MagicSmoke  $VERSION$
sman.h
Go to the documentation of this file.
1 //
2 // C++ Interface: Session Client
3 //
4 // Description: Session Client Class - connects to a session manager (or even starts one)
5 // and enables exchange of session data.
6 //
7 //
8 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
9 //
10 // Copyright: See README/COPYING.GPL files that come with this distribution
11 //
12 //
13 
14 #ifndef MAGICSMOKE_SC_SCLI_H
15 #define MAGICSMOKE_SC_SCLI_H
16 
17 #include <QObject>
18 #include <QList>
19 #include <QPair>
20 #include <QProcess>
21 
22 class QLocalServer;
23 class QLocalSocket;
24 class QSystemTrayIcon;
25 
26 class MSessionManager:public QObject
27 {
28  Q_OBJECT
29 public:
30  explicit MSessionManager ( QObject* parent = 0 );
31  virtual ~MSessionManager();
32 
33  virtual bool isActive()const;
34  virtual bool hasSession()const;
35  virtual QString sessionId()const;
36  virtual QString username()const;
37  virtual QString profile()const;
38  virtual QString profileName()const;
39 
40  int connectionCount()const{return mconnections.count();}
41  bool haveSlave()const{return mhaveslave;}
42 
43  virtual QList<QPair<QString,QString>> menuItems()const;
44 
45  static MSessionManager*instance();
46 
47  void setReady();
48 
49 private slots:
50  void newConnection();
51  void readyRead();
52  void socketClosed();
53  void socketLost(QObject*);
54 
55  void execCmd(const QString&);
56 
57  void loginSucceeded();
58  void sendNewSessionId();
59  void loginLost();
60  void processLost(int,QProcess::ExitStatus);
61 
62 signals:
63  void openConfig();
64  void setProfile(QString);
65  void setUsername(QString);
66  void setPassword(QString);
67  void startLogin();
68 
69 private:
70  QLocalServer*mserver=nullptr;
71  QList<QLocalSocket*>mconnections;
72  QString mkey;
73  QSystemTrayIcon*micon;
74  bool mhaveslave=false;
75  bool misready=false;
76 
77  void sendMenu(QLocalSocket*);
78  void sendProfiles(QLocalSocket*);
79  void sendSessionInfo(QLocalSocket*);
80  void startBinary(QString);
81 };
82 
83 
84 #endif
virtual QString sessionId() const
Definition: sman.cpp:122
virtual QString username() const
Definition: sman.cpp:131
MSessionManager(QObject *parent=0)
Definition: sman.cpp:38
virtual bool isActive() const
Definition: sman.cpp:158
void setUsername(QString)
int connectionCount() const
Definition: sman.h:40
virtual QString profile() const
Definition: sman.cpp:140
void setReady()
Definition: sman.cpp:355
Definition: sman.h:26
void setPassword(QString)
virtual bool hasSession() const
Definition: sman.cpp:113
static MSessionManager * instance()
Definition: sman.cpp:108
void setProfile(QString)
virtual ~MSessionManager()
Definition: sman.cpp:93
bool haveSlave() const
Definition: sman.h:41
virtual QList< QPair< QString, QString > > menuItems() const
Definition: sman.cpp:363
virtual QString profileName() const
Definition: sman.cpp:149