|
1 /* |
|
2 * Copyright (c) 2007, 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Header file for Presence Cache Server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef PRESENCECACHESERVER_H |
|
20 #define PRESENCECACHESERVER_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32base.h> |
|
24 #include "presencecacheexpiry.h" |
|
25 |
|
26 class CPresenceCacheServiceStore; |
|
27 class CPresenceCacheSession; |
|
28 |
|
29 |
|
30 /** |
|
31 * Shutdown timer class, to help us in delayed shutdown. |
|
32 * @since S60 v3.2 |
|
33 */ |
|
34 class CShutdown : public CTimer |
|
35 { |
|
36 enum {KMyShutdownDelay=0x200000}; // approx 2s |
|
37 public: |
|
38 inline CShutdown(); |
|
39 inline void ConstructL(); |
|
40 inline void Start(); |
|
41 private: |
|
42 //Initiate server exit when the timer expires |
|
43 void RunL(); |
|
44 }; |
|
45 |
|
46 |
|
47 /** |
|
48 * Presence cache server class. |
|
49 * @since S60 v3.2 |
|
50 */ |
|
51 class CPresenceCacheServer : public CPolicyServer |
|
52 { |
|
53 public : // Constructors and destructors |
|
54 |
|
55 /** |
|
56 * NewLC. |
|
57 * Two-phased constructor. |
|
58 * @return Pointer to created CPresenceCacheServer object. |
|
59 */ |
|
60 static CPresenceCacheServer* NewLC(); |
|
61 |
|
62 /** |
|
63 * ~CPresenceCacheServer. |
|
64 * Execution and Destruction. |
|
65 */ |
|
66 virtual ~CPresenceCacheServer(); |
|
67 static void ExecuteL(); |
|
68 |
|
69 public: // New functions |
|
70 |
|
71 /** |
|
72 * IncrementSessions. |
|
73 * Increments the count of the active sessions for this server. |
|
74 */ |
|
75 void IncrementSessions(); |
|
76 |
|
77 /** |
|
78 * DecrementSessions. |
|
79 * Decrements the count of the active sessions for this server. |
|
80 * If no more sessions are in use the server terminates. |
|
81 */ |
|
82 void DecrementSessions(); |
|
83 |
|
84 /** |
|
85 * Finds whether given session is alive or not. |
|
86 * |
|
87 * @param aSession to look for. |
|
88 * @return ETrue if session is still alive |
|
89 */ |
|
90 TBool SessionExists(CPresenceCacheSession* aSession); |
|
91 |
|
92 /** |
|
93 * Start expiry check mechanism |
|
94 * All buddy infos are read and expired buddy infos are removed |
|
95 * non-blocking function |
|
96 */ |
|
97 inline void StartExpiryCheck(); |
|
98 |
|
99 protected: // Functions from base classes |
|
100 |
|
101 // From CActive |
|
102 TInt RunError( TInt aError ); |
|
103 |
|
104 private: // Constructors and destructors |
|
105 |
|
106 /** |
|
107 * CPresenceCacheServer. |
|
108 * C++ default constructor. |
|
109 * @param aPriority priority for this thread. |
|
110 */ |
|
111 CPresenceCacheServer( TInt aPriority ); |
|
112 |
|
113 /** |
|
114 * ConstructL. |
|
115 * 2nd phase constructor. |
|
116 */ |
|
117 void ConstructL(); |
|
118 |
|
119 private: // Functions from base classes |
|
120 |
|
121 /** |
|
122 * From CServer, NewSessionL. |
|
123 * Creates a cache server session. |
|
124 * @param aVersion The client version. |
|
125 * @param aMessage Message from client. |
|
126 * @return Pointer to new session. |
|
127 */ |
|
128 CSession2* NewSessionL( const TVersion& aVersion, |
|
129 const RMessage2& aMessage ) const; |
|
130 |
|
131 private: // Data |
|
132 |
|
133 /** |
|
134 * iSessionCount, the number of session owned by this server. |
|
135 */ |
|
136 TInt iSessionCount; |
|
137 |
|
138 |
|
139 CShutdown iShutdown; |
|
140 |
|
141 /// Own |
|
142 CPresenceCacheExpiry* iExpiryCheck; |
|
143 |
|
144 public: // testing only |
|
145 |
|
146 /** |
|
147 * OWN: Main Presence cache on server side. Used by all sessions. |
|
148 */ |
|
149 RPointerArray<CPresenceCacheServiceStore> iPresenceCache; |
|
150 |
|
151 }; |
|
152 |
|
153 inline void CPresenceCacheServer::StartExpiryCheck() |
|
154 { |
|
155 iExpiryCheck->Start(); |
|
156 } |
|
157 |
|
158 |
|
159 #endif // PRESENCECACHESERVER_H |
|
160 |
|
161 // End of File |
|
162 |