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