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