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: Implements interface for CSatellite |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <bautils.h> |
|
21 #include <AknWaitDialog.h> |
|
22 #include <data_caging_path_literals.hrh> |
|
23 #include <SatInfo.rsg> |
|
24 #include "SatInfoConsts.h" |
|
25 #include "CSatelliteEng.h" |
|
26 #include "CSatelliteDialog.h" |
|
27 #include "Debug.h" |
|
28 #include "CSatellite.h" |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS ============================== |
|
31 // ---------------------------------------------------------------------------- |
|
32 // CSatellite::NewL |
|
33 // Two-phased constructor. |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 CSatellite* CSatellite::NewL() |
|
37 { |
|
38 CSatellite* self = new( ELeave ) CSatellite; |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(); // self |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // CSatellite::ConstructL |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 void CSatellite::ConstructL() |
|
50 { |
|
51 iEnv = CEikonEnv::Static(); |
|
52 OpenResourceFileL(); |
|
53 iEngine = CSatelliteEng::NewL(); |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CSatellite::CSatellite |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // ---------------------------------------------------------------------------- |
|
61 // |
|
62 CSatellite::CSatellite() |
|
63 { |
|
64 iLaunchView = ESignalStrengthView; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // CSatellite::~CSatellite |
|
69 // --------------------------------------------------------- |
|
70 // |
|
71 CSatellite::~CSatellite() |
|
72 { |
|
73 CloseResourceFile(); |
|
74 delete iEngine; |
|
75 delete iWaitDialog; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CSatellite::NotifyL |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 void CSatellite::NotifyL(TInt /*aError*/) |
|
83 { |
|
84 if ( iWaitDialog ) |
|
85 { |
|
86 iWaitDialog->ProcessFinishedL(); |
|
87 iWaitDialog = NULL; |
|
88 } |
|
89 else if(iDialog) |
|
90 { |
|
91 iDialog->UpdateL(); |
|
92 } |
|
93 } |
|
94 |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CSatellite::NotifyError |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 void CSatellite::NotifyError( TInt /*aErrorCode*/ ) |
|
101 { |
|
102 if ( iWaitDialog ) |
|
103 { |
|
104 delete iWaitDialog; |
|
105 iWaitDialog = NULL; |
|
106 } |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // CSatellite::ExecuteL |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 TInt CSatellite::ExecuteL( const TDesC& aNameOfRule ) |
|
114 { |
|
115 TInt ret(0); |
|
116 |
|
117 iEngine->SetObserver( *this ); |
|
118 iEngine->RequestSatelliteDataL( aNameOfRule ); |
|
119 |
|
120 iWaitDialog = new (ELeave) CAknWaitDialog( NULL, ETrue ); |
|
121 if ( iWaitDialog->ExecuteLD( R_SATELLITE_WAIT_NOTE ) ) |
|
122 { |
|
123 iWaitDialog = NULL; |
|
124 iDialog = CSatelliteDialog::NewL( *iEngine ); |
|
125 iDialog->SetLaunchView(iLaunchView); |
|
126 ret = iDialog->ExecuteLD(R_SATELLITE_DIALOG); |
|
127 } |
|
128 else |
|
129 { |
|
130 delete iDialog; |
|
131 iDialog = NULL; |
|
132 } |
|
133 iWaitDialog = NULL; |
|
134 return ret; |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // CSatellite::HandleForegroundEventL |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 void CSatellite::HandleForegroundEventL(TBool aForeground) |
|
142 { |
|
143 if ( aForeground ) |
|
144 { |
|
145 iEngine->StartRequestingL(); |
|
146 } |
|
147 else |
|
148 { |
|
149 iEngine->StopRequesting(); |
|
150 } |
|
151 } |
|
152 |
|
153 |
|
154 // ---------------------------------------------------------------------------- |
|
155 // CSatellite::OpenResourceFile |
|
156 // ---------------------------------------------------------------------------- |
|
157 // |
|
158 void CSatellite::OpenResourceFileL() |
|
159 { |
|
160 FindResourceFileL(); |
|
161 |
|
162 BaflUtils::NearestLanguageFile( iEnv->FsSession(), iResourceFileName ); |
|
163 iResourceOffset = iEnv->AddResourceFileL( iResourceFileName ); |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // CSatellite::CloseResourceFile |
|
168 // ---------------------------------------------------------------------------- |
|
169 // |
|
170 void CSatellite::CloseResourceFile() |
|
171 { |
|
172 iEnv->DeleteResourceFile( iResourceOffset ); |
|
173 } |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // CSatellite::FindResourceFileL |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 void CSatellite::FindResourceFileL() |
|
180 { |
|
181 // Path and file name: |
|
182 TFileName file; |
|
183 file.Append( KSatTmp_RESOURCE_FILES_DIR ); // always safe |
|
184 file.Append( KSatInfoRscFileName ); // always safe |
|
185 |
|
186 // Drive: |
|
187 TFileName drive; |
|
188 Dll::FileName( drive ); |
|
189 |
|
190 // Add drive to path & file name: |
|
191 TParse parse; |
|
192 User::LeaveIfError( parse.Set( file, &drive, NULL ) ); |
|
193 iResourceFileName = parse.FullName(); |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CSatellite::SetLaunchView |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 void CSatellite::SetLaunchView(TSatDialogView aView) |
|
201 { |
|
202 iLaunchView = aView; |
|
203 } |
|
204 |
|
205 // End of File |
|