emailservices/emailframework/src/CFSMailClient.cpp
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 65 478bc57ad291
equal deleted inserted replaced
54:997a02608b3a 59:16ed8d08d0b1
    35 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    36 EXPORT_C CFSMailClient* CFSMailClient::NewLC(TInt aConfiguration)
    36 EXPORT_C CFSMailClient* CFSMailClient::NewLC(TInt aConfiguration)
    37 {
    37 {
    38     NM_FUNCTION;
    38     NM_FUNCTION;
    39 
    39 
    40 	CFSMailClient* client = Instance();
    40     CFSMailClient* client = Instance();
    41 	if(!client)
    41     if( !client )
    42 	{
    42         {
    43 		client = new (ELeave) CFSMailClient();
    43         client = new (ELeave) CFSMailClient();
    44 		CleanupStack:: PushL(client);
    44         // The new client needs to be deleted rather than closed, up until
    45 		client->ConstructL(aConfiguration);
    45         // the TLS has been set properly.
    46 		TInt err = Dll::SetTls(static_cast<TAny*>(client));
    46         CleanupStack::PushL( client );
    47 		User::LeaveIfError(err);
    47         client->ConstructL( aConfiguration );
    48 		}
    48         TInt err = Dll::SetTls( static_cast<TAny*>( client ));
    49 	else
    49         User::LeaveIfError( err );
    50 		{
    50         // Now that the TLS has been set, we no longer want the new client
    51 		CleanupStack:: PushL(client);
    51         // to be deleted if there's a problem, so pop it off the cleanup
    52 		}
    52         // stack (it will be pushed back on for closing below).
    53 
    53         CleanupStack::Pop( client );
    54 	client->IncReferenceCount();
    54         }
    55 	
    55 
    56 	return client;
    56     // Increment reference count before calling CleanupClosePushL so that
    57 
    57     // the reference count is correct if CleanupClosePushL leaves.
       
    58     client->IncReferenceCount();
       
    59     CleanupClosePushL( *client );
       
    60     
       
    61     return client;
    58 } 
    62 } 
    59 
    63 
    60 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    61 // CFSMailClient::NewL
    65 // CFSMailClient::NewL
    62 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
   134 		mailBox = plugin->GetMailBoxByUidL(aMailBoxId);
   138 		mailBox = plugin->GetMailBoxByUidL(aMailBoxId);
   135 	}
   139 	}
   136 
   140 
   137 	return mailBox;
   141 	return mailBox;
   138 }
   142 }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CFSMailClient::GetMailBoxByUidLC
       
   146 // -----------------------------------------------------------------------------
       
   147 EXPORT_C CFSMailBox* CFSMailClient::GetMailBoxByUidLC(const TFSMailMsgId aMailBoxId)
       
   148 {
       
   149     NM_FUNCTION;
       
   150     CFSMailBox* mailBox = GetMailBoxByUidL( aMailBoxId );
       
   151     CleanupStack::PushL( mailBox );
       
   152     return mailBox;
       
   153 }
       
   154 
       
   155 
   139 
   156 
   140 // -----------------------------------------------------------------------------
   157 // -----------------------------------------------------------------------------
   141 // CFSMailClient::GetFolderByUidL
   158 // CFSMailClient::GetFolderByUidL
   142 // -----------------------------------------------------------------------------
   159 // -----------------------------------------------------------------------------
   143 EXPORT_C CFSMailFolder* CFSMailClient::GetFolderByUidL( const TFSMailMsgId aMailBoxId,
   160 EXPORT_C CFSMailFolder* CFSMailClient::GetFolderByUidL( const TFSMailMsgId aMailBoxId,
   252 				    mailBox = NULL;
   269 				    mailBox = NULL;
   253 				    TRAP_IGNORE(
   270 				    TRAP_IGNORE(
   254                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[ii]) );
   271                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[ii]) );
   255 				    if ( mailBox )
   272 				    if ( mailBox )
   256     				    {
   273     				    {
   257                         aMailBoxes.Append( mailBox );
   274                         err = aMailBoxes.Append( mailBox );
   258                         }
   275                         }
   259 				// </cmail>
   276 				// </cmail>
   260 					if(err != KErrNone)
   277 					if(err != KErrNone)
   261 					{
   278 					{
   262 						ret = err;
   279 						ret = err;
   292                     mailBox = NULL;
   309                     mailBox = NULL;
   293 				    TRAP_IGNORE(
   310 				    TRAP_IGNORE(
   294                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[i]) );
   311                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[i]) );
   295                     if ( mailBox )
   312                     if ( mailBox )
   296                         {
   313                         {
   297                         aMailBoxes.Append( mailBox );
   314                         err = aMailBoxes.Append( mailBox );
   298                         }
   315                         }
   299                 // </cmail>				
   316                 // </cmail>				
   300 				if(err != KErrNone)
   317 				if(err != KErrNone)
   301 				    {
   318 				    {
   302 					ret = err;
   319 					ret = err;
   557 	if ( plugin )
   574 	if ( plugin )
   558 		{
   575 		{
   559 		plugin->SetMailboxName( aMailboxId, aMailboxName );
   576 		plugin->SetMailboxName( aMailboxId, aMailboxName );
   560 		}
   577 		}
   561 	}
   578 	}
   562 	
   579 
       
   580 // -----------------------------------------------------------------------------
       
   581 // CFSMailClient::PrepareMrDescriptionL
       
   582 // -----------------------------------------------------------------------------
       
   583 EXPORT_C void CFSMailClient::PrepareMrDescriptionL(  const TFSMailMsgId& aMailBoxId,
       
   584                                                      const TFSMailMsgId& aMessageId )
       
   585     {
       
   586     NM_FUNCTION;
       
   587     // select plugin
       
   588     CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid( aMessageId );
       
   589     if ( plugin )
       
   590         {
       
   591         // set MR description from the plugin
       
   592         plugin->PrepareMrDescriptionL( aMailBoxId, aMessageId );
       
   593         }  
       
   594     }
       
   595 
   563 // -----------------------------------------------------------------------------
   596 // -----------------------------------------------------------------------------
   564 // CFSMailClient::Close
   597 // CFSMailClient::Close
   565 // -----------------------------------------------------------------------------
   598 // -----------------------------------------------------------------------------
   566 EXPORT_C void CFSMailClient::Close()
   599 EXPORT_C void CFSMailClient::Close()
   567 {
   600 {