htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMessagesServicePlugin.cpp
changeset 0 d6fe6244b863
child 3 2703485a934c
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     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     }
       
    57 
       
    58 // ----------------------------------------------------------------------------
       
    59 void CHtiMessagesServicePlugin::ConstructL()
       
    60     {
       
    61     HTI_LOG_TEXT( "CHtiMessagesServicePlugin::ConstructL" );
       
    62 
       
    63     }
       
    64 
       
    65 // ----------------------------------------------------------------------------
       
    66 void CHtiMessagesServicePlugin::ProcessMessageL( const TDesC8& aMessage,
       
    67     THtiMessagePriority aPriority)
       
    68     {
       
    69     HTI_LOG_FUNC_IN( "CHtiMessagesServicePlugin::ProcessMessageL" );
       
    70     HTI_LOG_FORMAT( "Msg len: %d.", aMessage.Length() );
       
    71 
       
    72     if ( aMessage.Length() == 0 )
       
    73         {
       
    74         User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
       
    75             KErrArgument, KErrorMissingCommand, KHtiMessagesServiceUid ) );
       
    76         return;
       
    77         }
       
    78 
       
    79     TUint8 command = aMessage.Ptr()[0];
       
    80 
       
    81     if ( command >= EAddSms && command <= EDeleteFolderContent )
       
    82         {
       
    83         if ( !iMessageHandler )
       
    84             {
       
    85             iMessageHandler = CMessageMgmntHandler::NewL();
       
    86             iMessageHandler->SetDispatcher( iDispatcher );
       
    87             }
       
    88         iMessageHandler->ProcessMessageL( aMessage, aPriority );
       
    89         }
       
    90     else if ( command >= ECreateMailBox && command <= EDeleteMailBox  )
       
    91         {
       
    92         if ( !iMailboxHandler )
       
    93             {
       
    94             iMailboxHandler = CHtiMailboxHandler::NewL();
       
    95             iMailboxHandler->SetDispatcher( iDispatcher );
       
    96             }
       
    97         iMailboxHandler->ProcessMessageL( aMessage, aPriority );
       
    98         }
       
    99     else if ( command >= ECreateIAP && command <= ESetDefaultConnection )
       
   100         {
       
   101         if ( !iIAPHandler )
       
   102             {
       
   103             iIAPHandler = CHtiIAPHandler::NewL();
       
   104             iIAPHandler->SetDispatcher( iDispatcher );
       
   105             }
       
   106         iIAPHandler->ProcessMessageL( aMessage, aPriority );
       
   107         }
       
   108 
       
   109     else if ( command >= ESetDefaultSmsCenter && command <= ESetMmsSettings )
       
   110         {
       
   111         if ( !iMsgSettingsHandler )
       
   112             {
       
   113             iMsgSettingsHandler = CHtiMsgSettingsHandler::NewL();
       
   114             iMsgSettingsHandler->SetDispatcher( iDispatcher );
       
   115             }
       
   116         iMsgSettingsHandler->ProcessMessageL( aMessage, aPriority );
       
   117         }
       
   118 
       
   119     else
       
   120         {
       
   121         User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
       
   122             KErrArgument, KErrorUnrecognizedCommand, KHtiMessagesServiceUid ) );
       
   123         }
       
   124 
       
   125     HTI_LOG_FUNC_OUT( "CHtiMessagesServicePlugin::ProcessMessageL: Done" );
       
   126     }