|
1 /* |
|
2 * Copyright (c) 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: The cache stores a single array of this type. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPRESENCECACHESERVICESTORE_H |
|
19 #define CPRESENCECACHESERVICESTORE_H |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 class CPresenceCacheBuddyStore; |
|
24 class MPresenceBuddyInfo2; |
|
25 |
|
26 /** |
|
27 * This class is used in presence cache store. The presence server has an array |
|
28 * of this object, each object represents the buddies in a specific service name. |
|
29 * This class contains an array of CPresenceCacheBuddyStore. The objects are |
|
30 * identified by their Identities. |
|
31 * |
|
32 * @lib presencecacheserver.exe |
|
33 * @since S60 v3.2 |
|
34 */ |
|
35 class CPresenceCacheServiceStore: public CBase |
|
36 { |
|
37 |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Symbian constructors and c++ destructor |
|
42 */ |
|
43 IMPORT_C static CPresenceCacheServiceStore* NewLC(); |
|
44 IMPORT_C static CPresenceCacheServiceStore* NewL(); |
|
45 virtual ~CPresenceCacheServiceStore(); |
|
46 |
|
47 private: |
|
48 |
|
49 /** |
|
50 * c++ constructor |
|
51 */ |
|
52 CPresenceCacheServiceStore(); |
|
53 |
|
54 /** |
|
55 * Symbian second phase constructor |
|
56 */ |
|
57 void ConstructL(); |
|
58 |
|
59 public: |
|
60 |
|
61 /** |
|
62 * Get the buddy stores pointer array contained by this object. |
|
63 * Those stores are owned by this object. |
|
64 * |
|
65 * @return reference to RPointerArray<CPresenceCacheSession> |
|
66 */ |
|
67 RPointerArray<CPresenceCacheBuddyStore>& GetObjectCollection(); |
|
68 |
|
69 |
|
70 /** |
|
71 * Service name of this object |
|
72 * |
|
73 * @return TPtrC service name of this object |
|
74 */ |
|
75 TPtrC ServiceName() const; |
|
76 |
|
77 |
|
78 /** |
|
79 * Sets service name of this object |
|
80 * |
|
81 * @param aServiceName service name for this object |
|
82 */ |
|
83 void SetServiceNameL(TDesC& aServiceName); |
|
84 |
|
85 |
|
86 /** |
|
87 * Count of buddy stores in this object. |
|
88 * |
|
89 * @return TInt number of buddy stores in this object |
|
90 */ |
|
91 TInt Count() const; |
|
92 |
|
93 |
|
94 /** |
|
95 * Count of those buddy stores who has presence info. |
|
96 * |
|
97 * @return TInt number of buddy stores who has presence info |
|
98 */ |
|
99 TInt PresenceCount() const; |
|
100 |
|
101 |
|
102 /** |
|
103 * Adds a buddy store object, without checking whether it exists or not. |
|
104 * Identity of the given store must be set. |
|
105 * It takes ownership of given buddy store. |
|
106 * |
|
107 * @param aPresenceBuddyInfo buddy store to add or replace. |
|
108 * @return TInt an error code |
|
109 */ |
|
110 TInt AddBlind(CPresenceCacheBuddyStore* aPresenceBuddyInfo); |
|
111 |
|
112 /** |
|
113 * Removes a buddy store object blindly. Unlike the other addition and removal |
|
114 * functions this will not modify the iPresenceCount. This will also not delete |
|
115 * the provided object. It's caller's responsiblity to delete it. |
|
116 * |
|
117 * @param aPresenceBuddyInfo buddy store to be removed |
|
118 */ |
|
119 void RemoveBlind(CPresenceCacheBuddyStore* aPresenceBuddyInfo); |
|
120 |
|
121 /** |
|
122 * Adds of replaces a buddies presence info. If the buddy is found, then only |
|
123 * presence info is updated, leaving subscribed sessions untouched. It is |
|
124 * recommended to use when an update to an already existing buddy receives. |
|
125 * It takes ownership of given presence info. |
|
126 * |
|
127 * @param aBuddyPresInfo buddy presence info to add or replace. |
|
128 * @return pointer to newly created or existing CPresenceCacheBuddyStore |
|
129 */ |
|
130 CPresenceCacheBuddyStore* AddOrReplacePresenceL(MPresenceBuddyInfo2* aBuddyPresInfo); |
|
131 |
|
132 |
|
133 /** |
|
134 * Finds removed the buddy store with given identity. If the buddy does not |
|
135 * contain any subscribed sessions, this function removes the whole buddy store. |
|
136 * But if there are subscribed sessions to this buddy, then it only removes |
|
137 * presence from that buddy. |
|
138 * |
|
139 * @param aIdentity identity of the given buddy to be searched. |
|
140 * @param aErr the error code is returned here. |
|
141 * @return pointer to removed CPresenceCacheBuddyStore, returns NULL if the |
|
142 * buddy store is completely removed, or not found. |
|
143 */ |
|
144 CPresenceCacheBuddyStore* FindAndRemove(const TDesC& aIdentity, TInt& aErr); |
|
145 |
|
146 /** |
|
147 * Finds and get the buddy store with given identity. |
|
148 * |
|
149 * @param aIdentity identity of the given buddy to be searched. |
|
150 * @return pointer to found CPresenceCacheBuddyStore, returns NULL if the |
|
151 * buddy store is not found. |
|
152 */ |
|
153 CPresenceCacheBuddyStore* FindAndGet(const TDesC& aIdentity) const; |
|
154 |
|
155 /** |
|
156 * Removes presence info from all buddy stores contained in this object. |
|
157 * Notice that those buddy stores which doesnt have any subscribed sessions, |
|
158 * would be completely removed. |
|
159 */ |
|
160 void RemoveAllPresences(); |
|
161 |
|
162 /** |
|
163 * Removes buddy info from store if buddy info is expired |
|
164 * @param aBuddyStores buddy store is added to this |
|
165 * array if buddy info is removed and there is subscribed session |
|
166 */ |
|
167 void RemoveExpiredBuddyInfos( |
|
168 RPointerArray<CPresenceCacheBuddyStore>& aBuddyStores ); |
|
169 |
|
170 private: // data |
|
171 |
|
172 |
|
173 /** |
|
174 * Array of owned CPresenceCacheBuddyStore pointers |
|
175 */ |
|
176 RPointerArray< CPresenceCacheBuddyStore> iBuddyStoreCollection; |
|
177 |
|
178 /** |
|
179 * OWN: Service name for this object |
|
180 */ |
|
181 HBufC* iServiceName; |
|
182 |
|
183 /** |
|
184 * OWN: Count of buddy stores which contain valid presence info, because there |
|
185 * can be objects whose presences are NULL |
|
186 */ |
|
187 TInt iPresenceCount; |
|
188 |
|
189 }; |
|
190 |
|
191 |
|
192 #endif // CPRESENCECACHESERVICESTORE_H |