MagicSmoke  $VERSION$
scli.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 <QLocalSocket>
21 
22 #ifdef MAGICSMOKE_SESSCLI_LIB_BUILD
23 # define MAGICSMOKE_SESSCLI_EXPORT Q_DECL_EXPORT
24 #else
25 # define MAGICSMOKE_SESSCLI_EXPORT Q_DECL_IMPORT
26 #endif
27 
29 {
30  Q_OBJECT
31 public:
35  virtual ~MSessionClient();
36 
39  static MSessionClient*instance();
40 
43  virtual bool waitForSessionAvailable();
44 
46  virtual bool waitForReady();
47 
49  virtual bool sessionIsAvailable()const;
51  virtual QString currentSessionId()const;
53  virtual QString currentProfileId()const;
55  virtual QString currentUsername()const;
57  virtual bool isConnected()const;
58 
61  virtual QList<QPair<QString,QString>> menuEntries(bool force=false)const;
62 
65  virtual QList<QPair<QString,QString>> profiles(bool force=false)const;
66 
68  virtual QString defaultProfileId()const;
69 
70 public slots:
71  void execServerCommand(QString);
72  void setProfile(QString);
73  void login(QString user,QString password,bool attemptLogin=true);
74 
75 signals:
76  void sessionIdChanged(QString sessionId);
77  void sessionLost();
78  void managerLost();
79  void menuChanged();
80  void profilesChanged();
81  void readyReceived();
82 
83 private slots:
84  void socketLost();
85  void readSocket();
86 
87 private:
88  QLocalSocket*msocket=nullptr;
89  QString msid,mprofile,muser,mdefaultprofile;
90  QList<QPair<QString,QString>> mmenu,mprofiles;
91  bool misready=false;
92 };
93 
94 
95 #endif
#define MAGICSMOKE_SESSCLI_EXPORT
Definition: scli.h:25
Definition: scli.h:28