|
1 /* |
|
2 * Copyright (c) 2009-2010 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: |
|
15 * Cache side object representing a destination. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CMMDESTINATIONSTRUCT_H_ |
|
21 #define CMMDESTINATIONSTRUCT_H_ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <commsdattypesv1_1.h> |
|
25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
26 #include <commsdattypesv1_1_partner.h> |
|
27 #include <commsdattypesv1_1_internal.h> |
|
28 #include <commsdattypeinfov1_1_internal.h> |
|
29 #endif |
|
30 |
|
31 #include "cmmserverdefs.h" |
|
32 |
|
33 class CCmmTransactionHandler; |
|
34 class CCmmDestinationInstance; |
|
35 class CCmmCache; |
|
36 class CCDSNAPMetadataRecord; |
|
37 |
|
38 |
|
39 /** |
|
40 * Cache side object representing a destination. Reflects the current state in |
|
41 * database. |
|
42 */ |
|
43 NONSHARABLE_CLASS( CCmmDestinationStruct ) : public CBase |
|
44 { |
|
45 public: |
|
46 static CCmmDestinationStruct* NewL( |
|
47 CCmmCache* aCache, |
|
48 CCmmTransactionHandler* aTransactionHandler, |
|
49 const TUint32 aId ); |
|
50 static CCmmDestinationStruct* NewL( |
|
51 CCmmCache* aCache, |
|
52 CCmmTransactionHandler* aTransactionHandler, |
|
53 const TDesC& aName, |
|
54 const TUint32 aId ); |
|
55 |
|
56 static CCmmDestinationStruct* NewLC( |
|
57 CCmmCache* aCache, |
|
58 CCmmTransactionHandler* aTransactionHandler, |
|
59 const TUint32 aId ); |
|
60 static CCmmDestinationStruct* NewLC( |
|
61 CCmmCache* aCache, |
|
62 CCmmTransactionHandler* aTransactionHandler, |
|
63 const TDesC& aName, |
|
64 const TUint32 aId ); |
|
65 |
|
66 virtual ~CCmmDestinationStruct(); |
|
67 |
|
68 private: |
|
69 CCmmDestinationStruct( CCmmCache* aCache, CCmmTransactionHandler* aTransactionHandler ); |
|
70 |
|
71 // Opens an existing destination, based on ID. |
|
72 void ConstructL( const TUint32 aDestinationId ); |
|
73 |
|
74 // Creates a new destination. With name and optionally also with ID. |
|
75 void ConstructL( const TDesC& aName, const TUint32 aId ); |
|
76 |
|
77 public: |
|
78 void SetId( const TUint32 aId ); |
|
79 TUint32 GetId() const; |
|
80 |
|
81 /** |
|
82 * Get the destination ID from network record. To get a valid ID, this must |
|
83 * be called only during or after a call to UpdateL(). |
|
84 */ |
|
85 TUint32 GetRealId() const; |
|
86 TDesC& GetDestinationNameL(); |
|
87 |
|
88 /** |
|
89 * Gets the current status of this destination struct. |
|
90 */ |
|
91 TCmmDestinationStatus GetStatus() const; |
|
92 TInt GetReferenceCount() const; |
|
93 |
|
94 /** |
|
95 * Sets a new status value. |
|
96 */ |
|
97 void SetStatus( const TCmmDestinationStatus& aStatus ); |
|
98 |
|
99 /** |
|
100 * Notify about a possible change in database on specified record table. |
|
101 */ |
|
102 void NotifyRecordChange( const TCmmDbRecords aRecordType ); |
|
103 |
|
104 /** |
|
105 * Set the record status for all records. |
|
106 */ |
|
107 void SetStatusForAllRecords( const TCmmRecordStatus aStatus ); |
|
108 |
|
109 /** |
|
110 * Copies the data for this destination to a session instance and |
|
111 * increments the reference counter by one. |
|
112 */ |
|
113 void CreateDestinationInstanceL( |
|
114 CCmmDestinationInstance& aDestinationInstance ); |
|
115 |
|
116 /** |
|
117 * Refresh the data contained in aDestinationInstance. This means reloading |
|
118 * the data from database if necessary. After this call the contents of |
|
119 * aDestinationInstance will reflect the current state in the database. |
|
120 */ |
|
121 void RefreshDestinationInstanceL( |
|
122 CCmmDestinationInstance& aDestinationInstance ); |
|
123 |
|
124 /** |
|
125 * Reloads a destination record if needed and copies the latest version to |
|
126 * the session instance given as parameter. |
|
127 */ |
|
128 void LoadRecordL( |
|
129 CCmmDestinationInstance& aDestinationInstance, |
|
130 TCmmDbRecords aRecordType ); |
|
131 |
|
132 /** |
|
133 * Save the contents of a session side destination handle into database. |
|
134 */ |
|
135 void UpdateL( |
|
136 CCmmDestinationInstance& aDestinationInstance, |
|
137 CCmmCache* aCache ); |
|
138 |
|
139 /** |
|
140 * Delete all database records of this destination. Also removes any |
|
141 * records making this destination an embedded destination in another |
|
142 * destination. |
|
143 */ |
|
144 void DeleteL(); |
|
145 |
|
146 /** |
|
147 * |
|
148 * This should be called when a client session closes a destination handle. |
|
149 * Reference counter is decremented by one and the remaining number of |
|
150 * references is returned. |
|
151 */ |
|
152 TInt DestinationInstanceClosed(); |
|
153 |
|
154 /** |
|
155 * Called after this destination has been updated and database transaction |
|
156 * has completed successfully. Sets the internal state of this destination |
|
157 * structure to reflect the new valid state. |
|
158 */ |
|
159 void UpdateSuccessful(); |
|
160 |
|
161 private: |
|
162 void InitializeDestApRecordL(); |
|
163 void SetDefaultTierManagerL(); |
|
164 void SetDefaultMCprL(); |
|
165 void SetDefaultCprL(); |
|
166 void SetDefaultSCprL(); |
|
167 void SetDefaultProtocolL(); |
|
168 |
|
169 /** |
|
170 * Set attribute flag on the given record. |
|
171 * @param aRecord Record to be set. |
|
172 * @param aAttribute Attribute to be set. |
|
173 * @param aSet ETrue to set, EFalse to clear. |
|
174 */ |
|
175 void SetAttribute( CommsDat::CCDRecordBase* aRecord, TUint32 aAttribute, TBool aSet ); |
|
176 |
|
177 CommsDat::CCDRecordBase* CopyRecordL( |
|
178 TCmmDbRecords aRecordType, |
|
179 CommsDat::CCDRecordBase* aSource ); |
|
180 |
|
181 private: |
|
182 // Database cache. |
|
183 CCmmCache* iCache; // Not owned. |
|
184 |
|
185 // The transaction handler. |
|
186 CCmmTransactionHandler* iTransactionHandler; // Not owned. |
|
187 |
|
188 // The access point record. |
|
189 CommsDat::CCDAccessPointRecord* iDestApRecord; // Owned. |
|
190 // The network record. |
|
191 CommsDat::CCDNetworkRecord* iNetworkRecord; // Owned. |
|
192 // The metadata record. |
|
193 CCDSNAPMetadataRecord* iMetadataRecord; // Owned. |
|
194 |
|
195 // Record status variables. |
|
196 TCmmRecordStatus iDestApRecordStatus; |
|
197 TCmmRecordStatus iNetworkRecordStatus; |
|
198 TCmmRecordStatus iMetadataRecordStatus; |
|
199 |
|
200 // Counts number of session side objects referring to this destination. |
|
201 TInt iReferenceCounter; |
|
202 |
|
203 // Destination status. |
|
204 TCmmDestinationStatus iStatus; |
|
205 |
|
206 // Destination ID. If real ID is not available, contains a temporary ID. |
|
207 TUint32 iId; |
|
208 |
|
209 // Destination name for newly created destination. |
|
210 // Only valid until destination is saved to database (status is ECmmDestinationStatusNotSaved). |
|
211 HBufC* iName; // Owned. |
|
212 }; |
|
213 |
|
214 #endif // CMMDESTINATIONSTRUCT_H_ |
|
215 |
|
216 // End of file |