Blame view

LiveChat/FeiTalk/JusDoodle/DoodleManager.h 1.93 KB
9f17d59e   陈明泉   no message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  #ifndef _DOODLE_MANAGER_H__
  #define _DOODLE_MANAGER_H__
  
  #include <QtCore>
  #include "../mainapp.h"
  
  namespace JusDoodle {
  
  typedef int SESSID;
  
  class DoodleSession;
  
  class DoodleManager : public QObject
  {
      Q_OBJECT
  
  private Q_SLOTS:
      void onServiceEvent(const QString &name, size_t cookie, const Notification &info);    
  
  public:
      DoodleManager(QObject *parent = 0);
      virtual ~DoodleManager();
  
      // singleton
      static DoodleManager *Instance();
  
      // Initialization
      // Session create when MtcCallConnectingNotification received,
      // and delete when MtcCallTermedNotification or MtcCallDidTermNotification.
      // 
      // All sessions will be deleted when MtcCliServerLogoutedNotification
      // or MtcCliServerDidLogoutNotification.
      // 
      // Session has the same id of corresponding call.
      bool init();
  
      // Start doodle session.
      // Show doodle window. When start for the first time, 
      // MTC_DOODLE_ACTION_START action will be sent as well.
      bool startSess(SESSID sessId, int pageCount);
  
      // Stop doodle session, hide the doodle window.
      // Received data will be saved in session.
      void stopSess(SESSID sessId);
  
      // Set background images.
      void setBackgroundImages(SESSID sessId, const QStringList &imagePaths);
  
      // Interface when data received. Useless right now.
      void onRecvData(SESSID sessId, const char *name, const char *data);
  
      DoodleSession *findSess(SESSID sessId);
  
  Q_SIGNALS:
      // Emit after a session is created
      void sessCreated(int sessId);
  
  private:
      // Get session from ID.
  
      // Process call notification.
      bool onCallEvent(const QString &name, size_t cookie, const Notification &info);
  
      // Process client notification.
      bool onClientEvent(const QString &name, size_t cookie, const Notification &info);
  
  private:
      static DoodleManager *_pDoodleManager;
      std::map<SESSID, DoodleSession *> _SessMap;
  };
  
  } // namespace JusDoodle
  
  #endif /* _DOODLE_MANAGER_H__ */