|
1 /* |
|
2 * Copyright (c) 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: Location Triggering Management Plugin View's container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Include |
|
20 #include <aknViewAppUi.h> |
|
21 #include <StringLoader.h> // For String Loader |
|
22 #include <lbtmgmtpluginview.rsg> |
|
23 #include <barsread.h> // For TResourceReader |
|
24 #include <bautils.h> |
|
25 |
|
26 // User Includes |
|
27 #include "locsettingsuiobserver.h" |
|
28 #include "locsettingsuiparams.h" |
|
29 #include "lbtmgmtplugin.h" |
|
30 #include "lbtmgmtpluginview.h" |
|
31 |
|
32 // Constant Definition |
|
33 /** |
|
34 * Position of Triggering Management plug-in the Postioning View. |
|
35 * As defined by the Location System UI UI specification, the Location |
|
36 * Triggering Management plug-in should be inserted at the Third level |
|
37 */ |
|
38 const TInt KLbtMgmtPluginPriority = 0x00000003; |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CLbtMgmtPlugin::CLbtMgmtPlugin |
|
42 // C++ default constructor. |
|
43 // --------------------------------------------------------------------------- |
|
44 CLbtMgmtPlugin::CLbtMgmtPlugin( MLocSettingsUiObserver& aSettingsUiObserver, |
|
45 CAknViewAppUi& aAppUi ) |
|
46 :CLocSettingsUi( aSettingsUiObserver, aAppUi ), |
|
47 iResourceLoader( *CCoeEnv::Static() ) |
|
48 { |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CLbtMgmtPlugin::~CLbtMgmtPlugin |
|
53 // Destructor. |
|
54 // --------------------------------------------------------------------------- |
|
55 CLbtMgmtPlugin::~CLbtMgmtPlugin() |
|
56 { |
|
57 iResourceLoader.Close(); |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CLbtMgmtPlugin* CLbtMgmtPlugin::NewL |
|
62 // Symbian OS two-phased constructor |
|
63 // |
|
64 // @return CLbtMgmtPlugin* Reference to the Settings UI object |
|
65 // --------------------------------------------------------------------------- |
|
66 CLbtMgmtPlugin* CLbtMgmtPlugin::NewL( TAny* aParam ) |
|
67 { |
|
68 CLocSettingsUiParams* param = reinterpret_cast<CLocSettingsUiParams *>( aParam ); |
|
69 MLocSettingsUiObserver& observer = param->SettingsUiObserver(); |
|
70 CAknViewAppUi& appUi = param->AppUi(); |
|
71 CLbtMgmtPlugin* self = new (ELeave )CLbtMgmtPlugin( observer, |
|
72 appUi ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop( self ); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // void CLbtMgmtPlugin::ConstructL |
|
81 // Second phase constructor. |
|
82 // --------------------------------------------------------------------------- |
|
83 void CLbtMgmtPlugin::ConstructL() |
|
84 { |
|
85 // Open the Resource file for the plugin. The resource file is not |
|
86 // explicity opened by system. Hence, the opening and closind if tied |
|
87 // down to the time when the DLL is active |
|
88 OpenLocalizedResourceFileL( KLbtMgmtUiResFileName, |
|
89 iResourceLoader ); |
|
90 |
|
91 // Creating an Application view |
|
92 iView = CLbtMgmtPluginView::NewL( iSettingsUiObserver ); |
|
93 |
|
94 // Transferring the view's control to AppUi |
|
95 iAppUi.AddViewL( iView ); |
|
96 |
|
97 // Obtaining the View Id for reference |
|
98 iViewId = iView->Id(); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // void CLbtMgmtPlugin::LaunchL |
|
103 // Inherited from CSettingsUi |
|
104 // Launches the Settings UI |
|
105 // |
|
106 // @param aUiLaunchParams Flags for Launch options |
|
107 // --------------------------------------------------------------------------- |
|
108 void CLbtMgmtPlugin::LaunchL( TInt /* aUiLaunchParams */) |
|
109 { |
|
110 // Activate self |
|
111 iAppUi.ActivateLocalViewL( iViewId ); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // void CLbtMgmtPlugin::Close |
|
116 // Inherited from CSettingsUi |
|
117 // Closes the running Settings UI |
|
118 // --------------------------------------------------------------------------- |
|
119 void CLbtMgmtPlugin::Close() |
|
120 { |
|
121 iView->CloseSettings(); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // void CLbtMgmtPlugin::GetCaptionL |
|
126 // Inherited from CSettingsUi |
|
127 // Method for getting caption of this plugin. This should be the |
|
128 // localized name of the settings view to be shown in parent view. |
|
129 // |
|
130 // @param aCaption pointer to Caption variable |
|
131 // --------------------------------------------------------------------------- |
|
132 void CLbtMgmtPlugin::GetCaptionL( TDes& aCaption ) const |
|
133 { |
|
134 // Load the Location Triggering setting caption from the resource file |
|
135 // and hand it back to the callee. It is assuemed here that the calling function has |
|
136 // allocated enough memory for the aCaption string. If not the fucntion |
|
137 // would leave |
|
138 HBufC* caption = StringLoader::LoadL( R_LOCTR_TITLE_TEXT_LT ); |
|
139 |
|
140 if( aCaption.MaxLength() < caption->Length()) |
|
141 { |
|
142 User::Leave( KErrNoMemory ); |
|
143 } |
|
144 aCaption.Copy( *caption ); |
|
145 delete caption; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // TInt CLbtMgmtPlugin::GetPriority |
|
150 // Inherited from CSettingsUi |
|
151 // Returns the priority of the UI module. |
|
152 // |
|
153 // @return Priority of the Settings UI |
|
154 // --------------------------------------------------------------------------- |
|
155 TInt CLbtMgmtPlugin::GetPriority() |
|
156 { |
|
157 return KLbtMgmtPluginPriority; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // void CLbtMgmtPlugin::OpenLocalizedResourceFileL |
|
162 // Opens the nearest localized resourcefile using aResourceLoader. |
|
163 // aResourceLoader should be opened only once before closing it. |
|
164 // Otherwise it will raise a panic. Therefore it is better to have |
|
165 // multiple resource loaders. |
|
166 // |
|
167 // @param aResourceFileName Drive and name of resource file in format |
|
168 // <path>:<rsc_file_name> |
|
169 // @param aResourceLoader Resource loader for the resource. The loader |
|
170 // must not be opened allready or it will raise |
|
171 // a panic. It is caller's responsibility to |
|
172 // close the resource loader after using the |
|
173 // resource. |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CLbtMgmtPlugin::OpenLocalizedResourceFileL( |
|
177 const TDesC& aResourceFileName, |
|
178 RConeResourceLoader& aResourceLoader ) |
|
179 { |
|
180 RFs fsSession; |
|
181 User::LeaveIfError( fsSession.Connect()); |
|
182 |
|
183 // Add the RFs session to the CleanupStack |
|
184 CleanupClosePushL( fsSession ); |
|
185 |
|
186 TFileName* tmpName = new( ELeave ) TFileName; |
|
187 CleanupStack::PushL( tmpName ); |
|
188 |
|
189 // Append the Resource Files Directory |
|
190 tmpName->Append( KDC_RESOURCE_FILES_DIR ); |
|
191 |
|
192 // Append the Ressource File Name |
|
193 tmpName->Append( aResourceFileName ); |
|
194 |
|
195 |
|
196 // Obtain the drive where the DLL is installed |
|
197 TFileName* dllDrive = new ( ELeave ) TFileName; |
|
198 CleanupStack::PushL( dllDrive ); |
|
199 Dll::FileName( *dllDrive ); |
|
200 |
|
201 // Obtain the Complete path for the Resource File |
|
202 TParse parse; |
|
203 User::LeaveIfError( parse.Set( *dllDrive, NULL, NULL )); |
|
204 User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL )); |
|
205 TFileName* fileName = new ( ELeave ) TFileName; |
|
206 CleanupStack::PushL( fileName ); |
|
207 fileName->Append( parse.FullName() ); |
|
208 |
|
209 // Get language of resource file |
|
210 BaflUtils::NearestLanguageFile( fsSession, *fileName ); |
|
211 |
|
212 // Open resource file |
|
213 aResourceLoader.OpenL( *fileName ); |
|
214 |
|
215 // Pop all the fields |
|
216 CleanupStack::PopAndDestroy( fileName ); |
|
217 CleanupStack::PopAndDestroy( dllDrive ); |
|
218 CleanupStack::PopAndDestroy( tmpName ); |
|
219 |
|
220 CleanupStack::Pop(); // fsSession |
|
221 |
|
222 //If leave occurs before this, close is called automatically when the thread exits. |
|
223 fsSession.Close(); |
|
224 |
|
225 } |
|
226 |
|
227 |