hti/HtiFramework/src/HtiDispatcher.cpp
changeset 13 33016869e0dd
parent 0 a03f92240627
child 17 67c6ff54ec25
child 21 f5d4820de50d
--- a/hti/HtiFramework/src/HtiDispatcher.cpp	Tue Feb 02 01:57:15 2010 +0200
+++ b/hti/HtiFramework/src/HtiDispatcher.cpp	Fri Apr 16 16:37:27 2010 +0300
@@ -20,10 +20,10 @@
 #include "HtiDispatcher.h"
 #include "HtiMessage.h"
 #include "HtiMessageQueue.h"
-#include "HTILogging.h"
+#include "HtiLogging.h"
 #include "HtiCommAdapter.h"
-#include "HTIServicePluginInterface.h"
-#include "HTICommPluginInterface.h"
+#include "HtiServicePluginInterface.h"
+#include "HtiCommPluginInterface.h"
 #include "HtiSecurityManager.h"
 #include "HtiVersion.h"
 
@@ -113,7 +113,7 @@
 *
 **************************************************************************/
 CHtiDispatcher::CHtiDispatcher( TInt aMaxQueueMemorySize,
-                                TBool aShowErrorDialogs ):
+        TInt aReconnectDelay, TBool aShowErrorDialogs ):
     iIdleActive( EFalse ),
     iMaxQueueMemorySize( aMaxQueueMemorySize > 0 ?
                          aMaxQueueMemorySize : KDefaultMaxQueueSize ),
@@ -122,7 +122,8 @@
     iConsole( NULL ),
     iIdleOverCommAdapter( EFalse ),
     iHtiInstanceId( 0 ),
-    iShowErrorDialogs( aShowErrorDialogs )
+    iShowErrorDialogs( aShowErrorDialogs ),
+    iReconnectDelay (aReconnectDelay)
     {
     HTI_LOG_FORMAT( "MaxQueueMemorySize %d", iMaxQueueMemorySize );
     iQueueSizeLowThresold = ( iMaxQueueMemorySize / 2 ) / 2;
@@ -256,11 +257,12 @@
 CHtiDispatcher* CHtiDispatcher::NewLC( const TDesC8& aCommPlugin,
                                 TInt aMaxMsgSize,
                                 TInt aMaxQueueMemory,
+                                TInt aReconnectDelay,
                                 TBool aShowConsole,
                                 TBool aShowErrorDialogs )
     {
     CHtiDispatcher* obj = new (ELeave) CHtiDispatcher(
-            aMaxQueueMemory, aShowErrorDialogs );
+            aMaxQueueMemory, aReconnectDelay,aShowErrorDialogs );
     CleanupStack::PushL( obj );
     obj->ConstructL( aCommPlugin, aMaxMsgSize, aShowConsole );
     return obj;
@@ -269,11 +271,12 @@
 CHtiDispatcher* CHtiDispatcher::NewL( const TDesC8& aCommPlugin,
                                 TInt aMaxMsgSize,
                                 TInt aMaxQueueMemory,
+                                TInt aReconnectDelay,
                                 TBool aShowConsole,
                                 TBool aShowErrorDialogs )
     {
     CHtiDispatcher* obj = NewLC( aCommPlugin, aMaxMsgSize, aMaxQueueMemory,
-            aShowConsole, aShowErrorDialogs );
+            aReconnectDelay,aShowConsole, aShowErrorDialogs );
     CleanupStack::Pop();
     return obj;
     }
@@ -1240,3 +1243,25 @@
         }
     return mappedUid;
     }
+
+TBool CHtiDispatcher::CommReconnect()
+    {
+    if(iReconnectDelay == 0)
+        {
+        return EFalse;
+        }
+    
+    //Delay
+    HTI_LOG_FORMAT( "Reconnect deley : %d seconds", iReconnectDelay);
+    User::After(iReconnectDelay * 1000 * 1000);
+    
+    //Reconnect
+    iIncomingQueue->RemoveAll();
+    iOutgoingQueue->RemoveAll();
+    
+    iListener->Reset();
+    iSender->Reset();
+    iListener->ReceiveMessage();
+
+    return ETrue;
+    }