|
1 /** |
|
2 This file is part of CWRT package ** |
|
3 |
|
4 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** |
|
5 |
|
6 This program is free software: you can redistribute it and/or modify |
|
7 it under the terms of the GNU (Lesser) General Public License as |
|
8 published by the Free Software Foundation, version 2.1 of the License. |
|
9 This program is distributed in the hope that it will be useful, but |
|
10 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 (Lesser) General Public License for more details. You should have |
|
13 received a copy of the GNU (Lesser) General Public License along |
|
14 with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 */ |
|
16 |
|
17 |
|
18 #ifndef serviceipcserver_p_h |
|
19 #define serviceipcserver_p_h |
|
20 |
|
21 #include <QtCore> |
|
22 #include "serviceipcserver_p.h" |
|
23 #include "serviceipcserver.h" |
|
24 #include "sessionidtable.h" |
|
25 |
|
26 namespace WRT { |
|
27 |
|
28 class ServiceFwIPCServer; |
|
29 class ServiceIPCSession; |
|
30 class MServiceIPCObserver; |
|
31 |
|
32 /** |
|
33 * Private implementation interface for service framework server |
|
34 * This class is the abstract interface for all server backends |
|
35 */ |
|
36 class ServiceFwIPCServerPrivate |
|
37 { |
|
38 public: |
|
39 /** |
|
40 * Virtual destructor |
|
41 */ |
|
42 virtual ~ServiceFwIPCServerPrivate() {}; |
|
43 |
|
44 public: |
|
45 |
|
46 /** |
|
47 * Start listening for new service requests |
|
48 * @param aServerName name of the server |
|
49 * @return true if listen was successful |
|
50 */ |
|
51 virtual bool listen(const QString& aServerName) = 0; |
|
52 |
|
53 /** |
|
54 * Shutdown the server and stop serving clients |
|
55 * @return void |
|
56 */ |
|
57 virtual void disconnect() = 0; |
|
58 |
|
59 /** |
|
60 * IPC server lifetime should be configurable |
|
61 * @param aKeepServer to keep or disconnect IPC server when all clients are shutdown. |
|
62 * @return void |
|
63 */ |
|
64 virtual void configIpcServerLifetime(bool aKeepServer) = 0; |
|
65 |
|
66 //Keep session handle at high level, platform independent. |
|
67 inline QHash<int, ServiceIPCSession*> getBroadcastSessions() { return m_broadcastSessions; } |
|
68 |
|
69 |
|
70 inline void appendBroadcastList(int aSessionId, ServiceIPCSession * aSession) |
|
71 { |
|
72 m_broadcastSessions.insert(aSessionId, aSession); |
|
73 }; |
|
74 |
|
75 inline void removeBroadcastList(int aSessionId) |
|
76 { |
|
77 m_broadcastSessions.remove(aSessionId); |
|
78 }; |
|
79 /* |
|
80 Release session ID from iSessionIdTable |
|
81 @param aSession |
|
82 */ |
|
83 inline void releaseSessionId(int aSessionId) |
|
84 { |
|
85 m_sessionIdTable->release(aSessionId); |
|
86 }; |
|
87 |
|
88 /* |
|
89 Allocate session ID from iSessionIdTable |
|
90 @return new Session ID |
|
91 */ |
|
92 inline int allocateSessionId() |
|
93 { |
|
94 return m_sessionIdTable->allocate(); |
|
95 }; |
|
96 |
|
97 protected: |
|
98 |
|
99 /** |
|
100 * Get the server observer |
|
101 * @return MServiceIPCObserver* observer to this server |
|
102 */ |
|
103 inline MServiceIPCObserver* Observer() |
|
104 { |
|
105 return q->m_Observer; |
|
106 }; |
|
107 |
|
108 inline void startExitTimer() |
|
109 { |
|
110 return q->startTimer(); |
|
111 }; |
|
112 |
|
113 inline void stopExitTimer() |
|
114 { |
|
115 return q->stopTimer(); |
|
116 }; |
|
117 |
|
118 |
|
119 protected: |
|
120 QList<ServiceIPCSession*> m_Sessions; |
|
121 |
|
122 //use for broadcast message to clients |
|
123 QHash<int, ServiceIPCSession*> m_broadcastSessions; |
|
124 |
|
125 SessionIdTable* m_sessionIdTable; |
|
126 |
|
127 private: |
|
128 friend class ServiceFwIPCServer; |
|
129 ServiceFwIPCServer* q; |
|
130 }; |
|
131 |
|
132 } |
|
133 #endif // serviceipcserver_p_h |