|
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 |
|
25 class CPresenceCacheServiceStore; |
|
26 class CPresenceCacheSession; |
|
27 |
|
28 |
|
29 /** |
|
30 * Shutdown timer class, to help us in delayed shutdown. |
|
31 * @ingroup ximpprescacheserver |
|
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 * @ingroup ximpprescacheserver |
|
50 * @since S60 v3.2 |
|
51 */ |
|
52 class CPresenceCacheServer : public CServer2 |
|
53 { |
|
54 public : // Constructors and destructors |
|
55 |
|
56 /** |
|
57 * NewLC. |
|
58 * Two-phased constructor. |
|
59 * @return Pointer to created CPresenceCacheServer object. |
|
60 */ |
|
61 static CPresenceCacheServer* NewLC(); |
|
62 |
|
63 /** |
|
64 * ~CPresenceCacheServer. |
|
65 * Execution and Destruction. |
|
66 */ |
|
67 virtual ~CPresenceCacheServer(); |
|
68 static void ExecuteL(); |
|
69 |
|
70 public: // New functions |
|
71 |
|
72 /** |
|
73 * IncrementSessions. |
|
74 * Increments the count of the active sessions for this server. |
|
75 */ |
|
76 void IncrementSessions(); |
|
77 |
|
78 /** |
|
79 * DecrementSessions. |
|
80 * Decrements the count of the active sessions for this server. |
|
81 * If no more sessions are in use the server terminates. |
|
82 */ |
|
83 void DecrementSessions(); |
|
84 |
|
85 /** |
|
86 * Finds whether given session is alive or not. |
|
87 * |
|
88 * @param aSession to look for. |
|
89 * @return ETrue if session is still alive |
|
90 */ |
|
91 TBool SessionExists(CPresenceCacheSession* aSession); |
|
92 |
|
93 |
|
94 protected: // Functions from base classes |
|
95 |
|
96 // From CActive |
|
97 TInt RunError( TInt aError ); |
|
98 |
|
99 private: // Constructors and destructors |
|
100 |
|
101 /** |
|
102 * CPresenceCacheServer. |
|
103 * C++ default constructor. |
|
104 * @param aPriority priority for this thread. |
|
105 */ |
|
106 CPresenceCacheServer( TInt aPriority ); |
|
107 |
|
108 /** |
|
109 * ConstructL. |
|
110 * 2nd phase constructor. |
|
111 */ |
|
112 void ConstructL(); |
|
113 |
|
114 private: // Functions from base classes |
|
115 |
|
116 /** |
|
117 * From CServer, NewSessionL. |
|
118 * Creates a cache server session. |
|
119 * @param aVersion The client version. |
|
120 * @param aMessage Message from client. |
|
121 * @return Pointer to new session. |
|
122 */ |
|
123 CSession2* NewSessionL( const TVersion& aVersion, |
|
124 const RMessage2& aMessage ) const; |
|
125 |
|
126 private: // Data |
|
127 |
|
128 /** |
|
129 * iSessionCount, the number of session owned by this server. |
|
130 */ |
|
131 TInt iSessionCount; |
|
132 |
|
133 |
|
134 CShutdown iShutdown; |
|
135 |
|
136 public: // testing only |
|
137 |
|
138 /** |
|
139 * OWN: Main Presence cache on server side. Used by all sessions. |
|
140 */ |
|
141 RPointerArray<CPresenceCacheServiceStore> iPresenceCache; |
|
142 |
|
143 }; |
|
144 |
|
145 |
|
146 #endif // PRESENCECACHESERVER_H |
|
147 |
|
148 // End of File |
|
149 |