emailservices/emailframework/src/CFSClientAPIRequestHandler.cpp
branchRCL_3
changeset 13 0396474f30f5
parent 8 e1b6206813b4
child 16 4ce476e64c59
--- a/emailservices/emailframework/src/CFSClientAPIRequestHandler.cpp	Fri Mar 12 15:41:14 2010 +0200
+++ b/emailservices/emailframework/src/CFSClientAPIRequestHandler.cpp	Mon Mar 15 12:39:10 2010 +0200
@@ -26,24 +26,53 @@
 // CFSMailRequestHandler::CFSMailRequestHandler
 // -----------------------------------------------------------------------------
 CFSClientAPIRequestHandler::CFSClientAPIRequestHandler(  
-    MEmailClientPluginManager* aPluginManager ) : iPluginManager(aPluginManager)
+    MEmailClientPluginManager* aPluginManager ) : iPluginManager(aPluginManager), iInstanceCounter( 1 )
 {
     FUNC_LOG;
-
-	// store pointer to TLS
-	TInt err = Dll::SetTls(static_cast<TAny*>(this));
 }
 
 // -----------------------------------------------------------------------------
 // CFSMailRequestHandler::~CFSMailRequestHandler
 // -----------------------------------------------------------------------------
-
 CFSClientAPIRequestHandler::~CFSClientAPIRequestHandler()
     {
     FUNC_LOG;
     }
 
 // -----------------------------------------------------------------------------
+// CFSMailRequestHandler::GetInstanceL
+// -----------------------------------------------------------------------------
+CFSClientAPIRequestHandler* CFSClientAPIRequestHandler::GetInstanceL( MEmailClientPluginManager* aPluginManager )
+    {
+    CFSClientAPIRequestHandler *requestHandler = static_cast<CFSClientAPIRequestHandler*>( Dll::Tls() );
+    if ( requestHandler == NULL )
+        {
+        requestHandler = CFSClientAPIRequestHandler::NewL( aPluginManager );
+        }
+    else
+        {
+        requestHandler->iInstanceCounter++;
+        }
+	
+    return requestHandler;
+    }
+
+// -----------------------------------------------------------------------------
+// CFSMailRequestHandler::ReleaseInstance
+// -----------------------------------------------------------------------------
+void CFSClientAPIRequestHandler::ReleaseInstance()
+    {
+    if( iInstanceCounter > 1 )
+        {
+        iInstanceCounter--;
+        }
+    else
+        {
+        delete this;
+        }
+    }
+
+// -----------------------------------------------------------------------------
 // CFSMailRequestHandler::NewL
 // -----------------------------------------------------------------------------
 CFSClientAPIRequestHandler* CFSClientAPIRequestHandler::NewL(