htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMessagesServicePlugin.cpp
branchRCL_3
changeset 20 48060abbbeaf
parent 19 d40e813b23c0
child 21 b3cee849fa46
equal deleted inserted replaced
19:d40e813b23c0 20:48060abbbeaf
     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:  MessagesServicePlugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "HtiMessagesServicePlugin.h"
       
    21 #include "MessageMgmntHandler.h"
       
    22 #include "HtiIAPHandler.h"
       
    23 #include "HtiMailboxHandler.h"
       
    24 #include "HtiMsgSettingsHandler.h"
       
    25 
       
    26 #include <HtiDispatcherInterface.h>
       
    27 #include <HtiLogging.h>
       
    28 
       
    29 // CONSTANTS
       
    30 _LIT8( KErrorMissingCommand, "Command was not given - message was empty" );
       
    31 _LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
       
    32 
       
    33 // ----------------------------------------------------------------------------
       
    34 // Create instance of concrete ECOM interface implementation
       
    35 CHtiMessagesServicePlugin* CHtiMessagesServicePlugin::NewL()
       
    36     {
       
    37     CHtiMessagesServicePlugin* self = new (ELeave) CHtiMessagesServicePlugin;
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop();
       
    41     return self;
       
    42     }
       
    43 
       
    44 // ----------------------------------------------------------------------------
       
    45 CHtiMessagesServicePlugin::CHtiMessagesServicePlugin()
       
    46     {
       
    47     }
       
    48 
       
    49 // ----------------------------------------------------------------------------
       
    50 CHtiMessagesServicePlugin::~CHtiMessagesServicePlugin()
       
    51     {
       
    52     HTI_LOG_TEXT( "CHtiMessagesServicePlugin destroy" );
       
    53     delete iMessageHandler;
       
    54     delete iIAPHandler;
       
    55     delete iMailboxHandler;
       
    56     delete iMsgSettingsHandler;
       
    57     }
       
    58 
       
    59 // ----------------------------------------------------------------------------
       
    60 void CHtiMessagesServicePlugin::ConstructL()
       
    61     {
       
    62     HTI_LOG_TEXT( "CHtiMessagesServicePlugin::ConstructL" );
       
    63 
       
    64     }
       
    65 
       
    66 // ----------------------------------------------------------------------------
       
    67 void CHtiMessagesServicePlugin::ProcessMessageL( const TDesC8& aMessage,
       
    68     THtiMessagePriority aPriority)
       
    69     {
       
    70     HTI_LOG_FUNC_IN( "CHtiMessagesServicePlugin::ProcessMessageL" );
       
    71     HTI_LOG_FORMAT( "Msg len: %d.", aMessage.Length() );
       
    72 
       
    73     if ( aMessage.Length() == 0 )
       
    74         {
       
    75         User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
       
    76             KErrArgument, KErrorMissingCommand, KHtiMessagesServiceUid ) );
       
    77         return;
       
    78         }
       
    79 
       
    80     TUint8 command = aMessage.Ptr()[0];
       
    81 
       
    82     if ( command >= EAddSms && command <= EDeleteFolderContent )
       
    83         {
       
    84         if ( !iMessageHandler )
       
    85             {
       
    86             iMessageHandler = CMessageMgmntHandler::NewL();
       
    87             iMessageHandler->SetDispatcher( iDispatcher );
       
    88             }
       
    89         iMessageHandler->ProcessMessageL( aMessage, aPriority );
       
    90         }
       
    91     else if ( command >= ECreateMailBox && command <= EDeleteMailBox  )
       
    92         {
       
    93         if ( !iMailboxHandler )
       
    94             {
       
    95             iMailboxHandler = CHtiMailboxHandler::NewL();
       
    96             iMailboxHandler->SetDispatcher( iDispatcher );
       
    97             }
       
    98         iMailboxHandler->ProcessMessageL( aMessage, aPriority );
       
    99         }
       
   100     else if ( command >= ECreateIAP && command <= ESetDefaultConnection )
       
   101         {
       
   102         if ( !iIAPHandler )
       
   103             {
       
   104             iIAPHandler = CHtiIAPHandler::NewL();
       
   105             iIAPHandler->SetDispatcher( iDispatcher );
       
   106             }
       
   107         iIAPHandler->ProcessMessageL( aMessage, aPriority );
       
   108         }
       
   109 
       
   110     else if ( command >= ESetDefaultSmsCenter && command <= ESetMmsSettings )
       
   111         {
       
   112         if ( !iMsgSettingsHandler )
       
   113             {
       
   114             iMsgSettingsHandler = CHtiMsgSettingsHandler::NewL();
       
   115             iMsgSettingsHandler->SetDispatcher( iDispatcher );
       
   116             }
       
   117         iMsgSettingsHandler->ProcessMessageL( aMessage, aPriority );
       
   118         }
       
   119 
       
   120     else
       
   121         {
       
   122         User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
       
   123             KErrArgument, KErrorUnrecognizedCommand, KHtiMessagesServiceUid ) );
       
   124         }
       
   125 
       
   126     HTI_LOG_FUNC_OUT( "CHtiMessagesServicePlugin::ProcessMessageL: Done" );
       
   127     }