|
1 /* |
|
2 * Copyright (c) 2002 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: Concrete implementation of res.file& bitmap changing feature. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CCAOpBrandVariant20.h" |
|
22 #include "CAlternator.h" |
|
23 #include <coemain.h> |
|
24 #include <f32file.h> |
|
25 #include <eikenv.h> |
|
26 #include <CWVSAPSettingsStore.h> |
|
27 #include <CWVSAPSettings.h> |
|
28 |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KChatAppModuleIdForBranding, "IMApp" ); |
|
32 _LIT( KChatEngModuleIdForBranding, "IMEng" ); |
|
33 |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CCAOpBrandVariant20::CCAOpBrandVariant20 |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CCAOpBrandVariant20::CCAOpBrandVariant20() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CCAOpBrandVariant20::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CCAOpBrandVariant20::ConstructL() |
|
53 { |
|
54 iAlternator = CAlternator::InstanceL(); |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CCAOpBrandVariant20::NewL |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CCAOpBrandVariant20* CCAOpBrandVariant20::NewL() |
|
63 { |
|
64 CCAOpBrandVariant20* self = new( ELeave ) CCAOpBrandVariant20; |
|
65 |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop(); |
|
69 |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 // Destructor |
|
75 CCAOpBrandVariant20::~CCAOpBrandVariant20() |
|
76 { |
|
77 iCoeEnv->DeleteResourceFile( iAppResFileOffset ); |
|
78 iCoeEnv->DeleteResourceFile( iEngResFileOffset ); |
|
79 |
|
80 if ( iOrigCommUiResource.Length() > 0 ) // added 31.7.03 by kikangas to support 2.1 release |
|
81 { |
|
82 iCoeEnv->DeleteResourceFile( iCommUiResFileOffset ); |
|
83 } |
|
84 |
|
85 delete iServerName; |
|
86 } |
|
87 |
|
88 void CCAOpBrandVariant20::RemoveAppResourceL( CCoeEnv* aCoeEnv, TInt& aAppResFileOffset ) |
|
89 { |
|
90 aCoeEnv->DeleteResourceFile( aAppResFileOffset ); |
|
91 aAppResFileOffset = NULL; |
|
92 } |
|
93 |
|
94 void CCAOpBrandVariant20::RetrieveSavedSettingsL( CCoeEnv* aCoeEnv, const TDesC& aOrigAppResPath, |
|
95 const TDesC& aOrigEngResPath, |
|
96 const TDesC& aOrigCommUiResPath, |
|
97 TDes& aBitmapPath ) |
|
98 { |
|
99 iCoeEnv = aCoeEnv; |
|
100 |
|
101 // store original paths |
|
102 iOrigAppResource = aOrigAppResPath; |
|
103 iOrigEngResource = aOrigEngResPath; |
|
104 iOrigCommUiResource = aOrigCommUiResPath; |
|
105 iOrigBitmapPath = aBitmapPath; |
|
106 |
|
107 CWVSAPSettingsStore* sapStore = CWVSAPSettingsStore::NewL(); |
|
108 CleanupStack::PushL( sapStore ); |
|
109 |
|
110 // if there are no SAPs then don't try the get default |
|
111 if ( sapStore->SAPCountL() > 0 ) |
|
112 { |
|
113 CWVSAPSettings* sap = CWVSAPSettings::NewLC(); |
|
114 sapStore->GetDefaultL( *sap ); |
|
115 HBufC* server = sap->SAPName().AllocLC(); |
|
116 |
|
117 ActivateBrandL( *server, aBitmapPath ); |
|
118 CleanupStack::PopAndDestroy( 2 ); // server, sap |
|
119 } |
|
120 else |
|
121 { |
|
122 // loads original resource files |
|
123 TBuf<1> empty; |
|
124 ActivateBrandL( empty, aBitmapPath ); |
|
125 } |
|
126 CleanupStack::PopAndDestroy(); // sapStore |
|
127 } |
|
128 |
|
129 void CCAOpBrandVariant20::ActivateBrandL( const TDesC& aServer, TDes& aBitmapPath ) |
|
130 { |
|
131 #ifdef _DEBUG |
|
132 RDebug::Print( _L( "iAlternator->ChangeResourceL" ) ); |
|
133 #endif |
|
134 |
|
135 delete iServerName; |
|
136 iServerName = NULL; |
|
137 iServerName = aServer.AllocL(); |
|
138 |
|
139 // APPLICATION RESOURCE |
|
140 TParsePtrC parseApp( iOrigAppResource ); |
|
141 |
|
142 // if ok, removes the previous resource and adds new one |
|
143 TInt err = iAlternator->ChangeResourceL( KChatAppModuleId, aServer, parseApp.NameAndExt(), iAppResFileOffset ); |
|
144 // if not ok |
|
145 if ( err ) |
|
146 { |
|
147 // delete the old one |
|
148 CEikonEnv::Static()->DeleteResourceFile( iAppResFileOffset ); |
|
149 // load original app resource |
|
150 // Code scanner warning Id 53 "not using |
|
151 // BaflUtils::NearestLanguageFile() when loading a resource file" |
|
152 // is not applicable to this case. |
|
153 iAppResFileOffset = CEikonEnv::Static()->AddResourceFileL( |
|
154 iOrigAppResource ); // CSI: 53 # See above |
|
155 } |
|
156 |
|
157 |
|
158 // ENGINE RESOURCE |
|
159 |
|
160 TParsePtrC parseEng( iOrigEngResource ); |
|
161 |
|
162 // if ok, removes the previous resource and adds new one |
|
163 err = iAlternator->ChangeResourceL( KChatAppModuleId, aServer, parseEng.NameAndExt(), iEngResFileOffset ); |
|
164 // if not ok |
|
165 if ( err ) |
|
166 { |
|
167 // delete the old one |
|
168 CEikonEnv::Static()->DeleteResourceFile( iEngResFileOffset ); |
|
169 // load original eng resource |
|
170 // Code scanner warning Id 53 "not using |
|
171 // BaflUtils::NearestLanguageFile() when loading a resource file" |
|
172 // is not applicable to this case. |
|
173 iEngResFileOffset = CEikonEnv::Static()->AddResourceFileL( |
|
174 iOrigEngResource ); // CSI: 53 # See above |
|
175 } |
|
176 |
|
177 // COMMON UI RESOURCE |
|
178 if ( iOrigCommUiResource.Length() > 0 ) |
|
179 { |
|
180 TParsePtrC parseCUI( iOrigCommUiResource ); |
|
181 |
|
182 // if ok, removes the previous resource and adds new one |
|
183 err = iAlternator->ChangeResourceL( KChatAppModuleId, aServer, parseCUI.NameAndExt(), iCommUiResFileOffset ); |
|
184 // if not ok |
|
185 if ( err ) |
|
186 { |
|
187 // delete the old one |
|
188 CEikonEnv::Static()->DeleteResourceFile( iCommUiResFileOffset ); |
|
189 // load original eng resource |
|
190 // Code scanner warning Id 53 "not using |
|
191 // BaflUtils::NearestLanguageFile() when loading a resource file" |
|
192 // is not applicable to this case. |
|
193 iCommUiResFileOffset = CEikonEnv::Static()->AddResourceFileL( |
|
194 iOrigCommUiResource ); // CSI: 53 # See above |
|
195 } |
|
196 } |
|
197 |
|
198 |
|
199 // BITMAP |
|
200 TParsePtrC parseBitmap( iOrigBitmapPath ); |
|
201 if ( iAlternator->ChangeBitmapFileL( KChatAppModuleId, aServer, parseBitmap.NameAndExt() ) == KErrNone ) |
|
202 { |
|
203 // set branded bitmap |
|
204 aBitmapPath.Zero(); |
|
205 aBitmapPath.Append( iAlternator->CurrentBitmapFile( KChatAppModuleId, aServer, parseBitmap.NameAndExt() ) ); |
|
206 } |
|
207 else |
|
208 { |
|
209 // else set to app defaults!! |
|
210 aBitmapPath.Zero(); |
|
211 aBitmapPath.Append( iOrigBitmapPath ); |
|
212 |
|
213 } |
|
214 } |
|
215 |
|
216 void CCAOpBrandVariant20::DeleteResource( CCoeEnv* aCoeEnv ) |
|
217 { |
|
218 aCoeEnv->DeleteResourceFile( iAppResFileOffset ); |
|
219 } |
|
220 |
|
221 TBool CCAOpBrandVariant20::BrandBitmapsActivated() const |
|
222 { |
|
223 |
|
224 TParsePtrC parseBitmap( iOrigBitmapPath ); |
|
225 TPtrC origFileName( parseBitmap.NameAndExt() ); |
|
226 |
|
227 // returns zero length path if brand bitmap path is not set |
|
228 if ( iAlternator->CurrentBitmapFile( KChatAppModuleId, *iServerName, origFileName ).Length() == 0 ) |
|
229 { |
|
230 return EFalse; |
|
231 } |
|
232 |
|
233 return ETrue; |
|
234 } |
|
235 void CCAOpBrandVariant20::CurrentResourceFileL( const TDesC& /*aServer*/, const TDesC& /*aResourceFile*/, TDes& /*aFullPath*/ ) |
|
236 { |
|
237 } |
|
238 |
|
239 // End of File |