|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // CStoreableOverrideSettings class definitions |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @deprecated since v9.1. Functionality is replaced with commsdat. |
|
21 */ |
|
22 |
|
23 #include <cdbstore.h> |
|
24 #include "OVERRIDE.H" |
|
25 |
|
26 namespace commdb_dll |
|
27 { |
|
28 /** |
|
29 Maximum size of the store |
|
30 @internalComponent |
|
31 */ |
|
32 const TInt KStoreExpandSize=100; |
|
33 } |
|
34 using namespace commdb_dll; |
|
35 |
|
36 |
|
37 EXPORT_C CStoreableOverrideSettings* CStoreableOverrideSettings::NewL(TParamList aParamList) |
|
38 /** Allocates and constructs a storable override settings object. |
|
39 |
|
40 The construction process automatically opens the communications database and |
|
41 connects to the DBMS. The database is closed and the connection to the DBMS |
|
42 severed when this override object is destroyed |
|
43 |
|
44 This member function was withdrawn in release 6.0, but re-introduced in 7.0 |
|
45 |
|
46 @param aParamList An enumerator which indicates whether the override settings |
|
47 are partial or full. |
|
48 @return A pointer to the override settings object. */ |
|
49 { |
|
50 CStoreableOverrideSettings* r=new(ELeave) CStoreableOverrideSettings(aParamList); |
|
51 CleanupStack::PushL(r); |
|
52 r->ConstructL(); |
|
53 CleanupStack::Pop(r); |
|
54 return r; |
|
55 } |
|
56 |
|
57 EXPORT_C CStoreableOverrideSettings* CStoreableOverrideSettings::NewL(TParamList aParamList, TCommDbDatabaseType /*aDbType*/) |
|
58 /** Allocates and constructs a storable override settings object. |
|
59 |
|
60 The construction process automatically opens the communications database and |
|
61 connects to the DBMS. The database is closed and the connection to the DBMS |
|
62 severed when this override object is destroyed |
|
63 |
|
64 Re-instated override variant of NewL function in order to maintain BC with 6.1. |
|
65 Disgards a TCommDbDatabaseType value and calls NewL(TParamList aParamList). |
|
66 |
|
67 @param aParamList |
|
68 @param aDbType Whether Database is IAP or ISP version. All Db's are IAP type now. |
|
69 @return CCommDbOverrideSettings* the calling function takes ownership of the returned object/ |
|
70 */ |
|
71 { |
|
72 return CStoreableOverrideSettings::NewL(aParamList); |
|
73 } |
|
74 |
|
75 CStoreableOverrideSettings::CStoreableOverrideSettings(TParamList aParamList) |
|
76 : CCommDbOverrideSettings(aParamList) |
|
77 /** Constructor |
|
78 @internalAll */ |
|
79 {} |
|
80 |
|
81 void CStoreableOverrideSettings::ConstructL() |
|
82 { |
|
83 iStore=CBufStore::NewL(KStoreExpandSize); |
|
84 CCommDbOverrideSettings::ConstructL(); |
|
85 } |
|
86 |
|
87 EXPORT_C CStoreableOverrideSettings::~CStoreableOverrideSettings() |
|
88 /** Frees all resources owned by this object, prior to its destruction. |
|
89 |
|
90 Specifically, it deletes the memory store. */ |
|
91 { |
|
92 delete iStore; |
|
93 } |
|
94 |
|
95 EXPORT_C void CStoreableOverrideSettings::ExternalizeL(RWriteStream& aStream) const |
|
96 /** Externalises override settings to a stream. |
|
97 |
|
98 @param aStream The stream to write to. */ |
|
99 { |
|
100 TInt i; |
|
101 TInt count; |
|
102 |
|
103 count = iOverrides.Count(); |
|
104 aStream.WriteUint32L(count); |
|
105 for (i=0; i<count; i++) |
|
106 { |
|
107 iOverrides[i]->ExternalizeL(aStream); |
|
108 } |
|
109 count = iIapOverrides.Count(); |
|
110 aStream.WriteUint32L(count); |
|
111 for (i=0; i<count; i++) |
|
112 { |
|
113 iIapOverrides[i].ExternalizeL(aStream); |
|
114 } |
|
115 } |
|
116 |
|
117 EXPORT_C void CStoreableOverrideSettings::InternalizeL(RReadStream& aStream) |
|
118 /** Internalises the override settings from a stream. |
|
119 |
|
120 @param aStream The stream to read from. */ |
|
121 { |
|
122 TInt count; |
|
123 TInt i; |
|
124 |
|
125 count=aStream.ReadUint32L(); |
|
126 for (i=0; i < count; i++) |
|
127 { |
|
128 CCommDbOverride pattern(EUnknownType); |
|
129 pattern.InternalizeL(aStream); |
|
130 CCommDbOverride* override = 0; |
|
131 switch (pattern.iType) |
|
132 { |
|
133 case EIntValue: |
|
134 override = new (ELeave) CCommDbIntOverride(pattern.iTableName, |
|
135 pattern.iColumnName); |
|
136 break; |
|
137 case EBoolValue: |
|
138 override = new (ELeave) CCommDbBoolOverride(pattern.iTableName, |
|
139 pattern.iColumnName); |
|
140 break; |
|
141 case EDes8Value: |
|
142 override = new (ELeave) CCommDbDes8Override(pattern.iTableName, |
|
143 pattern.iColumnName); |
|
144 break; |
|
145 case EDes16Value: |
|
146 override = new (ELeave) CCommDbDes16Override(pattern.iTableName, |
|
147 pattern.iColumnName); |
|
148 break; |
|
149 case ELongDesValue: |
|
150 override = CCommDbLongDesOverride::NewL(pattern.iTableName, |
|
151 pattern.iColumnName); |
|
152 break; |
|
153 default: |
|
154 User::Leave(KErrArgument); |
|
155 break; |
|
156 } |
|
157 CleanupStack::PushL(override); |
|
158 override->InternalizeL(aStream); |
|
159 User::LeaveIfError(iOverrides.Append(override)); |
|
160 CleanupStack::Pop(); // override |
|
161 } |
|
162 count=aStream.ReadUint32L(); |
|
163 for (i=0; i < count; i++) |
|
164 { |
|
165 TCommDbIapConnectionPrefOverride override; |
|
166 override.InternalizeL(aStream); |
|
167 User::LeaveIfError(iIapOverrides.Append(override)); |
|
168 } |
|
169 } |
|
170 |
|
171 EXPORT_C CBufFlat* CStoreableOverrideSettings::StoreLC() |
|
172 /** Constructs a flat buffer and stores the override settings in it. |
|
173 |
|
174 The function returns a pointer to the buffer; the pointer to this object is |
|
175 placed on the cleanup stack. |
|
176 |
|
177 @return A pointer to a flat buffer in which this object is stored. */ |
|
178 { |
|
179 CBufFlat* buf=CBufFlat::NewL(256); // expand size = 256 |
|
180 CleanupStack::PushL(buf); |
|
181 RBufWriteStream strm(*buf); |
|
182 strm << *this; |
|
183 strm.CommitL(); |
|
184 return buf; |
|
185 } |
|
186 |
|
187 EXPORT_C void CStoreableOverrideSettings::RestoreL(HBufC8* aBuf) |
|
188 /** Restores the override settings from the buffer memory store hosted by the specified |
|
189 8-bit descriptor. |
|
190 |
|
191 @param aBuf A pointer to an 8 bit memory descriptor containing the data to |
|
192 be restored. */ |
|
193 { |
|
194 RDesReadStream strm(*aBuf); // turn it into a stream |
|
195 strm >> *this; // re-construct arrays |
|
196 } |