emailservices/emailframework/src/CFSMailClient.cpp
changeset 56 15bc1d5d6267
parent 51 d845db10c0d4
child 62 a8c646b56683
--- a/emailservices/emailframework/src/CFSMailClient.cpp	Fri Jul 09 12:17:13 2010 +0300
+++ b/emailservices/emailframework/src/CFSMailClient.cpp	Fri Jul 23 19:09:50 2010 +0300
@@ -37,24 +37,28 @@
 {
     NM_FUNCTION;
 
-	CFSMailClient* client = Instance();
-	if(!client)
-	{
-		client = new (ELeave) CFSMailClient();
-		CleanupStack:: PushL(client);
-		client->ConstructL(aConfiguration);
-		TInt err = Dll::SetTls(static_cast<TAny*>(client));
-		User::LeaveIfError(err);
-		}
-	else
-		{
-		CleanupStack:: PushL(client);
-		}
+    CFSMailClient* client = Instance();
+    if( !client )
+        {
+        client = new (ELeave) CFSMailClient();
+        // The new client needs to be deleted rather than closed, up until
+        // the TLS has been set properly.
+        CleanupStack::PushL( client );
+        client->ConstructL( aConfiguration );
+        TInt err = Dll::SetTls( static_cast<TAny*>( client ));
+        User::LeaveIfError( err );
+        // Now that the TLS has been set, we no longer want the new client
+        // to be deleted if there's a problem, so pop it off the cleanup
+        // stack (it will be pushed back on for closing below).
+        CleanupStack::Pop( client );
+        }
 
-	client->IncReferenceCount();
-	
-	return client;
-
+    // Increment reference count before calling CleanupClosePushL so that
+    // the reference count is correct if CleanupClosePushL leaves.
+    client->IncReferenceCount();
+    CleanupClosePushL( *client );
+    
+    return client;
 } 
 
 // -----------------------------------------------------------------------------
@@ -138,6 +142,19 @@
 }
 
 // -----------------------------------------------------------------------------
+// CFSMailClient::GetMailBoxByUidLC
+// -----------------------------------------------------------------------------
+EXPORT_C CFSMailBox* CFSMailClient::GetMailBoxByUidLC(const TFSMailMsgId aMailBoxId)
+{
+    NM_FUNCTION;
+    CFSMailBox* mailBox = GetMailBoxByUidL( aMailBoxId );
+    CleanupStack::PushL( mailBox );
+    return mailBox;
+}
+
+
+
+// -----------------------------------------------------------------------------
 // CFSMailClient::GetFolderByUidL
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolder* CFSMailClient::GetFolderByUidL( const TFSMailMsgId aMailBoxId,
@@ -559,7 +576,23 @@
 		plugin->SetMailboxName( aMailboxId, aMailboxName );
 		}
 	}
-	
+
+// -----------------------------------------------------------------------------
+// CFSMailClient::PrepareMrDescriptionL
+// -----------------------------------------------------------------------------
+EXPORT_C void CFSMailClient::PrepareMrDescriptionL(  const TFSMailMsgId& aMailBoxId,
+                                                     const TFSMailMsgId& aMessageId )
+    {
+    NM_FUNCTION;
+    // select plugin
+    CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid( aMessageId );
+    if ( plugin )
+        {
+        // set MR description from the plugin
+        plugin->PrepareMrDescriptionL( aMailBoxId, aMessageId );
+        }  
+    }
+
 // -----------------------------------------------------------------------------
 // CFSMailClient::Close
 // -----------------------------------------------------------------------------