88
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <w32std.h>
|
|
19 |
#include <apgtask.h>
|
|
20 |
#include <apgcli.h>
|
|
21 |
#include <AknTaskList.h>
|
|
22 |
|
|
23 |
#include "caurlhandler.h"
|
|
24 |
#include "cadef.h"
|
|
25 |
#include "cainnerentry.h"
|
|
26 |
|
|
27 |
// ================= MEMBER FUNCTIONS =======================
|
|
28 |
|
|
29 |
// --------------------------------------------------------------------------
|
|
30 |
// CCaUrlHandler::~CCaUrlHandler
|
|
31 |
// --------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
CCaUrlHandler::~CCaUrlHandler()
|
|
34 |
{
|
|
35 |
}
|
|
36 |
|
|
37 |
// --------------------------------------------------------------------------
|
|
38 |
// CCaUrlHandler::NewL
|
|
39 |
// --------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CCaUrlHandler* CCaUrlHandler::NewL()
|
|
42 |
{
|
|
43 |
CCaUrlHandler* handler = new ( ELeave ) CCaUrlHandler();
|
|
44 |
CleanupStack::PushL( handler );
|
|
45 |
handler->ConstructL();
|
|
46 |
CleanupStack::Pop( handler );
|
|
47 |
return handler;
|
|
48 |
}
|
|
49 |
|
|
50 |
// --------------------------------------------------------------------------
|
|
51 |
// CCaUrlHandler::CCaUrlHandler
|
|
52 |
// --------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
CCaUrlHandler::CCaUrlHandler()
|
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
// --------------------------------------------------------------------------
|
|
59 |
// CCaUrlHandler::ConstructL
|
|
60 |
// --------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
void CCaUrlHandler::ConstructL()
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
// --------------------------------------------------------------------------
|
|
67 |
// CCaUrlHandler::HandleCommandL
|
|
68 |
// --------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
void CCaUrlHandler::HandleCommandL( CCaInnerEntry& aEntry,
|
|
71 |
const TDesC8& aCommand )
|
|
72 |
{
|
|
73 |
|
|
74 |
if( !aCommand.Compare( KCaCmdOpen() ) )
|
|
75 |
{
|
|
76 |
const RCaEntryAttrArray& attributes = aEntry.GetAttributes();
|
|
77 |
TInt attributesArrayCount = attributes.Count();
|
|
78 |
for( int i = 0; i < attributesArrayCount; ++i )
|
|
79 |
{
|
|
80 |
const CCaEntryAttribute * const attribute = attributes[i];
|
|
81 |
if( attribute->Name().Compare( KCaAttrUrl ) == 0 )
|
|
82 |
{
|
|
83 |
LaunchUrlL( attribute->Value() );
|
|
84 |
break;
|
|
85 |
}
|
|
86 |
}
|
|
87 |
}
|
|
88 |
else
|
|
89 |
{
|
|
90 |
User::Leave( KErrNotSupported );
|
|
91 |
}
|
|
92 |
}
|
|
93 |
|
|
94 |
// --------------------------------------------------------------------------
|
|
95 |
// CCaUrlHandler::LaunchUrlL
|
|
96 |
// --------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
|
|
99 |
void CCaUrlHandler::LaunchUrlL( const TDesC& aUrl )
|
|
100 |
{
|
|
101 |
// Launches browser stand-alone.
|
|
102 |
// Browser is launched with a parameter 4 ("4 http://...."), which
|
|
103 |
// Start/Continue the browser specifying a URL.
|
|
104 |
// Other available parameters are described in the Browser API Specification
|
|
105 |
// Document.
|
|
106 |
TInt length = aUrl.Length() + KBrowserPrefix.iTypeLength;
|
|
107 |
|
|
108 |
RWsSession wsSession;
|
|
109 |
User::LeaveIfError( wsSession.Connect() );
|
|
110 |
CleanupClosePushL<RWsSession> ( wsSession );
|
|
111 |
|
|
112 |
CAknTaskList* taskList = CAknTaskList::NewL( wsSession );
|
|
113 |
TApaTask task = taskList->FindRootApp( KUidBrowser );
|
|
114 |
delete taskList;
|
|
115 |
|
|
116 |
if( task.Exists() )
|
|
117 |
{
|
|
118 |
HBufC8* param8 = HBufC8::NewLC( length );
|
|
119 |
TPtr8 ptr8 = param8->Des();
|
|
120 |
ptr8.Append( KBrowserPrefix );
|
|
121 |
ptr8.Append( aUrl );
|
|
122 |
|
|
123 |
// Sends message to existing Browser task.
|
|
124 |
task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
|
|
125 |
CleanupStack::PopAndDestroy( param8 );
|
|
126 |
}
|
|
127 |
else
|
|
128 |
{
|
|
129 |
HBufC* buf = HBufC::NewLC( length );
|
|
130 |
TPtr ptr = buf->Des();
|
|
131 |
ptr.Append( KBrowserPrefix );
|
|
132 |
ptr.Append( aUrl );
|
|
133 |
|
|
134 |
RApaLsSession appArcSession;
|
|
135 |
User::LeaveIfError( appArcSession.Connect() );
|
|
136 |
CleanupClosePushL<RApaLsSession> ( appArcSession );
|
|
137 |
TThreadId id;
|
|
138 |
appArcSession.StartDocument( *buf, KUidBrowser, id );
|
|
139 |
CleanupStack::PopAndDestroy( &appArcSession );
|
|
140 |
CleanupStack::PopAndDestroy( buf );
|
|
141 |
}
|
|
142 |
|
|
143 |
CleanupStack::PopAndDestroy( &wsSession );
|
|
144 |
}
|