|
1 /* |
|
2 * Copyright (c) 2006 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: Contains CNcdNodeUserData class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NCD_NODE_USER_DATA_H |
|
20 #define NCD_NODE_USER_DATA_H |
|
21 |
|
22 |
|
23 // For streams |
|
24 #include <s32mem.h> |
|
25 |
|
26 #include "catalogscommunicable.h" |
|
27 #include "ncdstoragedataitem.h" |
|
28 #include "ncdnodeclassids.h" |
|
29 |
|
30 |
|
31 class CNcdNodeManager; |
|
32 class CNcdNodeIdentifier; |
|
33 |
|
34 |
|
35 /** |
|
36 * This server side class contains the data and the functionality |
|
37 * that the proxy objects will use to internalize itself. |
|
38 * |
|
39 * This object should be added to the session. So, it will be usable |
|
40 * in the proxy side by using the handle gotten during addition. |
|
41 * The handle is used to identify to what object the proxy directs |
|
42 * the function call. When objects are added to sessions, |
|
43 * multiple handles may be gotten for the same object if addition is |
|
44 * done multiple times. |
|
45 * |
|
46 * @lib ?library |
|
47 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
48 */ |
|
49 class CNcdNodeUserData : public CCatalogsCommunicable, |
|
50 public MNcdStorageDataItem |
|
51 { |
|
52 |
|
53 public: |
|
54 /** |
|
55 * NewL |
|
56 * |
|
57 * @param aIdentifier Identifies the node whose user data this class |
|
58 * object will contain. |
|
59 * @param aManager Used when the user data is read from or written |
|
60 * into the database. |
|
61 * @return CNcdNodeUserData* Pointer to the created object |
|
62 * of this class. |
|
63 */ |
|
64 static CNcdNodeUserData* NewL( const CNcdNodeIdentifier& aIdentifier, |
|
65 CNcdNodeManager& aManager ); |
|
66 |
|
67 /** |
|
68 * NewLC |
|
69 * |
|
70 * @param aIdentifier Identifies the node whose user data this class |
|
71 * object will contain. |
|
72 * @param aManager Used when the user data is read from or written |
|
73 * into the database. |
|
74 * @return CNcdNodeUserData* Pointer to the created object |
|
75 * of this class. |
|
76 */ |
|
77 static CNcdNodeUserData* NewLC( const CNcdNodeIdentifier& aIdentifier, |
|
78 CNcdNodeManager& aManager ); |
|
79 |
|
80 |
|
81 /** |
|
82 * Destructor |
|
83 * |
|
84 * @note Because this is CCatalogsCommunicable function the |
|
85 * session that owns this object should delete this class object. |
|
86 * So, instead of directly deleting this object from some other |
|
87 * class. Close-method should be used instead. |
|
88 */ |
|
89 virtual ~CNcdNodeUserData(); |
|
90 |
|
91 |
|
92 /** |
|
93 * Retrieves the data type that informs what class the data is for. |
|
94 * By checking the data type information, an InternalizeL function |
|
95 * of a right class can be called when the object data is set |
|
96 * from the storage. |
|
97 * The data type may be decided and set in a object that creates this |
|
98 * class object. |
|
99 * |
|
100 * @return NcdNodeClassIds::TNcdNodeClassId Describes the data type. |
|
101 */ |
|
102 NcdNodeClassIds::TNcdNodeClassId ClassId() const; |
|
103 |
|
104 |
|
105 public: // CCatalogsCommunicable |
|
106 |
|
107 /** |
|
108 * @see CCatalogsCommunicable::ReceiveMessage |
|
109 */ |
|
110 virtual void ReceiveMessage( MCatalogsBaseMessage* aMessage, |
|
111 TInt aFunctionNumber ); |
|
112 |
|
113 /** |
|
114 * @see CCatalogsCommunicable::CounterPartLost |
|
115 */ |
|
116 virtual void CounterPartLost( const MCatalogsSession& aSession ); |
|
117 |
|
118 |
|
119 public: // MNcdStorageDataItem |
|
120 |
|
121 /** |
|
122 * @see MNcdStorageDataItem::ExternalizeL |
|
123 */ |
|
124 virtual void ExternalizeL( RWriteStream& aStream ); |
|
125 |
|
126 |
|
127 /** |
|
128 * @see MNcdStorageDataItem::InternalizeL |
|
129 */ |
|
130 virtual void InternalizeL( RReadStream& aStream ); |
|
131 |
|
132 |
|
133 protected: |
|
134 |
|
135 /** |
|
136 * Constructor |
|
137 * |
|
138 * @param aClassId Identifies this class. |
|
139 * Is set in the NewLC function. |
|
140 * @param aManager Used when the user data is read from or written |
|
141 * into the database. |
|
142 */ |
|
143 CNcdNodeUserData( NcdNodeClassIds::TNcdNodeClassId aClassId, |
|
144 CNcdNodeManager& aManager ); |
|
145 |
|
146 /** |
|
147 * ConstructL |
|
148 * |
|
149 * @param aIdentifier Identifies the node whose user data this class |
|
150 * object will contain. |
|
151 */ |
|
152 virtual void ConstructL( const CNcdNodeIdentifier& aIdentifier ); |
|
153 |
|
154 |
|
155 // These functions are called from the ReceiveMessage when |
|
156 // the given function id has matched to the function. |
|
157 |
|
158 /** |
|
159 * This function is called when the proxy wants to get the |
|
160 * user data from the serverside. |
|
161 * @param aMessage Contains data from the proxy and can be used |
|
162 * to send data back to proxy. |
|
163 */ |
|
164 void UserDataRequestL( MCatalogsBaseMessage& aMessage ); |
|
165 |
|
166 /** |
|
167 * This function is called when the proxy wants to set the |
|
168 * user data into the db. |
|
169 * @param aMessage Contains data from the proxy and can be used |
|
170 * to send data back to proxy. |
|
171 */ |
|
172 void SetUserDataRequestL( MCatalogsBaseMessage& aMessage ); |
|
173 |
|
174 /** |
|
175 * This function is called when the proxy wants to clear the |
|
176 * user data of the node from the db. |
|
177 * @param aMessage Contains data from the proxy and can be used |
|
178 * to send data back to proxy. |
|
179 */ |
|
180 void ClearUserDataRequestL( MCatalogsBaseMessage& aMessage ); |
|
181 |
|
182 /** |
|
183 * This function is called from the proxy side. When the proxy |
|
184 * is deleted. |
|
185 * @param aMessage Contains data from the proxy and can be used |
|
186 * to send data back to proxy |
|
187 */ |
|
188 void ReleaseRequest( MCatalogsBaseMessage& aMessage ) const; |
|
189 |
|
190 |
|
191 private: |
|
192 |
|
193 // Prevent these two if they are not implemented |
|
194 CNcdNodeUserData( const CNcdNodeUserData& aObject ); |
|
195 CNcdNodeUserData& operator =( const CNcdNodeUserData& aObject ); |
|
196 |
|
197 |
|
198 private: // data |
|
199 |
|
200 // The class id identifies this class. The id may be used to identify |
|
201 // what kind of class object is created when data is gotten from the db. |
|
202 NcdNodeClassIds::TNcdNodeClassId iClassId; |
|
203 |
|
204 // The message is set when ReceiveMessage is called. The message |
|
205 // is used in the CounterPartLost-function that informs the message |
|
206 // if the session has been lost. |
|
207 MCatalogsBaseMessage* iMessage; |
|
208 |
|
209 // Identifies to which metadata this user data belongs to. |
|
210 CNcdNodeIdentifier* iIdentifier; |
|
211 |
|
212 // The reference to the node that has this user data. |
|
213 CNcdNodeManager& iManager; |
|
214 |
|
215 // This contains the user data |
|
216 HBufC8* iUserData; |
|
217 |
|
218 }; |
|
219 |
|
220 #endif // NCD_NODE_USER_DATA_H |