emailservices/emailclientapi/src/emailinterfacefactoryimpl.cpp
branchRCL_3
changeset 24 d189ee25cf9d
parent 8 e1b6206813b4
child 25 3533d4323edc
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 #include <e32property.h>                // RProperty
    18 #include <e32property.h>                // RProperty
    19 #include <s32mem.h>                     // RDesRead/WriteStream
    19 #include <s32mem.h>                     // RDesRead/WriteStream
    20 
    20 
    21 #include "emailinterfacefactoryimpl.h"
    21 #include "emailinterfacefactoryimpl.h"
    22 #include "emailcontent.h"
    22 #include "emailcontent.h"
    23 #include "cfsmailclient.h"
    23 #include "CFSMailClient.h"
    24 #include "emailclientapiimpldefs.h"
    24 #include "emailclientapiimpldefs.h"
    25 #include "emailclientapiimpl.h"
    25 #include "emailclientapiimpl.h"
    26 #include "emailaddress.h"
    26 #include "emailaddress.h"
    27 #include "emailmessagesearch.h"
    27 #include "emailmessagesearch.h"
    28 #include "emailshutdownconst.h"
    28 #include "emailshutdownconst.h"
    31 const TInt KEmailUidExtraBuffer = 2 * KEmailPlatformApiUidItemSize;
    31 const TInt KEmailUidExtraBuffer = 2 * KEmailPlatformApiUidItemSize;
    32 
    32 
    33 // ---------------------------------------------------------------------------
    33 // ---------------------------------------------------------------------------
    34 // Email client API panic wrapper
    34 // Email client API panic wrapper
    35 // ---------------------------------------------------------------------------
    35 // ---------------------------------------------------------------------------
    36 //
       
    37 void Panic( TEmailImplPanic aPanic )
    36 void Panic( TEmailImplPanic aPanic )
    38     {
    37     {
    39     User::Panic( KEmailImplPanic(), aPanic );
    38     User::Panic( KEmailImplPanic(), aPanic );
    40     }
    39     }
    41     
    40 
    42 // ======== MEMBER FUNCTIONS ========
    41 // ======== MEMBER FUNCTIONS ========
    43 
    42 
    44 // ---------------------------------------------------------------------------
    43 // ---------------------------------------------------------------------------
    45 // CEmailInterfaceFactoryImpl::NewL
    44 // CEmailInterfaceFactoryImpl::NewL
    46 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    47 //
       
    48 CEmailInterfaceFactoryImpl* CEmailInterfaceFactoryImpl::NewL()
    46 CEmailInterfaceFactoryImpl* CEmailInterfaceFactoryImpl::NewL()
    49     {
    47     {
    50     CEmailInterfaceFactoryImpl* self = new (ELeave) CEmailInterfaceFactoryImpl();
    48     CEmailInterfaceFactoryImpl* self = new (ELeave) CEmailInterfaceFactoryImpl();
    51     CleanupStack::PushL( self );
    49     CleanupStack::PushL( self );
    52     self->ConstructL();
    50     self->ConstructL();
    53     CleanupStack::Pop( self );
    51     CleanupStack::Pop( self );
    54     return self;
    52     return self;
    55     }
    53     }
    56     
    54 
    57 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    58 // CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl
    56 // CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl
    59 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    60 //
       
    61 CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl()
    58 CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl()
    62     {
    59     {
    63     TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeRemove ) );
    60     TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeRemove ) );
    64     }
    61     }
    65 
    62 
    66 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    67 // CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl
    64 // CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl
    68 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    69 //
       
    70 CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl() : 
    66 CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl() : 
    71     CEmailInterfaceFactory()
    67     CEmailInterfaceFactory()
    72     {
    68     {
    73     }
    69     }
    74 
    70 
    75 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
    76 // CEmailInterfaceFactoryImpl::ConstructL
    72 // CEmailInterfaceFactoryImpl::ConstructL
    77 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    78 //
       
    79 void CEmailInterfaceFactoryImpl::ConstructL()
    74 void CEmailInterfaceFactoryImpl::ConstructL()
    80     {
    75     {
    81 	// This leaves if related P&S keys are not defined by EmailServerMonitor,
    76 	// This leaves if related P&S keys are not defined by EmailServerMonitor,
    82 	// so EmailServerMonitor need to be started before using client API.
    77 	// so EmailServerMonitor need to be started before using client API.
    83 	// TRAP_IGNORE should be removed after EmailServerMonitor is added to
    78 	// TRAP_IGNORE should be removed after EmailServerMonitor is added to
    86     }
    81     }
    87 
    82 
    88 // ---------------------------------------------------------------------------
    83 // ---------------------------------------------------------------------------
    89 // CEmailInterfaceFactoryImpl::InterfaceL
    84 // CEmailInterfaceFactoryImpl::InterfaceL
    90 // ---------------------------------------------------------------------------
    85 // ---------------------------------------------------------------------------
    91 //
       
    92 MEmailInterface* CEmailInterfaceFactoryImpl::InterfaceL( const TInt aInterfaceId )
    86 MEmailInterface* CEmailInterfaceFactoryImpl::InterfaceL( const TInt aInterfaceId )
    93     {
    87     {
    94     MEmailInterface* interface = NULL;
    88     MEmailInterface* interface = NULL;
    95     switch ( aInterfaceId )
    89     switch ( aInterfaceId )
    96         {
    90         {
    97         case KEmailClientApiInterface:
    91         case KEmailClientApiInterface:
    98             interface = CEmailClientApi::NewL();
    92             interface = CEmailClientApi::NewL();
    99             break;
    93             break;
   100         case KEmailIFUidTextContent:
       
   101             //interface = CEmailTextContent::NewL();
       
   102             break;
       
   103         case KEmailIFUidAddress:
    94         case KEmailIFUidAddress:
   104             interface = CEmailAddress::NewL( MEmailAddress::EUndefined, EClientOwns );
    95             interface = CEmailAddress::NewL( MEmailAddress::EUndefined, EClientOwns );
       
    96             break;
       
    97         case KEmailIFUidTextContent:
   105         default:
    98         default:
   106             break;
    99             break;
   107         }
   100         }
   108     if ( !interface )
   101     if ( !interface )
   109         {
   102         {
   113     }
   106     }
   114 
   107 
   115 // ---------------------------------------------------------------------------
   108 // ---------------------------------------------------------------------------
   116 // CEmailInterfaceFactoryImpl::AppendOrRemoveUidL
   109 // CEmailInterfaceFactoryImpl::AppendOrRemoveUidL
   117 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   118 //
       
   119 void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL(
   111 void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL(
   120         const TEmailUidAppendRemoveMode aMode )
   112         const TEmailUidAppendRemoveMode aMode )
   121     {
   113     {
   122     // Read buffer length
   114     // Read buffer length
   123     TInt bufLength( 0 );
   115     TInt bufLength( 0 );
   184             {
   176             {
   185             writeStream.WriteInt32L( item.iUid );
   177             writeStream.WriteInt32L( item.iUid );
   186             writeLength += KEmailPlatformApiUidItemSize;
   178             writeLength += KEmailPlatformApiUidItemSize;
   187             }
   179             }
   188         }
   180         }
   189     
   181 
   190     // If we are appending our UID and it wasn't found from the list,
   182     // If we are appending our UID and it wasn't found from the list,
   191     // write it to the stream
   183     // write it to the stream
   192     if( aMode == EEmailUidModeAppend && !ownUidFound )
   184     if( aMode == EEmailUidModeAppend && !ownUidFound )
   193         {
   185         {
   194         writeStream.WriteInt32L( ownUid.iUid );
   186         writeStream.WriteInt32L( ownUid.iUid );
   215 
   207 
   216         User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
   208         User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
   217                         EEmailPsKeyPlatformApiAppsToCloseLength,
   209                         EEmailPsKeyPlatformApiAppsToCloseLength,
   218                         writeLength ) );
   210                         writeLength ) );
   219         }
   211         }
   220     
   212 
   221     CleanupStack::PopAndDestroy( 4, readBuf );
   213     CleanupStack::PopAndDestroy( 4, readBuf );
   222     }
   214     }
   223 
   215 
   224 // End of file.
   216 // End of file