|
1 /* |
|
2 * Copyright (c) 2002-2005 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 the License "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: Providing open url functionality |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "AiwBrowserProviderOpenUrl.h" |
|
22 |
|
23 #include <AiwMenu.h> |
|
24 #include <coemain.h> |
|
25 #include <barsread.h> |
|
26 #include <aknnotedialog.h> |
|
27 #include <StringLoader.h> |
|
28 #include <AiwBrowserProvider.rsg> |
|
29 #include <data_caging_path_literals.hrh> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <AknNoteDialog.h> |
|
32 #include <apgcli.h> |
|
33 #include <FavouritesLimits.h> |
|
34 #include "AiwBrowserCommands.hrh" |
|
35 #include "logger.h" |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 _LIT( KResourceFileName, "AiwBrowserProvider.rsc"); |
|
39 |
|
40 // ============================= LOCAL FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // NewL |
|
44 // Constructor of CAiwBrowserProviderOpenUrl |
|
45 // Returns: |
|
46 // |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CAiwBrowserProviderOpenUrl* CAiwBrowserProviderOpenUrl::NewL() |
|
50 { |
|
51 CAiwBrowserProviderOpenUrl* self = new(ELeave) CAiwBrowserProviderOpenUrl; |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop(self); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CAiwBrowserProviderOpenUrl |
|
60 // Constructor of CAiwBrowserProviderOpenUrl |
|
61 // Returns: |
|
62 // |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CAiwBrowserProviderOpenUrl::CAiwBrowserProviderOpenUrl() |
|
66 { |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // ConstructL |
|
71 // Constructor of CAiwBrowserProviderOpenUrl |
|
72 // Returns: |
|
73 // |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CAiwBrowserProviderOpenUrl::ConstructL() |
|
77 { |
|
78 TFileName fName( KNullDesC ); |
|
79 iResourceOffset = -1; |
|
80 fName.Append( _L("Z:") ); |
|
81 fName.Append( KDC_RESOURCE_FILES_DIR ); |
|
82 fName.Append( KResourceFileName ); |
|
83 iResourceOffset = CCoeEnv::Static()->AddResourceFileL( fName ); |
|
84 LOG_WRITE("AIWBP: OpenUrl Resource file added."); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // ~CAiwBrowserProviderOpenUrl |
|
89 // Destructor of CAiwBrowserProviderOpenUrl |
|
90 // Returns: |
|
91 // |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 CAiwBrowserProviderOpenUrl::~CAiwBrowserProviderOpenUrl() |
|
95 { |
|
96 if( iResourceOffset != -1 ) |
|
97 { |
|
98 CCoeEnv::Static()->DeleteResourceFile( iResourceOffset ); |
|
99 iResourceOffset = -1; |
|
100 } |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // InitialiseL |
|
105 // aiw initialization |
|
106 // Returns: none |
|
107 // |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 |
|
111 void CAiwBrowserProviderOpenUrl::InitialiseL(MAiwNotifyCallback& aFrameworkCallback, |
|
112 const RCriteriaArray& aInterest) |
|
113 { |
|
114 iNotifyCallback = &aFrameworkCallback; |
|
115 iInterest = &aInterest; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // HandleServiceCmdL |
|
120 // |
|
121 // Returns: |
|
122 // |
|
123 // |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 |
|
127 void CAiwBrowserProviderOpenUrl::HandleServiceCmdL |
|
128 (const TInt& /*aCmdId*/, const CAiwGenericParamList& /*aInParamList*/, |
|
129 CAiwGenericParamList& /*aOutParamList*/, TUint /*aCmdOptions*/, |
|
130 const MAiwNotifyCallback* /*aCallback*/) |
|
131 { |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // InitializeMenuPaneL |
|
136 // initialization of menu pane |
|
137 // Returns: none |
|
138 // |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 |
|
142 void CAiwBrowserProviderOpenUrl::InitializeMenuPaneL |
|
143 (CAiwMenuPane& aMenuPane, TInt aIndex, |
|
144 TInt /*aCascadeId*/, const CAiwGenericParamList& /*aInParamList*/) |
|
145 { |
|
146 TResourceReader reader; |
|
147 CCoeEnv::Static()->CreateResourceReaderLC |
|
148 (reader, R_AIW_BROWSER_PROVIDER_OPEN_URL_MENU); |
|
149 aMenuPane.AddMenuItemsL(reader, EBrowserAiwCmdOpenUrl, aIndex);//open url |
|
150 CleanupStack::PopAndDestroy(); // reader |
|
151 LOG_WRITE("AIWBP: OpenUrl menupane initialized."); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // HandleMenuCmdL |
|
156 // handles menu commands |
|
157 // Returns: none |
|
158 // |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 |
|
162 void CAiwBrowserProviderOpenUrl::HandleMenuCmdL |
|
163 (TInt aMenuCmdId, const CAiwGenericParamList& aInParamList, |
|
164 CAiwGenericParamList& /*aOutParamList*/, TUint /*aCmdOptions*/, |
|
165 const MAiwNotifyCallback* /*aCallback*/) |
|
166 { |
|
167 if ( aMenuCmdId == EBrowserAiwCmdOpenUrl ) |
|
168 { |
|
169 TInt index = 0; |
|
170 const TAiwGenericParam* genericParam = NULL; |
|
171 TPtrC paramtext; |
|
172 index = 0; |
|
173 genericParam = aInParamList.FindFirst( index, |
|
174 EGenericParamURL, |
|
175 EVariantTypeDesC); |
|
176 LOG_WRITE("AIWBP: LaunchBrowser called with url:"); |
|
177 LOG_WRITE_TDES( genericParam->Value().AsDes() ); |
|
178 if( index == KErrNotFound ) |
|
179 { |
|
180 LOG_WRITE("AIWBP: Open Url Parameter not found!" ); |
|
181 return; |
|
182 } |
|
183 LaunchBrowserL( genericParam->Value().AsDes() ); |
|
184 } |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // LaunchBrowser |
|
189 // Launches a browser with an url |
|
190 // Returns: none |
|
191 // |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 |
|
195 void CAiwBrowserProviderOpenUrl::LaunchBrowserL( const TDesC& aUrl ) |
|
196 { |
|
197 const TInt KBrowserUid = 0x10008D39; |
|
198 HBufC* param = HBufC::NewLC( KFavouritesMaxUrl ); |
|
199 param->Des().Copy( _L( "4 " ) ); |
|
200 param->Des().Append( aUrl ); |
|
201 TUid id( TUid::Uid( KBrowserUid ) ); |
|
202 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
203 TApaTask task = taskList.FindApp( id ); |
|
204 |
|
205 LOG_WRITE("AIWBP: Browser launched with url:" ); |
|
206 LOG_WRITE_TDES( param->Des() ); |
|
207 |
|
208 if ( task.Exists() ) |
|
209 { |
|
210 HBufC8* param8 = HBufC8::NewLC( param->Length() ); |
|
211 param8->Des().Append( *param ); |
|
212 task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used |
|
213 CleanupStack::PopAndDestroy(); |
|
214 } |
|
215 else |
|
216 { |
|
217 RApaLsSession appArcSession; |
|
218 User::LeaveIfError( appArcSession.Connect() ); // connect to AppArc server |
|
219 CleanupClosePushL( appArcSession ); |
|
220 TThreadId id; |
|
221 User::LeaveIfError |
|
222 ( appArcSession.StartDocument( *param, TUid::Uid( KBrowserUid ), id ) ); |
|
223 CleanupStack::PopAndDestroy( &appArcSession ); |
|
224 } |
|
225 |
|
226 CleanupStack::PopAndDestroy(); // param |
|
227 } |