idlefw/plugins/mcsplugin/handler/src/mcspluginhandler.cpp
changeset 0 79c6a41cd166
child 8 d0529222e3f0
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <ecom/implementationproxy.h>
       
    19 #include <eikenv.h>
       
    20 #include <sendui.h>
       
    21 #include <SendUiConsts.h>
       
    22 
       
    23 #include <mcsmenuutils.h>
       
    24 #include <mcsmenuitem.h>
       
    25 
       
    26 #include <viewcli.h>                // For CVwsSessionWrapper
       
    27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    28 #include <viewclipartner.h>
       
    29 #endif
       
    30 
       
    31 #include <vwsdef.h>                 // For TVwsViewId
       
    32 #include <mcspluginparamval.h>
       
    33 #include <LogsUiCmdStarter.h>
       
    34 
       
    35 #include "mcsplugincompletedoperation.h"
       
    36 #include "mcspluginhandler.h"
       
    37 #include "mcspluginuids.hrh"
       
    38 
       
    39 #include "aiscutdefs.h"
       
    40 class CVwsSessionWrapper;
       
    41 
       
    42 _LIT( KMenuTypeShortcut, "menu:shortcut" ); ///< Menu folder type.
       
    43 _LIT( KMenuAttrParamLogs, "logs:dialed" );
       
    44 
       
    45 /** Argument value for parameter*/
       
    46 _LIT( KMenuAttrParam, "param" );
       
    47 
       
    48 const TInt KImplUidMCSPluginHandler = AI_UID_ECOM_IMPLEMENTATION_MCSPLUGIN_HANDLER;
       
    49 
       
    50 const TImplementationProxy ImplementationTable[] = 
       
    51     {
       
    52     IMPLEMENTATION_PROXY_ENTRY( KImplUidMCSPluginHandler, CMCSPluginHandler::NewL)
       
    53     };
       
    54 
       
    55 // ================= MEMBER FUNCTIONS =======================
       
    56 
       
    57 // ---------------------------------------------------------
       
    58 // CMCSPluginHandler::~CMCSPluginHandler
       
    59 // ---------------------------------------------------------
       
    60 //
       
    61 CMCSPluginHandler::~CMCSPluginHandler()
       
    62     {
       
    63     delete iVwsSession;
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // CMCSPluginHandler::NewL
       
    68 // ---------------------------------------------------------
       
    69 //
       
    70 CMCSPluginHandler* CMCSPluginHandler::NewL( RMenu &aMenu )
       
    71     {
       
    72     CMCSPluginHandler* handler = new (ELeave) CMCSPluginHandler( aMenu );
       
    73     CleanupStack::PushL( handler );
       
    74     handler->ConstructL();
       
    75     CleanupStack::Pop( handler );
       
    76     return handler;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CMCSPluginHandler::CMCSPluginHandler
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 CMCSPluginHandler::CMCSPluginHandler( RMenu &aMenu )
       
    84 : CMenuHandlerPlugin( aMenu )
       
    85     {
       
    86     iEikEnv = CEikonEnv::Static();
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CMCSPluginHandler::ConstructL
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 void CMCSPluginHandler::ConstructL()
       
    94     {
       
    95     BaseConstructL();
       
    96     iVwsSession = CVwsSessionWrapper::NewL();
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------
       
   100 // Supported menu item types
       
   101 // ---------------------------------------------------------
       
   102 //
       
   103 TBool CMCSPluginHandler::SupportsType( const TDesC& aType )
       
   104     {
       
   105     if ( !aType.Compare( KMenuTypeFolder() ) ||
       
   106          !aType.Compare( KMenuTypeSuite() )  ||
       
   107          !aType.Compare( KMenuTypeShortcut ) )
       
   108         {
       
   109         return ETrue;
       
   110         }
       
   111     return EFalse;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // Main command handler
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 CMenuOperation* CMCSPluginHandler::HandleCommandL(
       
   119         CMenuItem& aItem,
       
   120         const TDesC8& aCommand,
       
   121         const TDesC8& /*aParams*/,
       
   122         TRequestStatus& aStatus )
       
   123     {
       
   124     if ( aCommand != KMenuCmdOpen() )
       
   125         {
       
   126         User::Leave ( KErrNotSupported );
       
   127         }
       
   128 
       
   129     if( aItem.Type() == KMenuTypeFolder() )
       
   130         {
       
   131         
       
   132         return CMCSPluginCompletedOperation::NewL
       
   133             ( iMenu, CActive::EPriorityStandard, aStatus, KErrNone );
       
   134         }
       
   135     else if ( aItem.Type() == KMenuTypeSuite() )
       
   136         {
       
   137         return CMCSPluginCompletedOperation::NewL
       
   138             ( iMenu, CActive::EPriorityStandard, aStatus, KErrNone );
       
   139         }
       
   140     else if ( aItem.Type() == KMenuTypeShortcut() )
       
   141         {
       
   142         LaunchShortcutL( aItem );
       
   143         return CMCSPluginCompletedOperation::NewL
       
   144             ( iMenu, CActive::EPriorityStandard, aStatus, KErrNone );
       
   145         }
       
   146     else
       
   147         {
       
   148         User::Leave ( KErrNotSupported );
       
   149         }
       
   150     return NULL;
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------
       
   154 // Handles menu:shortcut specific commands
       
   155 // Must be extended to launch e.g. MailBoxes
       
   156 // caiscuttargetmessagingview.cpp implements the mailbox launching in old shortcut plugin
       
   157 // ---------------------------------------------------------
       
   158 //
       
   159 void CMCSPluginHandler::LaunchShortcutL( CMenuItem& aItem )
       
   160     {
       
   161 
       
   162     // menu:shortcut type of items are launched based on attribute param
       
   163     TBool attrExists = ETrue;
       
   164     TPtrC param = aItem.GetAttributeL( KMenuAttrParam, attrExists );
       
   165 
       
   166     if ( !attrExists )
       
   167         {
       
   168         User::Leave( KErrCorrupt );
       
   169         }
       
   170 
       
   171     // Messaging specific commands
       
   172     CSendUi* sendUi = CSendUi::NewLC();
       
   173     if ( param == KParamValueSelType ) // Select message type
       
   174         {
       
   175         TSendingCapabilities capabs( 0, 0, TSendingCapabilities::ESupportsEditor );
       
   176 
       
   177         TUid uid = sendUi->ShowTypedQueryL( CSendUi::EWriteMenu, NULL, capabs, NULL, KNullDesC );
       
   178         if ( uid != KNullUid )
       
   179             {
       
   180             sendUi->ServiceCapabilitiesL( uid, capabs );
       
   181             sendUi->CreateAndSendMessageL( uid, NULL, KNullUid, EFalse ); // launch standalone
       
   182             }
       
   183         }
       
   184     else if ( param == KParamValueMsg ) // New text message
       
   185         {
       
   186         sendUi->CreateAndSendMessageL(KSenduiMtmUniMessageUid, NULL, KNullUid, EFalse);
       
   187         }
       
   188     else if ( param == KParamValueEmail ) // New email
       
   189         {
       
   190         sendUi->CreateAndSendMessageL( KSenduiMtmSmtpUid, NULL, KNullUid, EFalse );
       
   191         }
       
   192 #ifdef __SYNCML_DS_EMAIL
       
   193     else if ( param == KParamValueSyncMLMail ) // New SyncML mail
       
   194         {
       
   195         sendUi->CreateAndSendMessageL( KSenduiMtmSyncMLEmailUid, NULL, KNullUid, EFalse );
       
   196         }
       
   197 #endif
       
   198     else if ( param == KParamValuePostcard ) // New postcard
       
   199         {
       
   200         sendUi->CreateAndSendMessageL( KSenduiMtmPostcardUid, NULL, KNullUid, EFalse );
       
   201         }
       
   202     else if ( param == KParamValueAudioMsg ) // New audio message
       
   203         {
       
   204         sendUi->CreateAndSendMessageL( KSenduiMtmAudioMessageUid, NULL, KNullUid, EFalse );
       
   205         }
       
   206     else if ( param.Find( KParamValueMailbox ) != KErrNotFound ) // Mailbox
       
   207         {
       
   208         TBool attrExists = ETrue;
       
   209         TInt pos = param.Locate( TChar( ':' ) ) + 1;
       
   210         TPtrC mailboxId = param.Mid( pos );
       
   211 
       
   212         if ( attrExists )
       
   213             {
       
   214             TInt number;
       
   215             TLex16 lextmp( mailboxId );
       
   216             lextmp.Val( number );
       
   217             TUid uId = TUid::Uid( number );
       
   218             const TVwsViewId viewId( KScutMessagingUid, KScutRemoteMailboxViewId );
       
   219             iVwsSession->CreateActivateViewEvent( viewId, uId, KNullDesC8() );
       
   220             }
       
   221         }
       
   222     else if ( param.Find( KMenuAttrParamLogs ) != KErrNotFound )
       
   223         {
       
   224         LogsUiCmdStarter::CmdStartL( LogsUiCmdStarterConsts::KDialledView() );
       
   225         }
       
   226     CleanupStack::PopAndDestroy( sendUi );
       
   227     }
       
   228 
       
   229 // ============================ GLOBAL FUNCTIONS ===============================
       
   230 
       
   231 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   232     {
       
   233     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   234     return ImplementationTable;
       
   235     }