1 /* |
|
2 * Copyright (c) 2007 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: Registration information for a Location based Application. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 #include <bautils.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 // USER INCLUDES |
|
25 #include "lcregappinfo.h" |
|
26 #include "lcregappnamelangid.h" |
|
27 // CONST DEFINATION |
|
28 |
|
29 |
|
30 // CLASS DEFINATION |
|
31 /** |
|
32 * Maximum length of a service name can be |
|
33 */ |
|
34 const TInt KAppNameMaxLength = 50; |
|
35 |
|
36 // ----- Member funtions for CLcRegAppInfo --------------------------------- |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CLcRegAppInfo::CLcRegAppInfo |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CLcRegAppInfo::CLcRegAppInfo( ) |
|
43 { |
|
44 // C++ Default constructor. No allocations or functions which can Leave |
|
45 // should be called from here.Initiallize all the variable here |
|
46 iFilePresenceStatus = ETrue; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CLcRegAppInfo::~CLcRegAppInfo |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CLcRegAppInfo::~CLcRegAppInfo() |
|
54 { |
|
55 // C++ Destructor. Free all resources associated with this class. |
|
56 iAppNameArray.ResetAndDestroy(); |
|
57 iAppNameArray.Close(); |
|
58 iAppLangArray.Reset(); |
|
59 iAppLangArray.Close(); |
|
60 iFileName.Delete( 0,iFileName.Length() ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CLcRegAppInfo* CLcRegAppInfo::NewL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CLcRegAppInfo* CLcRegAppInfo::NewL() |
|
68 { |
|
69 CLcRegAppInfo* self = new ( ELeave )CLcRegAppInfo(); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // void CLcRegAppInfo::SetAppNameL |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CLcRegAppInfo::SetAppNameL( const TDesC& aName ) |
|
78 { |
|
79 HBufC* nameBuf = NULL; |
|
80 if( aName.Length() > KAppNameMaxLength ) |
|
81 { |
|
82 nameBuf = HBufC::NewL( KAppNameMaxLength ); |
|
83 nameBuf->Des().Copy( aName.Left( KAppNameMaxLength )); |
|
84 } |
|
85 else |
|
86 { |
|
87 nameBuf = HBufC::NewL( aName.Length() ); |
|
88 nameBuf->Des().Copy( aName ); |
|
89 } |
|
90 User::LeaveIfError( iAppNameArray.Append( nameBuf ) ); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // TInt CLcRegAppInfo::SetNameLanguage |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CLcRegAppInfo::SetNameLanguage( const TDesC& aNameLang ) |
|
98 { |
|
99 for (TInt i=0; i< NUMLANGOPTIONS; i++) |
|
100 { |
|
101 if ( !KLangOptions[i].iName.Compare( aNameLang ) ) |
|
102 { |
|
103 return iAppLangArray.Append( ( TUint32 )KLangOptions[i].iNumber ); |
|
104 } |
|
105 } |
|
106 return KErrNotFound; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // void CLcRegAppInfo::SetAppLangSpecificNameL |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CLcRegAppInfo::SetAppLangSpecificNameL( RFs& aFs ) |
|
114 { |
|
115 TLanguage langcode = User::Language(); //current language |
|
116 TInt index = iAppLangArray.Find( ( TUint32 )langcode ); |
|
117 if( index != KErrNotFound ) |
|
118 { |
|
119 if( index < iAppNameArray.Count() ) |
|
120 { |
|
121 SetNameL( *iAppNameArray[index] ); |
|
122 } |
|
123 } |
|
124 else |
|
125 { |
|
126 RArray<TLanguage> langs; |
|
127 CleanupClosePushL( langs ); |
|
128 BaflUtils::GetDowngradePathL( aFs,langcode,langs ); |
|
129 for(TInt i = 0; i < iAppLangArray.Count(); ++i) |
|
130 { |
|
131 index = langs.Find( ( TLanguage )iAppLangArray[i] ); |
|
132 if( index != KErrNotFound ) |
|
133 { |
|
134 break; |
|
135 } |
|
136 } |
|
137 if( index == KErrNotFound ) |
|
138 { |
|
139 index = langs.Count() - 1; |
|
140 } |
|
141 if( index >= 0 && index < iAppNameArray.Count() ) |
|
142 { |
|
143 SetNameL( *iAppNameArray[index] ); |
|
144 } |
|
145 CleanupStack::PopAndDestroy( &langs ); |
|
146 } |
|
147 iAppNameArray.ResetAndDestroy(); |
|
148 iAppNameArray.Close(); |
|
149 iAppLangArray.Reset(); |
|
150 iAppLangArray.Close(); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // void CLcRegAppInfo::SetFileNameL |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CLcRegAppInfo::SetFileNameL( const TDesC& aFile ) |
|
158 { |
|
159 if( aFile.Length() <= KMaxFileName ) |
|
160 { |
|
161 iFileName.Copy( aFile ); |
|
162 } |
|
163 else |
|
164 { |
|
165 User::Leave( KErrBadName ); |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // TFileName CLcRegAppInfo::FileName |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 TFileName CLcRegAppInfo::FileName() |
|
174 { |
|
175 return iFileName; |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // void CLcRegAppInfo::IsAppPresent |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 TBool CLcRegAppInfo::IsAppPresent( ) |
|
183 { |
|
184 return iFilePresenceStatus; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // void CLcRegAppInfo::SetFilePresenceStatus |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CLcRegAppInfo::SetFilePresenceStatus( TBool aPresenceStatus ) |
|
192 { |
|
193 iFilePresenceStatus = aPresenceStatus; |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // void CLcRegAppInfo::SetMmcId |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void CLcRegAppInfo::SetMmcId( TUint aUid ) |
|
201 { |
|
202 iMmcId = aUid; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // TFileName CLcRegAppInfo::MmcId |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 TUint CLcRegAppInfo::MmcId() |
|
210 { |
|
211 return iMmcId; |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // void CLcRegAppInfo::SetArrayIndex |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CLcRegAppInfo::SetArrayIndex( TInt aIndex ) |
|
219 { |
|
220 iIndex = aIndex; |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // TFileName CLcRegAppInfo::Index |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CLcRegAppInfo::Index() |
|
228 { |
|
229 return iIndex; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // TBool CLcRegAppInfo::IsAppNamePresent |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 TBool CLcRegAppInfo::IsAppNamePresent() |
|
237 { |
|
238 if( iAppNameArray.Count() == 0 && |
|
239 iAppLangArray.Count() == 0 ) |
|
240 { |
|
241 return EFalse; |
|
242 } |
|
243 return ETrue; |
|
244 } |
|
245 //End of file |
|