htiui/HtiServicePlugins/HtiMessagesServicePlugin/src/HtiMessagesServicePlugin.cpp
changeset 2 453d490c84a5
parent 1 753e33780645
child 3 6952856dc269
equal deleted inserted replaced
1:753e33780645 2:453d490c84a5
     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 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
    26 #include "HtiNotificationHandler.h"
       
    27 #endif
       
    28 
       
    29 #include <HtiDispatcherInterface.h>
       
    30 #include <HtiLogging.h>
       
    31 
       
    32 // CONSTANTS
       
    33 _LIT8( KErrorMissingCommand, "Command was not given - message was empty" );
       
    34 _LIT8( KErrorUnrecognizedCommand, "Unrecognized command" );
       
    35 
       
    36 // ----------------------------------------------------------------------------
       
    37 // Create instance of concrete ECOM interface implementation
       
    38 CHtiMessagesServicePlugin* CHtiMessagesServicePlugin::NewL()
       
    39     {
       
    40     CHtiMessagesServicePlugin* self = new (ELeave) CHtiMessagesServicePlugin;
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop();
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ----------------------------------------------------------------------------
       
    48 CHtiMessagesServicePlugin::CHtiMessagesServicePlugin()
       
    49     {
       
    50     }
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 CHtiMessagesServicePlugin::~CHtiMessagesServicePlugin()
       
    54     {
       
    55     HTI_LOG_TEXT( "CHtiMessagesServicePlugin destroy" );
       
    56     delete iMessageHandler;
       
    57     delete iIAPHandler;
       
    58     delete iMailboxHandler;
       
    59     delete iMsgSettingsHandler;
       
    60 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
    61     delete iNotificationHandler;
       
    62 #endif
       
    63     }
       
    64 
       
    65 // ----------------------------------------------------------------------------
       
    66 void CHtiMessagesServicePlugin::ConstructL()
       
    67     {
       
    68     HTI_LOG_TEXT( "CHtiMessagesServicePlugin::ConstructL" );
       
    69 
       
    70     }
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 void CHtiMessagesServicePlugin::ProcessMessageL( const TDesC8& aMessage,
       
    74     THtiMessagePriority aPriority)
       
    75     {
       
    76     HTI_LOG_FUNC_IN( "CHtiMessagesServicePlugin::ProcessMessageL" );
       
    77     HTI_LOG_FORMAT( "Msg len: %d.", aMessage.Length() );
       
    78 
       
    79     if ( aMessage.Length() == 0 )
       
    80         {
       
    81         User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
       
    82             KErrArgument, KErrorMissingCommand, KHtiMessagesServiceUid ) );
       
    83         return;
       
    84         }
       
    85 
       
    86     TUint8 command = aMessage.Ptr()[0];
       
    87 
       
    88     if ( command >= EAddSms && command <= EDeleteFolderContent )
       
    89         {
       
    90         if ( !iMessageHandler )
       
    91             {
       
    92             iMessageHandler = CMessageMgmntHandler::NewL();
       
    93             iMessageHandler->SetDispatcher( iDispatcher );
       
    94             }
       
    95         iMessageHandler->ProcessMessageL( aMessage, aPriority );
       
    96         }
       
    97     else if ( command >= ECreateMailBox && command <= EDeleteMailBox  )
       
    98         {
       
    99         if ( !iMailboxHandler )
       
   100             {
       
   101             iMailboxHandler = CHtiMailboxHandler::NewL();
       
   102             iMailboxHandler->SetDispatcher( iDispatcher );
       
   103             }
       
   104         iMailboxHandler->ProcessMessageL( aMessage, aPriority );
       
   105         }
       
   106     else if ( command >= ECreateIAP && command <= ESetDefaultConnection )
       
   107         {
       
   108         if ( !iIAPHandler )
       
   109             {
       
   110             iIAPHandler = CHtiIAPHandler::NewL();
       
   111             iIAPHandler->SetDispatcher( iDispatcher );
       
   112             }
       
   113         iIAPHandler->ProcessMessageL( aMessage, aPriority );
       
   114         }
       
   115 
       
   116     else if ( command >= ESetDefaultSmsCenter && command <= ESetMmsSettings )
       
   117         {
       
   118         if ( !iMsgSettingsHandler )
       
   119             {
       
   120             iMsgSettingsHandler = CHtiMsgSettingsHandler::NewL();
       
   121             iMsgSettingsHandler->SetDispatcher( iDispatcher );
       
   122             }
       
   123         iMsgSettingsHandler->ProcessMessageL( aMessage, aPriority );
       
   124         }
       
   125 
       
   126 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
   127     else if ( command >= ECreateVoiceMessageNotification && command <= EClearAllNotifications)
       
   128         {
       
   129         if( !iNotificationHandler )
       
   130             {
       
   131             iNotificationHandler = CHtiNotificationHandler::NewL();
       
   132             iNotificationHandler->SetDispatcher(iDispatcher);
       
   133             }
       
   134         iNotificationHandler->ProcessMessageL( aMessage, aPriority );
       
   135         }
       
   136 #endif
       
   137 
       
   138     else
       
   139         {
       
   140         User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
       
   141             KErrArgument, KErrorUnrecognizedCommand, KHtiMessagesServiceUid ) );
       
   142         }
       
   143 
       
   144     HTI_LOG_FUNC_OUT( "CHtiMessagesServicePlugin::ProcessMessageL: Done" );
       
   145     }