diff -r c739008478cc -r 5d243a69bdda contentstorage/cahandler/url/src/caurlhandler.cpp --- a/contentstorage/cahandler/url/src/caurlhandler.cpp Mon May 24 20:50:46 2010 +0300 +++ b/contentstorage/cahandler/url/src/caurlhandler.cpp Fri May 28 16:17:03 2010 +0300 @@ -15,130 +15,33 @@ * */ -#include -#include -#include -#include +#include +#include + +#include #include "caurlhandler.h" -#include "cadef.h" -#include "cainnerentry.h" -// ================= MEMBER FUNCTIONS ======================= - -// -------------------------------------------------------------------------- -// CCaUrlHandler::~CCaUrlHandler -// -------------------------------------------------------------------------- -// -CCaUrlHandler::~CCaUrlHandler() - { - } +static const QString caAttrUrl("url"); -// -------------------------------------------------------------------------- -// CCaUrlHandler::NewL -// -------------------------------------------------------------------------- -// -CCaUrlHandler* CCaUrlHandler::NewL() - { - CCaUrlHandler* handler = new ( ELeave ) CCaUrlHandler(); - CleanupStack::PushL( handler ); - handler->ConstructL(); - CleanupStack::Pop( handler ); - return handler; - } - -// -------------------------------------------------------------------------- -// CCaUrlHandler::CCaUrlHandler -// -------------------------------------------------------------------------- -// -CCaUrlHandler::CCaUrlHandler() - { - } +CaUrlHandler::CaUrlHandler(QObject *parent) +{ + Q_UNUSED(parent); +} -// -------------------------------------------------------------------------- -// CCaUrlHandler::ConstructL -// -------------------------------------------------------------------------- -// -void CCaUrlHandler::ConstructL() - { - } - -// -------------------------------------------------------------------------- -// CCaUrlHandler::HandleCommandL -// -------------------------------------------------------------------------- -// -void CCaUrlHandler::HandleCommandL( CCaInnerEntry& aEntry, - const TDesC8& aCommand ) - { +CaUrlHandler::~CaUrlHandler() +{ +} - if( !aCommand.Compare( KCaCmdOpen() ) ) - { - const RCaEntryAttrArray& attributes = aEntry.GetAttributes(); - TInt attributesArrayCount = attributes.Count(); - for( int i = 0; i < attributesArrayCount; ++i ) - { - const CCaEntryAttribute * const attribute = attributes[i]; - if( attribute->Name().Compare( KCaAttrUrl ) == 0 ) - { - LaunchUrlL( attribute->Value() ); - break; - } - } - } - else - { - User::Leave( KErrNotSupported ); +int CaUrlHandler::execute(const CaEntry &entry, const QString &command) +{ + int err(KErrGeneral); + if (command == caCmdOpen) { + QString attribute = entry.attribute(caAttrUrl); + if (!attribute.isNull() && + QDesktopServices::openUrl(QUrl(attribute))) { + err = KErrNone; } } - -// -------------------------------------------------------------------------- -// CCaUrlHandler::LaunchUrlL -// -------------------------------------------------------------------------- -// - -void CCaUrlHandler::LaunchUrlL( const TDesC& aUrl ) - { - // Launches browser stand-alone. - // Browser is launched with a parameter 4 ("4 http://...."), which - // Start/Continue the browser specifying a URL. - // Other available parameters are described in the Browser API Specification - // Document. - TInt length = aUrl.Length() + KBrowserPrefix.iTypeLength; - - RWsSession wsSession; - User::LeaveIfError( wsSession.Connect() ); - CleanupClosePushL ( wsSession ); - - CAknTaskList* taskList = CAknTaskList::NewL( wsSession ); - TApaTask task = taskList->FindRootApp( KUidBrowser ); - delete taskList; - - if( task.Exists() ) - { - HBufC8* param8 = HBufC8::NewLC( length ); - TPtr8 ptr8 = param8->Des(); - ptr8.Append( KBrowserPrefix ); - ptr8.Append( aUrl ); - - // Sends message to existing Browser task. - task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used - CleanupStack::PopAndDestroy( param8 ); - } - else - { - HBufC* buf = HBufC::NewLC( length ); - TPtr ptr = buf->Des(); - ptr.Append( KBrowserPrefix ); - ptr.Append( aUrl ); - - RApaLsSession appArcSession; - User::LeaveIfError( appArcSession.Connect() ); - CleanupClosePushL ( appArcSession ); - TThreadId id; - appArcSession.StartDocument( *buf, KUidBrowser, id ); - CleanupStack::PopAndDestroy( &appArcSession ); - CleanupStack::PopAndDestroy( buf ); - } - - CleanupStack::PopAndDestroy( &wsSession ); - } + return err; +}