emailservices/emailclientapi/src/emailinterfacefactoryimpl.cpp
branchRCL_3
changeset 25 3533d4323edc
parent 24 d189ee25cf9d
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 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 //
    36 void Panic( TEmailImplPanic aPanic )
    37 void Panic( TEmailImplPanic aPanic )
    37     {
    38     {
    38     User::Panic( KEmailImplPanic(), aPanic );
    39     User::Panic( KEmailImplPanic(), aPanic );
    39     }
    40     }
    40 
    41     
    41 // ======== MEMBER FUNCTIONS ========
    42 // ======== MEMBER FUNCTIONS ========
    42 
    43 
    43 // ---------------------------------------------------------------------------
    44 // ---------------------------------------------------------------------------
    44 // CEmailInterfaceFactoryImpl::NewL
    45 // CEmailInterfaceFactoryImpl::NewL
    45 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
       
    47 //
    46 CEmailInterfaceFactoryImpl* CEmailInterfaceFactoryImpl::NewL()
    48 CEmailInterfaceFactoryImpl* CEmailInterfaceFactoryImpl::NewL()
    47     {
    49     {
    48     CEmailInterfaceFactoryImpl* self = new (ELeave) CEmailInterfaceFactoryImpl();
    50     CEmailInterfaceFactoryImpl* self = new (ELeave) CEmailInterfaceFactoryImpl();
    49     CleanupStack::PushL( self );
    51     CleanupStack::PushL( self );
    50     self->ConstructL();
    52     self->ConstructL();
    51     CleanupStack::Pop( self );
    53     CleanupStack::Pop( self );
    52     return self;
    54     return self;
    53     }
    55     }
    54 
    56     
    55 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    56 // CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl
    58 // CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl
    57 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
       
    60 //
    58 CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl()
    61 CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl()
    59     {
    62     {
    60     TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeRemove ) );
    63     TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeRemove ) );
    61     }
    64     }
    62 
    65 
    63 // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
    64 // CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl
    67 // CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl
    65 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
       
    69 //
    66 CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl() : 
    70 CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl() : 
    67     CEmailInterfaceFactory()
    71     CEmailInterfaceFactory()
    68     {
    72     {
    69     }
    73     }
    70 
    74 
    71 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    72 // CEmailInterfaceFactoryImpl::ConstructL
    76 // CEmailInterfaceFactoryImpl::ConstructL
    73 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
       
    78 //
    74 void CEmailInterfaceFactoryImpl::ConstructL()
    79 void CEmailInterfaceFactoryImpl::ConstructL()
    75     {
    80     {
    76 	// This leaves if related P&S keys are not defined by EmailServerMonitor,
    81 	// This leaves if related P&S keys are not defined by EmailServerMonitor,
    77 	// so EmailServerMonitor need to be started before using client API.
    82 	// so EmailServerMonitor need to be started before using client API.
    78 	// TRAP_IGNORE should be removed after EmailServerMonitor is added to
    83 	// TRAP_IGNORE should be removed after EmailServerMonitor is added to
    81     }
    86     }
    82 
    87 
    83 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    84 // CEmailInterfaceFactoryImpl::InterfaceL
    89 // CEmailInterfaceFactoryImpl::InterfaceL
    85 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
       
    91 //
    86 MEmailInterface* CEmailInterfaceFactoryImpl::InterfaceL( const TInt aInterfaceId )
    92 MEmailInterface* CEmailInterfaceFactoryImpl::InterfaceL( const TInt aInterfaceId )
    87     {
    93     {
    88     MEmailInterface* interface = NULL;
    94     MEmailInterface* interface = NULL;
    89     switch ( aInterfaceId )
    95     switch ( aInterfaceId )
    90         {
    96         {
    91         case KEmailClientApiInterface:
    97         case KEmailClientApiInterface:
    92             interface = CEmailClientApi::NewL();
    98             interface = CEmailClientApi::NewL();
    93             break;
    99             break;
       
   100         case KEmailIFUidTextContent:
       
   101             //interface = CEmailTextContent::NewL();
       
   102             break;
    94         case KEmailIFUidAddress:
   103         case KEmailIFUidAddress:
    95             interface = CEmailAddress::NewL( MEmailAddress::EUndefined, EClientOwns );
   104             interface = CEmailAddress::NewL( MEmailAddress::EUndefined, EClientOwns );
    96             break;
       
    97         case KEmailIFUidTextContent:
       
    98         default:
   105         default:
    99             break;
   106             break;
   100         }
   107         }
   101     if ( !interface )
   108     if ( !interface )
   102         {
   109         {
   106     }
   113     }
   107 
   114 
   108 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   109 // CEmailInterfaceFactoryImpl::AppendOrRemoveUidL
   116 // CEmailInterfaceFactoryImpl::AppendOrRemoveUidL
   110 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
       
   118 //
   111 void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL(
   119 void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL(
   112         const TEmailUidAppendRemoveMode aMode )
   120         const TEmailUidAppendRemoveMode aMode )
   113     {
   121     {
   114     // Read buffer length
   122     // Read buffer length
   115     TInt bufLength( 0 );
   123     TInt bufLength( 0 );
   176             {
   184             {
   177             writeStream.WriteInt32L( item.iUid );
   185             writeStream.WriteInt32L( item.iUid );
   178             writeLength += KEmailPlatformApiUidItemSize;
   186             writeLength += KEmailPlatformApiUidItemSize;
   179             }
   187             }
   180         }
   188         }
   181 
   189     
   182     // If we are appending our UID and it wasn't found from the list,
   190     // If we are appending our UID and it wasn't found from the list,
   183     // write it to the stream
   191     // write it to the stream
   184     if( aMode == EEmailUidModeAppend && !ownUidFound )
   192     if( aMode == EEmailUidModeAppend && !ownUidFound )
   185         {
   193         {
   186         writeStream.WriteInt32L( ownUid.iUid );
   194         writeStream.WriteInt32L( ownUid.iUid );
   207 
   215 
   208         User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
   216         User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
   209                         EEmailPsKeyPlatformApiAppsToCloseLength,
   217                         EEmailPsKeyPlatformApiAppsToCloseLength,
   210                         writeLength ) );
   218                         writeLength ) );
   211         }
   219         }
   212 
   220     
   213     CleanupStack::PopAndDestroy( 4, readBuf );
   221     CleanupStack::PopAndDestroy( 4, readBuf );
   214     }
   222     }
   215 
   223 
   216 // End of file
   224 // End of file.