From 861718f9e1dbdc61ea2aefdb3e4d57e1274b8718 Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 15 Sep 2007 13:47:54 +0000 Subject: [PATCH] some more functions more i18n git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@27 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/mainwindow.cpp | 16 ++-- src/overview.cpp | 33 ++++++++- src/overview.h | 8 ++ src/smoke_de.ts | 192 ++++++++++++++++++++++++++++++++++++++++++++-- src/smoke_de_SAX.ts | 209 +++++++++++++++++++++++++++++++++++++++++++++++---- src/webrequest.cpp | 42 +++++++++- src/webrequest.h | 10 +++ www/machine.php | 6 +- 8 files changed, 478 insertions(+), 38 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a51d5bc..f320b51 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -38,12 +38,12 @@ MMainWindow::MMainWindow() 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; @@ -93,12 +93,12 @@ MMainWindow::MMainWindow() 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(); diff --git a/src/overview.cpp b/src/overview.cpp index 084c5da..dd76f16 100644 --- a/src/overview.cpp +++ b/src/overview.cpp @@ -14,13 +14,36 @@ #include "webrequest.h" #include -#include +#include +#include +#include +#include +#include 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) @@ -36,3 +59,11 @@ MOverview::~MOverview() //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); +} diff --git a/src/overview.h b/src/overview.h index 9c216ec..d5ba10a 100644 --- a/src/overview.h +++ b/src/overview.h @@ -16,19 +16,27 @@ #include 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 diff --git a/src/smoke_de.ts b/src/smoke_de.ts index 487dcf5..2e07296 100644 --- a/src/smoke_de.ts +++ b/src/smoke_de.ts @@ -33,45 +33,221 @@ At least %1 Bits of random are required. MMainWindow - + Profile: - + Alternate Hostname: - + Server URL: - + Proxy: - + Username: - + Password: - + New Profile - + Please enter a profile name. It must be non-empty and must not be used yet: + + + Proxy Username: + + + + + Proxy Password: + + + + + Warning + + + + + Unable to log in. Error: %1 + + + + + &File + + + + + &New Profile... + + + + + &Save Profile + + + + + &Close Window + + + + + &Configure + + + + + new Profile + + + + + save Profile + + + + + Login + + + + + MOverview + + + &Session + + + + + &Re-Login + + + + + &Close Session + + + + + &Event + + + + + &Customer + + + + + C&onfigure + + + + + Events + + + + + Customers + + + + + Order + + + + + Warning + + + + + I was unable to renew the login at the server, the error was: %1 + + + + + MWebRequest + + + Unable to get server info. + + + + + Error while parsing server info (line %1 col %2): %3 + + + + + Error in server info: missing authentication algorithm info. + + + + + The server requested an unsupported hash algorithm: %1. + + + + + Unable to get authentication challenge. + + + + + Error while parsing session challenge (line %1 col %2): %3 + + + + + Error in session challenge: missing session ID. + + + + + Error in session challenge: missing host challenge. + + + + + Error in session challenge: missing user challenge. + + + + + Failed to log in: user/password mismatch, non-allowed host key, or challenge timed out. + + + + + Unable to authenticate. + + initkey diff --git a/src/smoke_de_SAX.ts b/src/smoke_de_SAX.ts index 441d295..390e188 100644 --- a/src/smoke_de_SAX.ts +++ b/src/smoke_de_SAX.ts @@ -1,5 +1,6 @@ + MKeyGen @@ -33,44 +34,220 @@ At least %1 Bits of random are required. MMainWindow - + Profile: - + Brofiel: - + Alternate Hostname: - + Andror Reschnername: - + Server URL: - + URL vom diggen Reschnor: - + Proxy: - + Web-Broggsie: - + Username: - + Nudsorname: - + Password: - + Gans doll geheimer Gohd: - + New Profile - + Neues Brofiel - + Please enter a profile name. It must be non-empty and must not be used yet: - + 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: + + + + Proxy Username: + Nudsername für'n Broggsie: + + + + Proxy Password: + Geheimer Gohd für'n Broggsie: + + + + Warning + Dumm gelaufen + + + + Unable to log in. Error: %1 + Isch gann nisch off'n gross'n Reschner. Der will nisch weil: %1 + + + + &File + &Dadai + + + + &New Profile... + &Neues Brofiel + + + + &Save Profile + Brofiel &schbeichorn + + + + &Close Window + Fänsdor &zumach'n + + + + &Configure + &Gonfiguriern + + + + new Profile + Neues Brofiel + + + + save Profile + Brofiel schbeichorn + + + + Login + Droff offn' Reschnor + + + + MOverview + + + &Session + &Sidsung + + + + &Re-Login + &Noch'ma einloggn + + + + &Close Session + Sidsung &Zumachn + + + + &Event + &Veranschdaldung + + + + &Customer + &Gunde + + + + C&onfigure + G&onfiguriern + + + + Events + Veranschdaldungen + + + + Customers + Gunden + + + + Order + Beschdellung + + + + Warning + Dumm gelaufen + + + + I was unable to renew the login at the server, the error was: %1 + Isch gann de' Verbindung off'n gross'n Reschner nisch erneuern. Der will nisch weil: %1 + + + + MWebRequest + + + Unable to get server info. + Dor grosse Reschner will mir nischd über sisch sach'n. Dummer Hund der. + + + + Error while parsing server info (line %1 col %2): %3 + Isch gann den gross'n Reschner nich verschdehn. Dor Fählor "%3" bassierd auf dor Dseile %1, Schbalde %2. + + + + Error in server info: missing authentication algorithm info. + Dor grosse Reschnor will mir nedd sach'n wie mor offn' droff gommd. Missd. + + + + The server requested an unsupported hash algorithm: %1. + Dor grosse Reschnor will 'ne Bereschnung von mir, die isch nedd gann: %1. + + + + Unable to get authentication challenge. + Dor grosse Reschnor reded nedd mit mir. Isch grich gehn "Schällänsch". + + + + Error while parsing session challenge (line %1 col %2): %3 + Isch gann den gross'n Reschner nich verschdehn. Dor Fählor "%3" bassierd auf dor Dseile %1, Schbalde %2. + + + + Error in session challenge: missing session ID. + Fählor im "Schällänsch": der had gehne "Säschn-Ei-Dih". + + + + Error in session challenge: missing host challenge. + Fählor im "Schällänsch": der had nischd fürn Gombjuder. + + + + Error in session challenge: missing user challenge. + Fählor im "Schällänsch": der had nischd fürn Nudsor. + + + + Failed to log in: user/password mismatch, non-allowed host key, or challenge timed out. + Isch gann nisch offn' grossen Reschnor. Das hadd zu lange gedauerd oder Du hasd'sch vordibbd. + + + + Unable to authenticate. + Isch gann misch ned anmälden. diff --git a/src/webrequest.cpp b/src/webrequest.cpp index 82286cc..2e51976 100644 --- a/src/webrequest.cpp +++ b/src/webrequest.cpp @@ -132,7 +132,13 @@ static inline QString calcAuth(QString algo,QString cha,QString pwd) 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; @@ -188,7 +194,7 @@ bool MWebRequest::login(QString usr,QString pwd,QString hostname) 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"); @@ -199,7 +205,7 @@ bool MWebRequest::login(QString usr,QString pwd,QString hostname) 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)); @@ -222,10 +228,38 @@ bool MWebRequest::login(QString usr,QString pwd,QString hostname) 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