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