|
1 /* |
|
2 * Copyright (c) 2004-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: Class defining a specific skin within Psln. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknsSkinUID.h> |
|
20 |
|
21 #include "PslnSkinNameEntry.h" |
|
22 #include "PslnConst.h" |
|
23 #include "PslnDebug.h" |
|
24 |
|
25 #ifdef RD_MULTIPLE_DRIVE |
|
26 #include <driveinfo.h> |
|
27 #endif //RD_MULTIPLE_DRIVE |
|
28 |
|
29 // Compares Unicode values based on the value itself AND character identity |
|
30 // AND accent AND case. |
|
31 const TInt KPslnCollationLvl3 = 3; |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // Two-phased constructor. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CPslnSkinNameEntry* CPslnSkinNameEntry::NewL() |
|
40 { |
|
41 CPslnSkinNameEntry* self = new( ELeave ) CPslnSkinNameEntry; |
|
42 CleanupStack::PushL( self ); |
|
43 self->BaseConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // Destructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CPslnSkinNameEntry::~CPslnSkinNameEntry() |
|
53 { |
|
54 delete iName; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CPslnSkinNameEntry::GetName |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CPslnSkinNameEntry::GetName( TDes& aDst ) const |
|
62 { |
|
63 CopyHonoringSize( aDst, iName ); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CPslnSkinNameEntry::SetNameL |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CPslnSkinNameEntry::SetNameL( const TDesC& aName ) |
|
71 { |
|
72 HBufC* name = aName.AllocL(); |
|
73 delete iName; |
|
74 iName = name; |
|
75 name = NULL; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CPslnSkinNameEntry::Location |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 TAknSkinSrvSkinPackageLocation CPslnSkinNameEntry::Location() const |
|
83 { |
|
84 return iLocation; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CPslnSkinNameEntry::SetLocation |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CPslnSkinNameEntry::SetLocation( |
|
92 const TAknSkinSrvSkinPackageLocation aLocation ) |
|
93 { |
|
94 iLocation = aLocation; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CPslnSkinNameEntry::PkgID |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 TAknsPkgID CPslnSkinNameEntry::PkgID() const |
|
102 { |
|
103 return iPID; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CPslnSkinNameEntry::SetPkgID |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CPslnSkinNameEntry::SetPkgID( const TAknsPkgID& aPID ) |
|
111 { |
|
112 iPID = aPID; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CPslnSkinNameEntry::LinearOrder |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 TInt CPslnSkinNameEntry::LinearOrder( |
|
120 const CPslnSkinNameEntry& aFirst, |
|
121 const CPslnSkinNameEntry& aSecond ) |
|
122 { |
|
123 // Default system skin is always less than anything else |
|
124 if( aFirst.iPID != aSecond.iPID ) |
|
125 { |
|
126 if( aFirst.iPID == KAknsPIDProductDefaultSkin ) |
|
127 { |
|
128 return -1; |
|
129 } |
|
130 if( aSecond.iPID == KAknsPIDProductDefaultSkin ) |
|
131 { |
|
132 return 1; |
|
133 } |
|
134 } |
|
135 |
|
136 // If there are empty names, they are less than something else |
|
137 if( !aFirst.iName && aSecond.iName ) |
|
138 { |
|
139 return -1; |
|
140 } |
|
141 if( aFirst.iName && !aSecond.iName ) |
|
142 { |
|
143 return 1; |
|
144 } |
|
145 if( !aFirst.iName && !aSecond.iName ) |
|
146 { |
|
147 return 0; |
|
148 } |
|
149 |
|
150 // Otherwise, compare names (they are NULL-checked at this point) |
|
151 PSLN_TRACE_DEBUG2("CPslnSkinNameEntry: Comparing \"%S\" and \"%S\"", |
|
152 aFirst.iName, aSecond.iName ); |
|
153 return aFirst.iName->CompareC( *aSecond.iName, KPslnCollationLvl3, NULL ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CPslnSkinNameEntry::LocationFromPath |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 TAknSkinSrvSkinPackageLocation CPslnSkinNameEntry::LocationFromPath( |
|
161 const TDesC& aPath ) |
|
162 { |
|
163 #ifndef RD_MULTIPLE_DRIVE |
|
164 TBuf<1> driveLetterBuf; |
|
165 driveLetterBuf.CopyUC( aPath.Left(1) ); |
|
166 if( driveLetterBuf.Compare( KPslnMMCDriveLetter ) == 0 ) |
|
167 { |
|
168 return EAknsSrvMMC; |
|
169 } |
|
170 return EAknsSrvPhone; |
|
171 #else |
|
172 RFs fs; |
|
173 if ( KErrNone != fs.Connect() ) |
|
174 { |
|
175 // not sure the default value if failed |
|
176 return EAknsSrvPhone; |
|
177 } |
|
178 |
|
179 TInt drive = EDriveC; |
|
180 TUint driveStatus = 0; |
|
181 TAknSkinSrvSkinPackageLocation skinLoc = EAknsSrvPhone; |
|
182 TInt err = RFs::CharToDrive( aPath[0], drive ); |
|
183 err = DriveInfo::GetDriveStatus( fs, drive, driveStatus ); |
|
184 if ( driveStatus & DriveInfo::EDriveExternallyMountable ) |
|
185 { |
|
186 skinLoc = EAknsSrvMMC; |
|
187 } |
|
188 |
|
189 fs.Close(); |
|
190 return skinLoc; |
|
191 #endif // RD_MULTIPLE_DRIVE |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CPslnSkinNameEntry::CopyHonoringSize |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CPslnSkinNameEntry::CopyHonoringSize( TDes& aDst, const TDesC* aSrc ) |
|
199 { |
|
200 if( aSrc ) |
|
201 { |
|
202 CopyHonoringSize( aDst, *aSrc ); |
|
203 } |
|
204 else |
|
205 { |
|
206 aDst.Zero(); |
|
207 } |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CPslnSkinNameEntry::CopyHonoringSize |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CPslnSkinNameEntry::CopyHonoringSize( TDes& aDst, const TDesC& aSrc ) |
|
215 { |
|
216 aDst.Copy( aSrc.Left( aDst.MaxLength() ) ); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // Symbian 2nd phase constructor can leave. |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CPslnSkinNameEntry::BaseConstructL( CAknsSrvSkinInformationPkg* aInfo ) |
|
224 { |
|
225 if ( aInfo ) |
|
226 { |
|
227 SetLocation( LocationFromPath( aInfo->IniFileDirectory() ) ); |
|
228 SetPkgID( aInfo->PID() ); |
|
229 SetNameL( aInfo->Name() ); |
|
230 } |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // C++ constructor can NOT contain any code, that might leave. |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 CPslnSkinNameEntry::CPslnSkinNameEntry() |
|
238 : iLocation( EAknsSrvPhone ), iPID( KAknsNullPkgID ) |
|
239 { |
|
240 } |
|
241 |
|
242 // End of File. |
|
243 |
|
244 |