emailservices/emailframework/src/CFSMailClient.cpp
branchRCL_3
changeset 36 e8f259fad141
parent 8 e1b6206813b4
child 52 efd4f1afd43e
equal deleted inserted replaced
35:e64954c2c8e2 36:e8f259fad141
    31 // -----------------------------------------------------------------------------
    31 // -----------------------------------------------------------------------------
    32 EXPORT_C CFSMailClient* CFSMailClient::NewLC(TInt aConfiguration)
    32 EXPORT_C CFSMailClient* CFSMailClient::NewLC(TInt aConfiguration)
    33 {
    33 {
    34     FUNC_LOG;
    34     FUNC_LOG;
    35 
    35 
    36 	CFSMailClient* client = Instance();
    36     CFSMailClient* client = Instance();
    37 	if(!client)
    37     if( !client )
    38 	{
    38         {
    39 		client = new (ELeave) CFSMailClient();
    39         client = new (ELeave) CFSMailClient();
    40 		CleanupStack:: PushL(client);
    40         // The new client needs to be deleted rather than closed, up until
    41 		client->ConstructL(aConfiguration);
    41         // the TLS has been set properly.
    42 		TInt err = Dll::SetTls(static_cast<TAny*>(client));
    42         CleanupStack::PushL( client );
    43 		User::LeaveIfError(err);
    43         client->ConstructL( aConfiguration );
    44 		}
    44         TInt err = Dll::SetTls( static_cast<TAny*>( client ));
    45 	else
    45         User::LeaveIfError( err );
    46 		{
    46         // Now that the TLS has been set, we no longer want the new client
    47 		CleanupStack:: PushL(client);
    47         // to be deleted if there's a problem, so pop it off the cleanup
    48 		}
    48         // stack (it will be pushed back on for closing below).
    49 
    49         CleanupStack::Pop( client );
    50 	client->IncReferenceCount();
    50         }
    51 	
    51 
    52 	return client;
    52     // Increment reference count before calling CleanupClosePushL so that
    53 
    53     // the reference count is correct if CleanupClosePushL leaves.
       
    54     client->IncReferenceCount();
       
    55     CleanupClosePushL( *client );
       
    56     
       
    57     return client;
    54 } 
    58 } 
    55 
    59 
    56 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    57 // CFSMailClient::NewL
    61 // CFSMailClient::NewL
    58 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------