commands/switchview/switchview.cpp
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // switchview.cpp
       
     2 // 
       
     3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "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 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #undef SYMBIAN_ENABLE_SPLIT_HEADERS // Stopgap to handle CVwsSessionWrapper being compiled out of viewcli.h in latest TB92
       
    14 #include <fshell/ioutils.h>
       
    15 #include <viewcli.h>
       
    16 #include <fshell/common.mmh>
       
    17 
       
    18 using namespace IoUtils;
       
    19 
       
    20 class CCmdSwitchview : public CCommandBase
       
    21 	{
       
    22 public:
       
    23 	static CCommandBase* NewLC();
       
    24 	~CCmdSwitchview();
       
    25 private:
       
    26 	CCmdSwitchview();
       
    27 private: // From CCommandBase.
       
    28 	virtual const TDesC& Name() const;
       
    29 	virtual void DoRunL();
       
    30 	virtual void ArgumentsL(RCommandArgumentList& aArguments);
       
    31 	virtual void OptionsL(RCommandOptionList& aOptions);
       
    32 private:
       
    33 	TUid iAppId;
       
    34 	TUid iViewId;
       
    35 	TUid iCustomMessageId;
       
    36 	HBufC* iCustomMessage;
       
    37 	};
       
    38 
       
    39 
       
    40 CCommandBase* CCmdSwitchview::NewLC()
       
    41 	{
       
    42 	CCmdSwitchview* self = new(ELeave) CCmdSwitchview();
       
    43 	CleanupStack::PushL(self);
       
    44 	self->BaseConstructL();
       
    45 	return self;
       
    46 	}
       
    47 
       
    48 CCmdSwitchview::~CCmdSwitchview()
       
    49 	{
       
    50 	delete iCustomMessage;
       
    51 	}
       
    52 
       
    53 CCmdSwitchview::CCmdSwitchview()
       
    54 	{
       
    55 	}
       
    56 
       
    57 const TDesC& CCmdSwitchview::Name() const
       
    58 	{
       
    59 	_LIT(KName, "switchview");	
       
    60 	return KName;
       
    61 	}
       
    62 
       
    63 void CCmdSwitchview::DoRunL()
       
    64 	{
       
    65 	CVwsSessionWrapper* vws = CVwsSessionWrapper::NewLC();
       
    66 	TVwsViewId viewId(iAppId, iViewId);
       
    67 
       
    68 	TPtrC8 customMessagePtr(KNullDesC8);
       
    69 	if (iCustomMessage)
       
    70 		{
       
    71 		customMessagePtr.Set((TUint8*)iCustomMessage->Ptr(), iCustomMessage->Size());
       
    72 		}
       
    73 
       
    74 #ifdef FSHELL_9_1_SUPPORT
       
    75 	User::LeaveIfError(vws->ActivateView(viewId, iCustomMessageId, customMessagePtr));
       
    76 #else
       
    77 	TRequestStatus status;
       
    78 	vws->ActivateView(viewId, iCustomMessageId, customMessagePtr, status);
       
    79 	User::WaitForRequest(status);
       
    80 	User::LeaveIfError(status.Int());
       
    81 #endif
       
    82 
       
    83 	CleanupStack::PopAndDestroy(vws);
       
    84 	}
       
    85 
       
    86 void CCmdSwitchview::ArgumentsL(RCommandArgumentList& aArguments)
       
    87 	{
       
    88 	_LIT(KArgAppId, "app_id");
       
    89 	aArguments.AppendUintL((TUint&)iAppId.iUid, KArgAppId);
       
    90 	_LIT(KArgViewId, "view_id");
       
    91 	aArguments.AppendUintL((TUint&)iViewId.iUid, KArgViewId);
       
    92 	_LIT(KArgCustomMessageId, "custom_message_id");
       
    93 	aArguments.AppendUintL((TUint&)iCustomMessageId.iUid, KArgCustomMessageId);
       
    94 	_LIT(KArgCustomMessage, "custom_message");
       
    95 	aArguments.AppendStringL(iCustomMessage, KArgCustomMessage);
       
    96 	}
       
    97 
       
    98 void CCmdSwitchview::OptionsL(RCommandOptionList&)
       
    99 	{
       
   100 	}
       
   101 
       
   102 
       
   103 EXE_BOILER_PLATE(CCmdSwitchview)
       
   104