--- /dev/null
+Print@Home Templating and Settings
+===================================
+
+Server Side Settings
+---------------------
+
+Select bill template
+Select ticket and voucher templates
+ --> select print mode: one per page, several per page
+Select generic documents
+
+==> select names for each document
+
+Select Mail template
+ --> select Cc address(es) and From address
+ --> select which documents to append
+
+Select shipping types that use p@h
+
+Later on: combine them into one or several documents
+
+
+
+TODO: tell MS server which contact type is email
+
+
+Local Settings
+---------------
+
+When to run...
+
+Pre-selected username and profile
+
+Autostart/Autologin?
\ No newline at end of file
--- /dev/null
+//
+// C++ Implementation: print @ home
+//
+// Description: Client Settings
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#include "client.h"
+
+#include <QFormLayout>
+#include <QBoxLayout>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QComboBox>
+
+#define GROUP "PrintAtHome/Client"
+#define TIMER GROUP "/timermin"
+#define SETPROFILE GROUP "/setprofile"
+#define PROFILE GROUP "/profile"
+#define SETUSER GROUP "/setuser"
+#define USERNAME GROUP "/username"
+#define AUTOLOGIN GROUP "/autologin"
+#define PASSWD GROUP "/passwd"
+
+
+MPClientConfig::MPClientConfig(QWidget* parent)
+{
+ QVBoxLayout*vl;
+ setLayout(vl=new QVBoxLayout);
+ QFormLayout*fl;
+ vl->addLayout(fl=new QFormLayout);
+ fl->addRow(tr("Check Interval in Minutes:"),mtimer=new QSpinBox);
+ mtimer->setRange(1,10080);
+ mtimer->setValue(timerInMinutes());
+ fl->addRow("",msetprofile=new QCheckBox(tr("Preselect Profile")));
+ fl->addRow(tr("Profile:"),mprofile=new QComboBox);
+ connect(msetprofile,SIGNAL(clicked(bool)),mprofile,SLOT(setEnabled(bool)));
+ msetprofile->setChecked(preselectProfile());
+ //TODO: get profile names
+
+}
+
+void MPClientConfig::save()
+{
+
+}
--- /dev/null
+//
+// C++ Interface: print @ home, client config
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#ifndef MSMOKE_PAH_CLIENT_H
+#define MSMOKE_PAH_CLIENT_H
+
+#include <QDialog>
+
+class MPClientConfig:public QDialog
+{
+ Q_OBJECT
+public:
+ MPClientConfig(QWidget*parent=nullptr);
+
+ static int timerInMinutes();
+ static bool preselectProfile();
+ static QString preselectedProfileName();
+ static bool preselectUser();
+ static QString preselectedUserName();
+ static bool autoLogin();
+ static QString password();
+
+public slots:
+ void save();
+
+private:
+ QSpinBox*mtimer;
+ QCheckBox*msetprofile,msetuser,mautologin;
+ QLineEdit*musername,*mpassword;
+ QComboBox*mprofile;
+
+};
+
+#endif
+//
+// C++ Implementation: print q home
+//
+// Description: Main Program
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
#include "mapplication.h"
#include "msinterface.h"
#include "scli.h"
QMenu*ctx=new QMenu;
ctx->addAction(tr("Start &Printing now"));
ctx->addSeparator();
- ctx->addAction(tr("&Client Configuration..."));
+ ctx->addAction(tr("&Client Configuration..."),this,SLOT(clientConfig()));
ctx->addAction(tr("&Server Configuration..."));
ctx->addSeparator();
ctx->addAction(tr("&Quit"),qApp,SLOT(quit()));
setToolTip(tr("MagicSmoke Print@Home: %1 - logged in as %2 at %3").arg(mode).arg(user).arg(host));
}
+void PrintIcon::clientConfig()
+{
+
+}
+
int main(int argc,char**argv)
+//
+// C++ Interface: print @ home
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
#ifndef PAH_MAIN_H
#define PAH_MAIN_H
};
public slots:
void setPrintMode(PrintMode);
+ void clientConfig();
};
#endif
\ No newline at end of file
return !msid.isEmpty();
}
-QList< QPair< QString, QString > > MSessionClient::menuEntries() const
+QList< QPair< QString, QString > > MSessionClient::menuEntries(bool force) const
{
if(!isConnected())return QList<QPair<QString,QString>>();
- if(mmenu.isEmpty()){
+ if(mmenu.isEmpty()||force){
//get menu
QEventLoop loop;
connect(this,SIGNAL(menuChanged()),&loop,SLOT(quit()));
return mmenu;
}
+QList< QPair< QString, QString > > MSessionClient::profiles(bool force) const
+{
+ if(!isConnected())return QList<QPair<QString,QString>>();
+ if(mprofiles.isEmpty()||force){
+ //get menu
+ QEventLoop loop;
+ connect(this,SIGNAL(profilesChanged()),&loop,SLOT(quit()));
+ connect(this,SIGNAL(managerLost()),&loop,SLOT(quit()));
+ QTimer::singleShot(5000,&loop,SLOT(quit()));
+ msocket->write("getprofiles\n");
+ msocket->waitForBytesWritten(1000);
+ loop.exec();
+ }
+ return mprofiles;
+}
+
+QString MSessionClient::defaultProfileId() const
+{
+ if(mprofiles.isEmpty())profiles();
+ return mdefaultprofile;
+}
+
+
void MSessionClient::socketLost()
{
qDebug()<<"Warning: Session Manager Socket lost!";
}else if(cmd=="endmenu"){
qDebug()<<"New Menu received from Session Manager!";
emit menuChanged();
+ }else if(cmd=="newprofiles"){
+ mprofiles.clear();
+ mdefaultprofile.clear();
+ }else if(cmd=="haveprofile"){
+ const int pos=par.indexOf(' ');
+ if(pos<2){
+ qDebug()<<"Warning: received invalid haveprofile command. Ignoring it.";
+ continue;
+ }
+ mprofiles.append(QPair<QString,QString>(par.left(pos),par.mid(pos+1)));
+ }else if(cmd=="defaultprofile"){
+ mdefaultprofile=par;
+ }else if(cmd=="endprofiles"){
+ qDebug()<<"Received new list of profiles.";
+ emit profilesChanged();
}else if(cmd=="closed"){
msid.clear();
qDebug()<<"Warning: Session lost!";
msocket->write(QString("exec "+cmd+"\n").toUtf8());
}
+void MSessionClient::setProfile(QString pn)
+{
+ if(msocket && msocket->isOpen())
+ msocket->write(QString("setprofile %1\n").arg(pn).toUtf8());
+}
+
+void MSessionClient::login(QString user,QString password)
+{
+ if(msocket && msocket->isOpen())
+ msocket->write(QString("setuser %1\nsetpasswd %2\nlogin\n")
+ .arg(user)
+ .arg(password.toUtf8().toBase64())
+ .toUtf8());
+}
///Returns true if the client is connected to a manager. If false there is something wrong.
virtual bool isConnected()const;
- ///retrieves and returns the menu entries of the session manager
- virtual QList<QPair<QString,QString>> menuEntries()const;
+ ///retrieves and returns the menu entries of the session manager in the format command -> menu text
+ /// \param force if true: force fresh retrieval of the menu even if it is already known
+ virtual QList<QPair<QString,QString>> menuEntries(bool force=false)const;
+
+ ///retrieves and returns all configured profiles in the format profileId -> profile name
+ /// \param force if true: force fresh retrieval of the menu profiles if it is already known
+ virtual QList<QPair<QString,QString>> profiles(bool force=false)const;
+
+ ///gets the default profile ID
+ virtual QString defaultProfileId()const;
public slots:
void execServerCommand(QString);
+ void setProfile(QString);
+ void login(QString user,QString password);
signals:
void sessionIdChanged(QString sessionId);
void sessionLost();
void managerLost();
void menuChanged();
+ void profilesChanged();
private slots:
void socketLost();
private:
QLocalSocket*msocket=nullptr;
- QString msid,mprofile,muser;
- QList<QPair<QString,QString>> mmenu;
+ QString msid,mprofile,muser,mdefaultprofile;
+ QList<QPair<QString,QString>> mmenu,mprofiles;
};
#include <QSignalMapper>
#include <QSystemTrayIcon>
#include <QTimer>
+#include <QSettings>
#include "sman.h"
#include "login.h"
sendSessionInfo(s);
}else if(cmd=="getmenu")
sendMenu(s);
+ else if(cmd=="getprofiles")
+ sendProfiles(s);
else if(cmd=="exec")
execCmd(par.trimmed());
+ else if(cmd=="setprofile")
+ emit setProfile(par.trimmed());
+ else if(cmd=="setuser")
+ emit setUsername(par.trimmed());
+ else if(cmd=="setpasswd")
+ emit setPassword(QString::fromUtf8(QByteArray::fromBase64(par.trimmed())));
+ else if(cmd=="login")
+ emit startLogin();
else
qDebug()<<"Warning: unknown client command"<<cmd;
}
s->write("endmenu\n");
}
+void MSessionManager::sendProfiles(QLocalSocket*s)
+{
+ s->write("newprofiles\n");
+ QSettings set;
+ s->write(QString("defaultprofile %1\n").arg(set.value("defaultprofile").toString()).toUtf8());
+ set.beginGroup("profiles");
+ QStringList prf=set.childGroups();
+ for(int i=0;i<prf.size();i++){
+ s->write(QString("haveprofile %1 %2\n").arg(prf[i]).arg(set.value(prf[i]+"/name").toString()).toUtf8());
+ }
+ s->write("endprofiles\n");
+}
+
+
void MSessionManager::execCmd (const QString &cmd)
{
qDebug()<<"Received command"<<cmd;
signals:
void openConfig();
+ void setProfile(QString);
+ void setUsername(QString);
+ void setPassword(QString);
+ void startLogin();
private:
QLocalServer*mserver=nullptr;
bool mhaveslave=false;
void sendMenu(QLocalSocket*);
+ void sendProfiles(QLocalSocket*);
void sendSessionInfo(QLocalSocket*);
void startBinary(QString);
};