htiui/HtiServicePlugins/HtiPIMServicePlugin/src/HtiPIMServicePlugin.cpp
changeset 0 d6fe6244b863
child 11 454d022d514b
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:  PIMServicePlugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "HtiPIMServicePlugin.h"
       
    21 #include "PIMHandler.h"
       
    22 #include "HtiBookmarkHandler.h"
       
    23 #include "HtiSimDirHandlerVPbk.h"
       
    24 
       
    25 #include <HtiDispatcherInterface.h>
       
    26 #include <HTILogging.h>
       
    27 
       
    28 // CONSTANTS
       
    29 _LIT8( KErrorMissingCommand, "Command was not given - message was empty" );
       
    30 
       
    31 // ----------------------------------------------------------------------------
       
    32 // Create instance of concrete ECOM interface implementation
       
    33 CHtiPIMServicePlugin* CHtiPIMServicePlugin::NewL()
       
    34     {
       
    35     CHtiPIMServicePlugin* self = new (ELeave) CHtiPIMServicePlugin;
       
    36     CleanupStack::PushL( self );
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop();
       
    39     return self;
       
    40     }
       
    41 
       
    42 // ----------------------------------------------------------------------------
       
    43 CHtiPIMServicePlugin::CHtiPIMServicePlugin()
       
    44     {
       
    45     }
       
    46 
       
    47 // ----------------------------------------------------------------------------
       
    48 CHtiPIMServicePlugin::~CHtiPIMServicePlugin()
       
    49     {
       
    50     HTI_LOG_TEXT("CHtiPIMServicePlugin destroy");
       
    51     delete iPimHandler;
       
    52     delete iBookmarkHandler;
       
    53     delete iSimDirHandler;
       
    54     }
       
    55 
       
    56 // ----------------------------------------------------------------------------
       
    57 void CHtiPIMServicePlugin::ConstructL()
       
    58     {
       
    59     HTI_LOG_TEXT("CHtiPIMServicePlugin::ConstructL");
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 void CHtiPIMServicePlugin::ProcessMessageL( const TDesC8& aMessage,
       
    64     THtiMessagePriority aPriority )
       
    65     {
       
    66     HTI_LOG_FUNC_IN( "CHtiPIMServicePlugin::ProcessMessageL" );
       
    67     HTI_LOG_FORMAT( "Msg len: %d.", aMessage.Length() );
       
    68 
       
    69     if ( aMessage.Length() == 0 )
       
    70         {
       
    71         User::LeaveIfError( iDispatcher->DispatchOutgoingErrorMessage(
       
    72             KErrArgument, KErrorMissingCommand, KPIMServiceUid ) );
       
    73         return;
       
    74         }
       
    75 
       
    76     TUint8 aCommand = aMessage.Ptr()[0];
       
    77     if ( aCommand < ESimCardInfo )
       
    78         {
       
    79         if ( iPimHandler == NULL )
       
    80             {
       
    81             iPimHandler = CPIMHandler::NewL();
       
    82             iPimHandler->SetDispatcher( iDispatcher );
       
    83             }
       
    84         iPimHandler->ProcessMessageL( aMessage, aPriority );
       
    85         }
       
    86     else if ( aCommand < ECreateBookmark )
       
    87         {
       
    88         if ( iSimDirHandler == NULL )
       
    89             {
       
    90             iSimDirHandler = CHtiSimDirHandlerVPbk::NewL();
       
    91             iSimDirHandler->SetDispatcher( iDispatcher );
       
    92             }
       
    93         iSimDirHandler->ProcessMessageL( aMessage, aPriority );
       
    94         }
       
    95     else
       
    96         {
       
    97         if ( iBookmarkHandler == NULL )
       
    98             {
       
    99             iBookmarkHandler = CHtiBookmarkHandler::NewL();
       
   100             iBookmarkHandler->SetDispatcher( iDispatcher );
       
   101             }
       
   102         iBookmarkHandler->ProcessMessageL( aMessage, aPriority );
       
   103         }
       
   104 
       
   105     HTI_LOG_FUNC_OUT( "CHtiPIMServicePlugin::ProcessMessageL" );
       
   106     }
       
   107 
       
   108 
       
   109 // ----------------------------------------------------------------------------
       
   110 TBool CHtiPIMServicePlugin::IsBusy()
       
   111     {
       
   112     if ( iPimHandler )
       
   113         {
       
   114         if ( iPimHandler->IsBusy() )
       
   115             return ETrue;
       
   116         }
       
   117     if ( iSimDirHandler )
       
   118         {
       
   119         if ( iSimDirHandler->IsBusy() )
       
   120             return ETrue;
       
   121         }
       
   122     if ( iBookmarkHandler )
       
   123         {
       
   124         if ( iBookmarkHandler->IsBusy() )
       
   125             return ETrue;
       
   126         }
       
   127     return EFalse;
       
   128     }