create external admin client
authorKonrad Rosenbaum <konrad@silmor.de>
Mon, 11 Jul 2016 11:24:11 +0000 (13:24 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Mon, 11 Jul 2016 11:26:07 +0000 (13:26 +0200)
12 files changed:
Makefile
adminapp/adminapp.pro [new file with mode: 0644]
adminapp/main.cpp [new file with mode: 0644]
sessman/login.cpp
sessman/sman.cpp
sessman/sman.h
sessman/smoke-sm_de.ts
sessman/smoke-sm_en.ts
src/main.h
src/mwin/aclwin.h
src/mwin/tabwin.h
src/smokeexport.h [new file with mode: 0644]

index cdac6fc..0072c48 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -107,6 +107,7 @@ client: wob taurus tzone wbase
        cd mainapp && $(QMAKE) $(QMAKEFLAGS) && $(MAKE)
        cd sessman && $(QMAKE) $(QMAKEFLAGS) && $(MAKE)
        cd plugins && $(QMAKE) $(QMAKEFLAGS) && $(MAKE)
+       cd adminapp && $(QMAKE) $(QMAKEFLAGS) && $(MAKE)
 
 taurus:
        cd taurus && $(QMAKE) $(QMCFG) $(QMAKEFLAGS) && $(MAKE)
diff --git a/adminapp/adminapp.pro b/adminapp/adminapp.pro
new file mode 100644 (file)
index 0000000..13f0989
--- /dev/null
@@ -0,0 +1,20 @@
+#Project File for MagicSmoke
+# (c) Konrad Rosenbaum, 2016
+
+TEMPLATE = app
+TARGET = magicsmoke-admin
+
+
+#main source files
+SOURCES = main.cpp
+INCLUDEPATH += . ../src ../src/mwin
+LIBS+= -lmagicsmoke
+
+include (../basics.pri)
+
+include (../iface/iface.pri)
+include (../commonlib/commonlib.pri)
+include (../sesscli/sesscli.pri)
+
+#make sure dependencies are found
+DEPENDPATH += $$INCLUDEPATH
diff --git a/adminapp/main.cpp b/adminapp/main.cpp
new file mode 100644 (file)
index 0000000..27d1c10
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// C++ Implementation: main
+//
+// Description: Main Program
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007-2016
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+
+#include "aclwin.h"
+
+#include <scli.h>
+#include <mapplication.h>
+#include "msinterface.h"
+
+#include <WTransaction>
+#include "barcode-plugin.h"
+
+
+int main(int argc,char**argv)
+{
+       //create global app
+       MApplication app(argc,argv);
+       
+       //init
+       app.initialize();
+
+       //get session
+       MSessionClient sc;
+       sc.connect(&sc,SIGNAL(sessionLost()),&app,SLOT(quit()));
+       sc.connect(&sc,SIGNAL(managerLost()),&app,SLOT(quit()));
+       if(sc.waitForSessionAvailable()){
+               WTransaction::setLogPrefix("Admin-T");
+               MSInterface*ms=new MSInterface(sc.currentProfileId());
+               ms->loginSession(sc.currentUsername(), sc.currentSessionId());
+               ms->initialize();
+               MAclWindow::showWindow(nullptr);
+       }else{
+               qDebug()<<"Unable to get session. Giving up.";
+               return 1;
+       }
+       
+       return app.exec();
+}
index 9976746..be42348 100644 (file)
@@ -120,7 +120,7 @@ void MLogin::loadProfile()
 void MLogin::initClients(MSessionManager*sm)
 {
        //was sman started by a slave? If so: do not allow selection.
-       if(sm->connectionCount()>0){
+       if(sm->connectionCount()>0 || sm->haveSlave()){
                clients->setEnabled(false);
                return;
        }
index eff6959..b0637ae 100644 (file)
@@ -69,6 +69,7 @@ MSessionManager::MSessionManager ( QObject* parent ) : QObject ( parent )
                        ls.write(mkey.toLatin1()+"\n");
                        ls.waitForBytesWritten(1000);
                        ls.close();
+                       mhaveslave=true;
                }
        }
 
@@ -334,6 +335,7 @@ QList<QPair< QString, QString >> MSessionManager::menuItems() const
                _("@@main",tr("Start &Expert Client"));
                _("@wizard",tr("Start &Wizard"));
                _("@statistic",tr("Start &Statistics Client"));
+               _("@admin",tr("Start &Admin Client"));
                _("@print",tr("Start &Print@Home Daemon"));
                _("quit",tr("&Quit Session"));
        }
index 3ef0db7..c726ac5 100644 (file)
@@ -38,6 +38,7 @@ public:
        virtual QString profileName()const;
 
        int connectionCount()const{return mconnections.count();}
+       bool haveSlave()const{return mhaveslave;}
 
        virtual QList<QPair<QString,QString>> menuItems()const;
 
@@ -64,6 +65,7 @@ private:
        QList<QLocalSocket*>mconnections;
        QString mkey;
        QSystemTrayIcon*micon;
+       bool mhaveslave=false;
 
        void sendMenu(QLocalSocket*);
        void sendSessionInfo(QLocalSocket*);
index 71a2c13..d6f2357 100644 (file)
 <context>
     <name>MSessionManager</name>
     <message>
-        <location filename="sman.cpp" line="77"/>
+        <location filename="sman.cpp" line="78"/>
         <source>MagicSmoke Session Manager, waiting for login...</source>
         <translation>MagicSmoke Session Manager, warte auf Login...</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="268"/>
+        <location filename="sman.cpp" line="269"/>
         <source>Warning</source>
         <translation>Warnung</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="268"/>
+        <location filename="sman.cpp" line="269"/>
         <source>Cannot start a client while not logged in!</source>
         <translation>Programm kann nicht gestartet werden wenn noch kein Login besteht!</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="299"/>
+        <location filename="sman.cpp" line="300"/>
         <source>MagicSmoke Session Manager, logged in as %1 at %2.</source>
         <translation>MagicSmoke Session Manager, eingeloggt als %1 auf Profil %2.</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="333"/>
+        <location filename="sman.cpp" line="334"/>
         <source>&amp;Configuration...</source>
         <translation>&amp;Konfigurieren...</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="334"/>
+        <location filename="sman.cpp" line="335"/>
         <source>Start &amp;Expert Client</source>
         <translation>Starte &amp;Experten-Programm</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="335"/>
+        <location filename="sman.cpp" line="336"/>
         <source>Start &amp;Wizard</source>
         <translation>Starte &amp;Wizard</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="336"/>
+        <location filename="sman.cpp" line="337"/>
         <source>Start &amp;Statistics Client</source>
         <translation>Starte &amp;Statistik-Programm</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="337"/>
+        <location filename="sman.cpp" line="338"/>
+        <source>Start &amp;Admin Client</source>
+        <translation>Starte &amp;Administrationsprogramm</translation>
+    </message>
+    <message>
+        <location filename="sman.cpp" line="339"/>
         <source>Start &amp;Print@Home Daemon</source>
         <translation>Starte &amp;Print@Home Hintergrundprogramm</translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="338"/>
+        <location filename="sman.cpp" line="340"/>
         <source>&amp;Quit Session</source>
         <translation>Session &amp;Beenden</translation>
     </message>
index a9a1cc4..e58c53c 100644 (file)
 <context>
     <name>MSessionManager</name>
     <message>
-        <location filename="sman.cpp" line="77"/>
+        <location filename="sman.cpp" line="78"/>
         <source>MagicSmoke Session Manager, waiting for login...</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="268"/>
+        <location filename="sman.cpp" line="269"/>
         <source>Warning</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="268"/>
+        <location filename="sman.cpp" line="269"/>
         <source>Cannot start a client while not logged in!</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="299"/>
+        <location filename="sman.cpp" line="300"/>
         <source>MagicSmoke Session Manager, logged in as %1 at %2.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="333"/>
+        <location filename="sman.cpp" line="334"/>
         <source>&amp;Configuration...</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="334"/>
+        <location filename="sman.cpp" line="335"/>
         <source>Start &amp;Expert Client</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="335"/>
+        <location filename="sman.cpp" line="336"/>
         <source>Start &amp;Wizard</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="336"/>
+        <location filename="sman.cpp" line="337"/>
         <source>Start &amp;Statistics Client</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="337"/>
+        <location filename="sman.cpp" line="338"/>
+        <source>Start &amp;Admin Client</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="sman.cpp" line="339"/>
         <source>Start &amp;Print@Home Daemon</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="sman.cpp" line="338"/>
+        <location filename="sman.cpp" line="340"/>
         <source>&amp;Quit Session</source>
         <translation type="unfinished"></translation>
     </message>
index 49d34de..98e9b51 100644 (file)
 
 #include <QtCore/QtGlobal>
 
-#ifdef MAGICSMOKE_LIB_BUILD
-#define MAGICSMOKE_EXPORT Q_DECL_EXPORT
-#else
-#define MAGICSMOKE_EXPORT Q_DECL_IMPORT
-#endif
+#include "smokeexport.h"
 
 ///shortcut: the main function
 class MAGICSMOKE_EXPORT MagicSmokeMain
index fc1fd7e..d4365e4 100644 (file)
 #include <QTimer>
 
 #include "tabwin.h"
+#include "smokeexport.h"
 
 class MUserTab;
 class MHostTab;
 class MRoleTab;
 class MFlagTab;
 
-class MAclWindow:public MTabWin
+class MAGICSMOKE_EXPORT MAclWindow:public MTabWin
 {
        Q_OBJECT
        public:
index 4435e04..d692e6b 100644 (file)
 #include <QPointer>
 #include <QTimer>
 
+#include "smokeexport.h"
+
 class QTabWidget;
 class QStackedWidget;
 
 class MSInterface;
 
 /**Main Overview Window*/
-class MTabWin:public QMainWindow
+class MAGICSMOKE_EXPORT MTabWin:public QMainWindow
 {
        Q_OBJECT
        public:
diff --git a/src/smokeexport.h b/src/smokeexport.h
new file mode 100644 (file)
index 0000000..38658e3
--- /dev/null
@@ -0,0 +1,10 @@
+
+#ifndef MAGICSMOKE_EXPORT
+
+#ifdef MAGICSMOKE_LIB_BUILD
+#define MAGICSMOKE_EXPORT Q_DECL_EXPORT
+#else
+#define MAGICSMOKE_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif