telephonyserverplugins/common_tsy/commontsy/src/mmcustomtsy/CMmCustomTsy.cpp
changeset 20 244d7c5f118e
parent 19 1f776524b15c
child 23 6b1d113cdff3
--- a/telephonyserverplugins/common_tsy/commontsy/src/mmcustomtsy/CMmCustomTsy.cpp	Fri Mar 19 09:55:57 2010 +0200
+++ b/telephonyserverplugins/common_tsy/commontsy/src/mmcustomtsy/CMmCustomTsy.cpp	Fri Apr 16 16:12:37 2010 +0300
@@ -40,7 +40,8 @@
 
 // ======== MEMBER FUNCTIONS ========
 
-CMmCustomTsy::CMmCustomTsy()
+CMmCustomTsy::CMmCustomTsy():
+    iReqHandleType(ECustomTsyReqHandleUnknown)
     {
     iMmPhoneTsy = NULL;
     iMmCustomExtInterface = NULL;
@@ -141,7 +142,7 @@
 CMmCustomTsy::~CMmCustomTsy()
     {
 TFLOGSTRING("TSY: CMmCustomTsy::~CMmCustomTsy");
-    iMmPhoneTsy->SetHomeZoneParamsChecked( EFalse );
+
 	iFeatureControl.Close();
 	
     // Delete subsystems
@@ -150,34 +151,19 @@
         delete iMmSubTsy[i];
         }
 
-    if ( iMmSecurityTsy )
-        {
-        // Delete SecurityTsy
-        delete iMmSecurityTsy;
-        }
-
-    if ( iMmCustomExtInterface )
-        {
-        // Delete GSM extensions
-        delete iMmCustomExtInterface;
-        }
-
-    if ( iTsyReqHandleStore )
-        {
-        // delete req handle store
-        delete iTsyReqHandleStore;
-        }
-
-    iMmSecurityTsy = NULL;
-    iMmCustomExtInterface = NULL;
-    iTsyReqHandleStore = NULL;
-    iISVDialNumberCheckObject = NULL;
-    iCFISCentRep = NULL;
+    // Delete SecurityTsy
+    delete iMmSecurityTsy;
+
+    // Delete GSM extensions
+    delete iMmCustomExtInterface;
+    
+    // delete req handle store
+    delete iTsyReqHandleStore;
 
     if ( iMmPhoneTsy )
         {
+        iMmPhoneTsy->SetHomeZoneParamsChecked( EFalse );
         iMmPhoneTsy->SetCustomTsy( NULL );
-
         // unregister custom tsy in the message manager
         iMmPhoneTsy->MessageManager()->DeregisterTsyObject(this);
         }
@@ -211,7 +197,14 @@
     {
     TInt ret = KErrNone;
     TInt trapError = KErrNone;
-    iReqHandleType = ECustomTsyReqHandleUnknown;
+    
+    // Ensure the ReqHandleType is unset.
+    // This will detect cases where this method indirectly calls itself
+    // (e.g. servicing a client call that causes a self-reposting notification to complete and thus repost).
+    // Such cases are not supported because iReqHandleType is in the context of this class instance,
+    // not this request, and we don't want the values set by the inner request and the outer request
+    // interfering with each other.
+    __ASSERT_DEBUG(iReqHandleType==ECustomTsyReqHandleUnknown, User::Invariant());
 
     // before processing further the request, check if offline mode status
     // is enabled and if the given request can be perfomed in that case.
@@ -272,9 +265,14 @@
         // if extension modules did not serve this request
         if ( KErrNotSupported == ret )
             {
-            // reset last tsy request type
-            iReqHandleType = ECustomTsyReqHandleUnknown;
-
+            // Ensure the ReqHandleType is unset.
+            // This will detect cases where this method indirectly calls itself
+            // (e.g. servicing a client call that causes a self-reposting notification to complete and thus repost).
+            // Such cases are not supported because iReqHandleType is in the context of this class instance,
+            // not this request, and we don't want the values set by the inner request and the outer request
+            // interfering with each other.
+            __ASSERT_DEBUG(iReqHandleType==ECustomTsyReqHandleUnknown, User::Invariant());
+            
             switch ( aIpc )
                 {
                 // Perform IMS Authentication
@@ -560,6 +558,9 @@
                 iTsyReqHandleStore->SetTsyReqHandle( iReqHandleType,
                     aTsyReqHandle );
 #endif // REQHANDLE_TIMER
+                // We've finished with this value now. Clear it so it doesn't leak
+                //  up to any other instances of this method down the call stack
+                iReqHandleType = ECustomTsyReqHandleUnknown;
                 }
             }
         }