40
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: CSconDataproviderInfo implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "scondataproviderinfo.h"
|
|
20 |
#include <s32strm.h>
|
|
21 |
#include <badesca.h>
|
|
22 |
#include <utf.h> // for CnvUtfConverter
|
|
23 |
#include "debug.h"
|
|
24 |
|
|
25 |
CSconDataproviderInfo::CSconDataproviderInfo()
|
|
26 |
{
|
|
27 |
}
|
|
28 |
|
|
29 |
EXPORT_C CSconDataproviderInfo::~CSconDataproviderInfo()
|
|
30 |
{
|
|
31 |
delete iName;
|
|
32 |
delete iDefaultStore;
|
|
33 |
delete iStores;
|
|
34 |
}
|
|
35 |
|
|
36 |
EXPORT_C CSconDataproviderInfo* CSconDataproviderInfo::NewL()
|
|
37 |
{
|
|
38 |
return new (ELeave) CSconDataproviderInfo();
|
|
39 |
}
|
|
40 |
|
|
41 |
EXPORT_C void CSconDataproviderInfo::ExternalizeL( RWriteStream& aStream ) const
|
|
42 |
{
|
|
43 |
TRACE_FUNC_ENTRY;
|
|
44 |
LOGGER_WRITE_1("iUid: 0x%x", iUid);
|
|
45 |
aStream.WriteInt32L( iUid );
|
|
46 |
if ( iName )
|
|
47 |
{
|
|
48 |
HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iName->Des() );
|
|
49 |
CleanupStack::PushL( temp );
|
|
50 |
TPtrC8 tempPtr = temp->Des();
|
|
51 |
aStream.WriteUint16L( tempPtr.Length() );
|
|
52 |
aStream.WriteL( tempPtr );
|
|
53 |
CleanupStack::PopAndDestroy( temp );
|
|
54 |
}
|
|
55 |
else
|
|
56 |
{
|
|
57 |
aStream.WriteUint16L( 0 );
|
|
58 |
}
|
|
59 |
|
|
60 |
if ( iDefaultStore )
|
|
61 |
{
|
|
62 |
HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iDefaultStore->Des() );
|
|
63 |
CleanupStack::PushL( temp );
|
|
64 |
TPtrC8 tempPtr = temp->Des();
|
|
65 |
aStream.WriteUint16L( tempPtr.Length() );
|
|
66 |
aStream.WriteL( tempPtr );
|
|
67 |
CleanupStack::PopAndDestroy( temp );
|
|
68 |
}
|
|
69 |
else
|
|
70 |
{
|
|
71 |
aStream.WriteUint16L( 0 );
|
|
72 |
}
|
|
73 |
if ( iStores )
|
|
74 |
{
|
|
75 |
aStream.WriteUint16L( iStores->Count() );
|
|
76 |
for ( TInt i=0; i<iStores->Count(); i++ )
|
|
77 |
{
|
|
78 |
TPtrC storePtr = (*iStores)[i];
|
|
79 |
HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( storePtr );
|
|
80 |
CleanupStack::PushL( temp );
|
|
81 |
TPtrC8 tempPtr = temp->Des();
|
|
82 |
aStream.WriteUint16L( tempPtr.Length() );
|
|
83 |
if ( tempPtr.Length() > 0 )
|
|
84 |
{
|
|
85 |
aStream.WriteL( tempPtr );
|
|
86 |
}
|
|
87 |
CleanupStack::PopAndDestroy( temp );
|
|
88 |
}
|
|
89 |
}
|
|
90 |
else
|
|
91 |
{
|
|
92 |
aStream.WriteUint16L( 0 );
|
|
93 |
}
|
|
94 |
aStream.CommitL();
|
|
95 |
TRACE_FUNC_EXIT;
|
|
96 |
}
|
|
97 |
|
|
98 |
EXPORT_C void CSconDataproviderInfo::InternalizeL( RReadStream& aStream )
|
|
99 |
{
|
|
100 |
TRACE_FUNC_ENTRY;
|
|
101 |
delete iName;
|
|
102 |
iName = NULL;
|
|
103 |
delete iDefaultStore;
|
|
104 |
iDefaultStore = NULL;
|
|
105 |
delete iStores;
|
|
106 |
iStores = NULL;
|
|
107 |
iStores = new ( ELeave ) CDesCArrayFlat( 1 );
|
|
108 |
iUid = aStream.ReadInt32L();
|
|
109 |
TInt len = aStream.ReadUint16L();
|
|
110 |
if ( len > 0 )
|
|
111 |
{
|
|
112 |
HBufC8* tempBuf = HBufC8::NewLC( len );
|
|
113 |
TPtr8 tempPtr = tempBuf->Des();
|
|
114 |
aStream.ReadL( tempPtr, len );
|
|
115 |
|
|
116 |
iName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr );
|
|
117 |
CleanupStack::PopAndDestroy( tempBuf );
|
|
118 |
}
|
|
119 |
|
|
120 |
len = aStream.ReadUint16L();
|
|
121 |
if ( len > 0 )
|
|
122 |
{
|
|
123 |
HBufC8* tempBuf = HBufC8::NewLC( len );
|
|
124 |
TPtr8 tempPtr = tempBuf->Des();
|
|
125 |
aStream.ReadL( tempPtr, len );
|
|
126 |
|
|
127 |
iDefaultStore = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr );
|
|
128 |
CleanupStack::PopAndDestroy( tempBuf );
|
|
129 |
}
|
|
130 |
|
|
131 |
TInt storeCount = aStream.ReadUint16L();
|
|
132 |
for (TInt i=0; i<storeCount; i++ )
|
|
133 |
{
|
|
134 |
len = aStream.ReadUint16L();
|
|
135 |
if ( len > 0 )
|
|
136 |
{
|
|
137 |
HBufC8* tempBuf8 = HBufC8::NewLC( len );
|
|
138 |
TPtr8 tempPtr8 = tempBuf8->Des();
|
|
139 |
aStream.ReadL( tempPtr8, len );
|
|
140 |
|
|
141 |
HBufC* temp = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr8 );
|
|
142 |
CleanupStack::PushL( temp );
|
|
143 |
TPtr tempPtr = temp->Des();
|
|
144 |
iStores->AppendL( tempPtr );
|
|
145 |
CleanupStack::PopAndDestroy( temp );
|
|
146 |
CleanupStack::PopAndDestroy( tempBuf8 );
|
|
147 |
}
|
|
148 |
}
|
|
149 |
TRACE_FUNC_EXIT;
|
|
150 |
}
|
|
151 |
|
|
152 |
EXPORT_C TUid CSconDataproviderInfo::ImplementationUid() const
|
|
153 |
{
|
|
154 |
return TUid::Uid( iUid );
|
|
155 |
}
|
|
156 |
|
|
157 |
EXPORT_C void CSconDataproviderInfo::SetImplementationUid( const TUid aUid )
|
|
158 |
{
|
|
159 |
iUid = aUid.iUid;
|
|
160 |
}
|
|
161 |
|
|
162 |
EXPORT_C TDesC& CSconDataproviderInfo::DisplayNameL()
|
|
163 |
{
|
|
164 |
if ( iName )
|
|
165 |
{
|
|
166 |
return *iName;
|
|
167 |
}
|
|
168 |
else
|
|
169 |
{
|
|
170 |
iName = KNullDesC().AllocL();
|
|
171 |
return *iName;
|
|
172 |
}
|
|
173 |
}
|
|
174 |
|
|
175 |
EXPORT_C void CSconDataproviderInfo::SetDisplayNameL( const TDesC& aName )
|
|
176 |
{
|
|
177 |
delete iName;
|
|
178 |
iName = NULL;
|
|
179 |
iName = aName.AllocL();
|
|
180 |
}
|
|
181 |
|
|
182 |
EXPORT_C TDesC& CSconDataproviderInfo::DefaultStoreL()
|
|
183 |
{
|
|
184 |
if ( iDefaultStore )
|
|
185 |
{
|
|
186 |
return *iDefaultStore;
|
|
187 |
}
|
|
188 |
else
|
|
189 |
{
|
|
190 |
iDefaultStore = KNullDesC().AllocL();
|
|
191 |
return *iDefaultStore;
|
|
192 |
}
|
|
193 |
}
|
|
194 |
|
|
195 |
EXPORT_C void CSconDataproviderInfo::SetDefaultStoreL( const TDesC& aStore )
|
|
196 |
{
|
|
197 |
delete iDefaultStore;
|
|
198 |
iDefaultStore = NULL;
|
|
199 |
iDefaultStore = aStore.AllocL();
|
|
200 |
}
|
|
201 |
|
|
202 |
EXPORT_C CDesCArray* CSconDataproviderInfo::ListStoresL() const
|
|
203 |
{
|
|
204 |
if ( !iStores )
|
|
205 |
{
|
|
206 |
User::Leave( KErrNotFound );
|
|
207 |
}
|
|
208 |
return iStores;
|
|
209 |
}
|
|
210 |
|
|
211 |
EXPORT_C void CSconDataproviderInfo::SetStoresL( const CDesCArray& aStores )
|
|
212 |
{
|
|
213 |
delete iStores;
|
|
214 |
iStores = NULL;
|
|
215 |
iStores = new ( ELeave ) CDesCArrayFlat( 1 );
|
|
216 |
for ( TInt i=0; i<aStores.Count(); i++ )
|
|
217 |
{
|
|
218 |
iStores->AppendL( aStores[i] );
|
|
219 |
}
|
|
220 |
}
|