setWindowTitle("Magic Smoke");
//create Menu Bar
QMenuBar*mb=menuBar();
- QMenu*m=mb->addMenu("&File");
- m->addAction("&New Profile...",this,SLOT(newProfile()));
- m->addAction("&Save Profile",this,SLOT(saveProfile()));
+ QMenu*m=mb->addMenu(tr("&File"));
+ m->addAction(tr("&New Profile..."),this,SLOT(newProfile()));
+ m->addAction(tr("&Save Profile"),this,SLOT(saveProfile()));
m->addSeparator();
- m->addAction("&Close Window",this,SLOT(close()));
- m=mb->addMenu("&Configure");
+ m->addAction(tr("&Close Window"),this,SLOT(close()));
+ m=mb->addMenu(tr("&Configure"));
//create central widget
QWidget *loginwidget;
gl->setRowStretch(++lctr,10);
gl->addLayout(hl=new QHBoxLayout,++lctr,0,1,2);
QPushButton*p;
- hl->addWidget(p=new QPushButton("new Profile"),0);
+ hl->addWidget(p=new QPushButton(tr("new Profile")),0);
connect(p,SIGNAL(clicked()),this,SLOT(newProfile()));
- hl->addWidget(p=new QPushButton("save Profile"),0);
+ hl->addWidget(p=new QPushButton(tr("save Profile")),0);
connect(p,SIGNAL(clicked()),this,SLOT(saveProfile()));
hl->addStretch(10);
- hl->addWidget(p=new QPushButton("Login"),0);
+ hl->addWidget(p=new QPushButton(tr("Login")),0);
connect(p,SIGNAL(clicked()),this,SLOT(saveProfile()));
connect(p,SIGNAL(clicked()),this,SLOT(startLogin()));
initProfiles();
#include "webrequest.h"
#include <QSettings>
-#include <QCoreApplication>
+#include <QMessageBox>
+#include <QTabWidget>
+#include <QStatusBar>
+#include <QMenuBar>
+#include <QMenu>
MOverview::MOverview(MWebRequest*mw,QString pk)
{
req=mw;
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle("MagicSmoke: "+QSettings().value("profiles/"+pk+"/name").toString());
+
+ //menu
+ QMenuBar*mb=menuBar();
+ QMenu*m=mb->addMenu(tr("&Session"));
+ m->addAction(tr("&Re-Login"),this,SLOT(relogin()));
+ m->addSeparator();
+ m->addAction(tr("&Close Session"),this,SLOT(close()));
+
+ m=mb->addMenu(tr("&Event"));
+ m=mb->addMenu(tr("&Customer"));
+ m=mb->addMenu(tr("C&onfigure"));
+ //tabs
+ setCentralWidget(tab=new QTabWidget);
+ tab->addTab(new QWidget,tr("Events"));
+ tab->addTab(new QWidget,tr("Customers"));
+ tab->addTab(new QWidget,tr("Order"));
+
+ //status bar
+ statusBar()->setSizeGripEnabled(true);
}
void MOverview::closeEvent(QCloseEvent*ce)
//free requestor
req->deleteLater();
}
+
+void MOverview::relogin()
+{
+ setEnabled(false);
+ if(!req->relogin())
+ QMessageBox::warning(this,tr("Warning"),tr("I was unable to renew the login at the server, the error was: %1").arg(req->errorString()));
+ setEnabled(true);
+}
#include <QMainWindow>
class MWebRequest;
+class QTabWidget;
/**Main Overview Window*/
class MOverview:public QMainWindow
{
+ Q_OBJECT
public:
/**construct the window with web-request/session handler and QSettings-key for current profile*/
MOverview(MWebRequest*,QString);
~MOverview();
protected:
void closeEvent(QCloseEvent*);
+ private slots:
+ void relogin();
private:
+ //my session object
MWebRequest*req;
+ //the profile associated with this session
QString profilekey;
+ //widgets
+ QTabWidget*tab;
};
#endif
<context>
<name>MMainWindow</name>
<message>
- <location filename="mainwindow.cpp" line="51"/>
+ <location filename="mainwindow.cpp" line="55"/>
<source>Profile:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="55"/>
+ <location filename="mainwindow.cpp" line="59"/>
<source>Alternate Hostname:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="58"/>
+ <location filename="mainwindow.cpp" line="62"/>
<source>Server URL:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="61"/>
+ <location filename="mainwindow.cpp" line="65"/>
<source>Proxy:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="73"/>
+ <location filename="mainwindow.cpp" line="86"/>
<source>Username:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="76"/>
+ <location filename="mainwindow.cpp" line="89"/>
<source>Password:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="161"/>
+ <location filename="mainwindow.cpp" line="177"/>
<source>New Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="161"/>
+ <location filename="mainwindow.cpp" line="177"/>
<source>Please enter a profile name. It must be non-empty and must not be used yet:</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <location filename="mainwindow.cpp" line="74"/>
+ <source>Proxy Username:</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="77"/>
+ <source>Proxy Password:</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="202"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="202"/>
+ <source>Unable to log in. Error: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="41"/>
+ <source>&File</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="42"/>
+ <source>&New Profile...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="43"/>
+ <source>&Save Profile</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="45"/>
+ <source>&Close Window</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="46"/>
+ <source>&Configure</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="96"/>
+ <source>new Profile</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="98"/>
+ <source>save Profile</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="101"/>
+ <source>Login</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>MOverview</name>
+ <message>
+ <location filename="overview.cpp" line="31"/>
+ <source>&Session</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="32"/>
+ <source>&Re-Login</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="34"/>
+ <source>&Close Session</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="36"/>
+ <source>&Event</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="37"/>
+ <source>&Customer</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="38"/>
+ <source>C&onfigure</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="41"/>
+ <source>Events</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="42"/>
+ <source>Customers</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="43"/>
+ <source>Order</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="67"/>
+ <source>Warning</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="67"/>
+ <source>I was unable to renew the login at the server, the error was: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>MWebRequest</name>
+ <message>
+ <location filename="webrequest.cpp" line="146"/>
+ <source>Unable to get server info.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="153"/>
+ <source>Error while parsing server info (line %1 col %2): %3</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="158"/>
+ <source>Error in server info: missing authentication algorithm info.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="163"/>
+ <source>The server requested an unsupported hash algorithm: %1.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="169"/>
+ <source>Unable to get authentication challenge.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="173"/>
+ <source>Error while parsing session challenge (line %1 col %2): %3</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="179"/>
+ <source>Error in session challenge: missing session ID.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="185"/>
+ <source>Error in session challenge: missing host challenge.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="191"/>
+ <source>Error in session challenge: missing user challenge.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="217"/>
+ <source>Failed to log in: user/password mismatch, non-allowed host key, or challenge timed out.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="221"/>
+ <source>Unable to authenticate.</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>initkey</name>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1" language="de">
+<defaultcodec></defaultcodec>
<context>
<name>MKeyGen</name>
<message>
<context>
<name>MMainWindow</name>
<message>
- <location filename="mainwindow.cpp" line="51"/>
+ <location filename="mainwindow.cpp" line="55"/>
<source>Profile:</source>
- <translation type="unfinished"></translation>
+ <translation>Brofiel:</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="55"/>
+ <location filename="mainwindow.cpp" line="59"/>
<source>Alternate Hostname:</source>
- <translation type="unfinished"></translation>
+ <translation>Andror Reschnername:</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="58"/>
+ <location filename="mainwindow.cpp" line="62"/>
<source>Server URL:</source>
- <translation type="unfinished"></translation>
+ <translation>URL vom diggen Reschnor:</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="61"/>
+ <location filename="mainwindow.cpp" line="65"/>
<source>Proxy:</source>
- <translation type="unfinished"></translation>
+ <translation>Web-Broggsie:</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="73"/>
+ <location filename="mainwindow.cpp" line="86"/>
<source>Username:</source>
- <translation type="unfinished"></translation>
+ <translation>Nudsorname:</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="76"/>
+ <location filename="mainwindow.cpp" line="89"/>
<source>Password:</source>
- <translation type="unfinished"></translation>
+ <translation>Gans doll geheimer Gohd:</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="161"/>
+ <location filename="mainwindow.cpp" line="177"/>
<source>New Profile</source>
- <translation type="unfinished"></translation>
+ <translation>Neues Brofiel</translation>
</message>
<message>
- <location filename="mainwindow.cpp" line="161"/>
+ <location filename="mainwindow.cpp" line="177"/>
<source>Please enter a profile name. It must be non-empty and must not be used yet:</source>
- <translation type="unfinished"></translation>
+ <translation>Bidde gäben'se 'nen Namen für das neue Brofiel ein. Der darf noch ni' benudsd sein und leer darf'or och nedd sein:</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="74"/>
+ <source>Proxy Username:</source>
+ <translation>Nudsername für'n Broggsie:</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="77"/>
+ <source>Proxy Password:</source>
+ <translation>Geheimer Gohd für'n Broggsie:</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="202"/>
+ <source>Warning</source>
+ <translation>Dumm gelaufen</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="202"/>
+ <source>Unable to log in. Error: %1</source>
+ <translation>Isch gann nisch off'n gross'n Reschner. Der will nisch weil: %1</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="41"/>
+ <source>&File</source>
+ <translation>&Dadai</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="42"/>
+ <source>&New Profile...</source>
+ <translation>&Neues Brofiel</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="43"/>
+ <source>&Save Profile</source>
+ <translation>Brofiel &schbeichorn</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="45"/>
+ <source>&Close Window</source>
+ <translation>Fänsdor &zumach'n</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="46"/>
+ <source>&Configure</source>
+ <translation>&Gonfiguriern</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="96"/>
+ <source>new Profile</source>
+ <translation>Neues Brofiel</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="98"/>
+ <source>save Profile</source>
+ <translation>Brofiel schbeichorn</translation>
+ </message>
+ <message>
+ <location filename="mainwindow.cpp" line="101"/>
+ <source>Login</source>
+ <translation>Droff offn' Reschnor</translation>
+ </message>
+</context>
+<context>
+ <name>MOverview</name>
+ <message>
+ <location filename="overview.cpp" line="31"/>
+ <source>&Session</source>
+ <translation>&Sidsung</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="32"/>
+ <source>&Re-Login</source>
+ <translation>&Noch'ma einloggn</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="34"/>
+ <source>&Close Session</source>
+ <translation>Sidsung &Zumachn</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="36"/>
+ <source>&Event</source>
+ <translation>&Veranschdaldung</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="37"/>
+ <source>&Customer</source>
+ <translation>&Gunde</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="38"/>
+ <source>C&onfigure</source>
+ <translation>G&onfiguriern</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="41"/>
+ <source>Events</source>
+ <translation>Veranschdaldungen</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="42"/>
+ <source>Customers</source>
+ <translation>Gunden</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="43"/>
+ <source>Order</source>
+ <translation>Beschdellung</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="67"/>
+ <source>Warning</source>
+ <translation>Dumm gelaufen</translation>
+ </message>
+ <message>
+ <location filename="overview.cpp" line="67"/>
+ <source>I was unable to renew the login at the server, the error was: %1</source>
+ <translation>Isch gann de' Verbindung off'n gross'n Reschner nisch erneuern. Der will nisch weil: %1</translation>
+ </message>
+</context>
+<context>
+ <name>MWebRequest</name>
+ <message>
+ <location filename="webrequest.cpp" line="146"/>
+ <source>Unable to get server info.</source>
+ <translation>Dor grosse Reschner will mir nischd über sisch sach'n. Dummer Hund der.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="153"/>
+ <source>Error while parsing server info (line %1 col %2): %3</source>
+ <translation>Isch gann den gross'n Reschner nich verschdehn. Dor Fählor "%3" bassierd auf dor Dseile %1, Schbalde %2.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="158"/>
+ <source>Error in server info: missing authentication algorithm info.</source>
+ <translation>Dor grosse Reschnor will mir nedd sach'n wie mor offn' droff gommd. Missd.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="163"/>
+ <source>The server requested an unsupported hash algorithm: %1.</source>
+ <translation>Dor grosse Reschnor will 'ne Bereschnung von mir, die isch nedd gann: %1.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="169"/>
+ <source>Unable to get authentication challenge.</source>
+ <translation>Dor grosse Reschnor reded nedd mit mir. Isch grich gehn "Schällänsch".</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="173"/>
+ <source>Error while parsing session challenge (line %1 col %2): %3</source>
+ <translation>Isch gann den gross'n Reschner nich verschdehn. Dor Fählor "%3" bassierd auf dor Dseile %1, Schbalde %2.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="179"/>
+ <source>Error in session challenge: missing session ID.</source>
+ <translation>Fählor im "Schällänsch": der had gehne "Säschn-Ei-Dih".</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="185"/>
+ <source>Error in session challenge: missing host challenge.</source>
+ <translation>Fählor im "Schällänsch": der had nischd fürn Gombjuder.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="191"/>
+ <source>Error in session challenge: missing user challenge.</source>
+ <translation>Fählor im "Schällänsch": der had nischd fürn Nudsor.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="217"/>
+ <source>Failed to log in: user/password mismatch, non-allowed host key, or challenge timed out.</source>
+ <translation>Isch gann nisch offn' grossen Reschnor. Das hadd zu lange gedauerd oder Du hasd'sch vordibbd.</translation>
+ </message>
+ <message>
+ <location filename="webrequest.cpp" line="221"/>
+ <source>Unable to authenticate.</source>
+ <translation>Isch gann misch ned anmälden.</translation>
</message>
</context>
<context>
return QByteArray();
}
-bool MWebRequest::login(QString usr,QString pwd,QString hostname)
+bool MWebRequest::login(QString usr,QString pwd,QString hn)
+{
+ user=usr;passwd=pwd;hostname=hn;
+ return doLogin();
+}
+
+bool MWebRequest::doLogin()
{
//get authentication algo
if(!request("serverinfo"))return false;
QString ucha=nl.at(0).toElement().text().trimmed();
//calculate auth
hcha=calcAuth(algo,hcha,QSettings().value("hostkey").toString());
- ucha=calcAuth(algo,ucha,pwd);
+ ucha=calcAuth(algo,ucha,passwd);
//create auth msg
QDomDocument adoc("Authenticate");
del=adoc.createElement("SessionAuth");
el.appendChild(adoc.createTextNode(hcha));
del.appendChild(el);
el=adoc.createElement("UserName");
- el.appendChild(adoc.createTextNode(usr));
+ el.appendChild(adoc.createTextNode(user));
del.appendChild(el);
el=adoc.createElement("UserAuth");
el.appendChild(adoc.createTextNode(ucha));
void MWebRequest::logout()
{
- request("closesession",QByteArray());
+ request("closesession");
+}
+
+bool MWebRequest::relogin()
+{
+ request("closesession");
+ return doLogin();
}
QString MWebRequest::errorString()
{
return errstr;
}
+
+bool MWebRequest::hasRole(QString r)
+{
+ //get roles
+ if(roles.size()==0){
+ //get roles from server
+ if(!request("getmyroles"))return false;
+ //parse data
+ QStringList rls=QString::fromAscii(rspdata).split("\n",QString::SkipEmptyParts);
+ for(int i=0;i<rls.size();i++){
+ QString rl=rls[i].trimmed().toLower();
+ if(rl=="")continue;
+ roles<<rl;
+ }
+ //if none: put in a dummy to avoid asking again
+ if(roles.size()==0)roles<<"__none__";
+ }
+ //check whether we are admin
+ if(roles.contains("_admin"))return true;
+ //check whether we have role
+ return roles.contains(r.toLower());
+}
/**returns the last error as string*/
QString errorString();
+ /**returns whether the user has a specific role/right*/
+ bool hasRole(QString);
+
public slots:
/**set how long to wait for a web request*/
void setTimeout(int);
/**log in to web server; requires username/password and the local host name as arguments*/
bool login(QString user,QString passwd,QString hostname);
+ /**re-log in to web server with previously set values*/
+ bool relogin();
/**log out of web server*/
void logout();
int webtimeout,proxyport;
//login data
QString user,passwd,sessionid,hostname;
+ //accounting data
+ QStringList roles;
//error data
QString errstr;
bool finerr,fin;
QString rspstatus;
QByteArray rspdata;
int finid,waitid;
+
+ /**used by login and relogin to do the actual work*/
+ bool doLogin();
};
#endif
$ALLOWEDREQUESTS=array(
"serverinfo", //info request
"startsession","sessionauth","closesession", //session requests
- "getmyroles" //role management
+ //all requests below here need authentication
+ "getmyroles", //role management
+ //all requests below here need a role entry in the DB
+ "geteventlist", "geteventdata", //event infos
+ "getcustomerlist" //customer info
);
/**contains the low-level request name from the client*/
$SMOKEREQUEST=strtolower($_SERVER["HTTP_X_MAGICSMOKE_REQUEST"]);