|
1 /* |
|
2 * Copyright (c) 2006-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: Loads browser launcher dynamically. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <w32std.h> |
|
21 #include <apgcli.h> |
|
22 #include <apgtask.h> |
|
23 #include <FavouritesDb.h> |
|
24 |
|
25 #include "pslnbrowserlaunchloader.h" |
|
26 #include "PslnConst.h" |
|
27 |
|
28 //Browser UID |
|
29 const TUid KUidBrowser = { 0x10008D39 }; |
|
30 const TInt KPslnBrowserParamLen = 20; |
|
31 _LIT( KPslnBrowserPrefix, "6 " ); |
|
32 |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // C++ default constructor can NOT contain any code, that might leave. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CPslnBrowserLaunchLoader::CPslnBrowserLaunchLoader() |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Two-phased constructor. |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CPslnBrowserLaunchLoader* CPslnBrowserLaunchLoader::NewL() |
|
49 { |
|
50 CPslnBrowserLaunchLoader* self = |
|
51 new( ELeave ) CPslnBrowserLaunchLoader(); |
|
52 |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Destructor |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CPslnBrowserLaunchLoader::~CPslnBrowserLaunchLoader() |
|
61 { |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // Launch browser as standalone application. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CPslnBrowserLaunchLoader::LaunchBrowserStandaloneL( ) |
|
69 { |
|
70 |
|
71 HBufC* param = HBufC::NewLC( KPslnBrowserParamLen ); |
|
72 param->Des().Copy( KPslnBrowserPrefix ); |
|
73 TInt folderid = GetFolderIdByContextIdL( KFavouritesSkinContextId ); |
|
74 param->Des().AppendNum( folderid ); |
|
75 |
|
76 RWsSession wsSession; |
|
77 User::LeaveIfError( wsSession.Connect() ); |
|
78 CleanupClosePushL<RWsSession>( wsSession ); |
|
79 TApaTaskList taskList( wsSession ); |
|
80 TApaTask task = taskList.FindApp( KUidBrowser ); |
|
81 |
|
82 if ( task.Exists() ) |
|
83 { |
|
84 HBufC8* param8 = HBufC8::NewLC( param->Length() ); |
|
85 param8->Des().Append( param->Des() ); |
|
86 task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used |
|
87 CleanupStack::PopAndDestroy( param8 ); |
|
88 } |
|
89 else |
|
90 { |
|
91 RApaLsSession appArcSession; |
|
92 User::LeaveIfError( appArcSession.Connect() ); |
|
93 CleanupClosePushL<RApaLsSession>( appArcSession ); |
|
94 TThreadId id; |
|
95 appArcSession.StartDocument( *param, KUidBrowser , id ); |
|
96 CleanupStack::PopAndDestroy(); // appArcSession |
|
97 } |
|
98 |
|
99 CleanupStack::PopAndDestroy( 2 ); // param,wsSession |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Cancel download. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CPslnBrowserLaunchLoader::CancelDownload() |
|
107 { |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Gets browser bookmark folder id. |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 TInt CPslnBrowserLaunchLoader::GetFolderIdByContextIdL( TUint32 aContextId ) |
|
115 { |
|
116 TInt folder = KFavouritesNullUid; |
|
117 if ( aContextId != (TUint32)KFavouritesNullContextId ) |
|
118 { |
|
119 CArrayFix<TInt>* uids = new (ELeave) CArrayFixFlat<TInt>( 1 ); |
|
120 CleanupStack::PushL( uids ); |
|
121 |
|
122 RFavouritesDb db; |
|
123 RFavouritesSession iFavouritesSess; |
|
124 User::LeaveIfError( iFavouritesSess.Connect() ); |
|
125 CleanupClosePushL<RFavouritesSession>( iFavouritesSess ); |
|
126 User::LeaveIfError( db.Open( iFavouritesSess, KBrowserBookmarks ) ); |
|
127 CleanupClosePushL<RFavouritesDb>( db ); |
|
128 User::LeaveIfError( db.GetUids( *uids, KFavouritesNullUid, |
|
129 CFavouritesItem::EFolder, NULL, aContextId ) ); |
|
130 |
|
131 if( uids->Count() > 0 ) |
|
132 { |
|
133 folder = uids->At( 0 ); |
|
134 } |
|
135 CleanupStack::PopAndDestroy( 3 ); // db,iFavouritesSess,uids |
|
136 } |
|
137 return folder; |
|
138 } |
|
139 |
|
140 //---------------------------------------------------------------------------- |
|
141 // Launcher gate function |
|
142 //---------------------------------------------------------------------------- |
|
143 EXPORT_C TAny* GateFunction() |
|
144 { |
|
145 CPslnBrowserLaunchLoader* launcher = NULL; |
|
146 TRAPD( err, launcher = CPslnBrowserLaunchLoader::NewL() ); |
|
147 if( err != KErrNone ) |
|
148 { |
|
149 return NULL; |
|
150 } |
|
151 |
|
152 return launcher; |
|
153 } |
|
154 |
|
155 // End of File |