hti/HtiFramework/src/HtiDispatcher.cpp
branchRCL_3
changeset 7 8a14024f954a
parent 4 73ff0d268e1d
child 12 d27dfa8884ad
equal deleted inserted replaced
6:ecff51f1e7fb 7:8a14024f954a
   111 /*************************************************************************
   111 /*************************************************************************
   112 *   CHtiDispatcher implementation
   112 *   CHtiDispatcher implementation
   113 *
   113 *
   114 **************************************************************************/
   114 **************************************************************************/
   115 CHtiDispatcher::CHtiDispatcher( TInt aMaxQueueMemorySize,
   115 CHtiDispatcher::CHtiDispatcher( TInt aMaxQueueMemorySize,
   116                                 TBool aShowErrorDialogs ):
   116         TInt aReconnectDelay, TBool aShowErrorDialogs ):
   117     iIdleActive( EFalse ),
   117     iIdleActive( EFalse ),
   118     iMaxQueueMemorySize( aMaxQueueMemorySize > 0 ?
   118     iMaxQueueMemorySize( aMaxQueueMemorySize > 0 ?
   119                          aMaxQueueMemorySize : KDefaultMaxQueueSize ),
   119                          aMaxQueueMemorySize : KDefaultMaxQueueSize ),
   120     iToReboot( EFalse ),
   120     iToReboot( EFalse ),
   121     iRfsMode( ERfsUnknown ),
   121     iRfsMode( ERfsUnknown ),
   122     iConsole( NULL ),
   122     iConsole( NULL ),
   123     iIdleOverCommAdapter( EFalse ),
   123     iIdleOverCommAdapter( EFalse ),
   124     iHtiInstanceId( 0 ),
   124     iHtiInstanceId( 0 ),
   125     iShowErrorDialogs( aShowErrorDialogs )
   125     iShowErrorDialogs( aShowErrorDialogs ),
       
   126     iReconnectDelay (aReconnectDelay)
   126     {
   127     {
   127     HTI_LOG_FORMAT( "MaxQueueMemorySize %d", iMaxQueueMemorySize );
   128     HTI_LOG_FORMAT( "MaxQueueMemorySize %d", iMaxQueueMemorySize );
   128     iQueueSizeLowThresold = ( iMaxQueueMemorySize / 2 ) / 2;
   129     iQueueSizeLowThresold = ( iMaxQueueMemorySize / 2 ) / 2;
   129     iQueueSizeHighThresold = ( iMaxQueueMemorySize / 2 ) * 4 / 5;
   130     iQueueSizeHighThresold = ( iMaxQueueMemorySize / 2 ) * 4 / 5;
   130     HTI_LOG_FORMAT( "QueueSizeThresholds low : %d", iQueueSizeLowThresold );
   131     HTI_LOG_FORMAT( "QueueSizeThresholds low : %d", iQueueSizeLowThresold );
   254 
   255 
   255 
   256 
   256 CHtiDispatcher* CHtiDispatcher::NewLC( const TDesC8& aCommPlugin,
   257 CHtiDispatcher* CHtiDispatcher::NewLC( const TDesC8& aCommPlugin,
   257                                 TInt aMaxMsgSize,
   258                                 TInt aMaxMsgSize,
   258                                 TInt aMaxQueueMemory,
   259                                 TInt aMaxQueueMemory,
       
   260                                 TInt aReconnectDelay,
   259                                 TBool aShowConsole,
   261                                 TBool aShowConsole,
   260                                 TBool aShowErrorDialogs )
   262                                 TBool aShowErrorDialogs )
   261     {
   263     {
   262     CHtiDispatcher* obj = new (ELeave) CHtiDispatcher(
   264     CHtiDispatcher* obj = new (ELeave) CHtiDispatcher(
   263             aMaxQueueMemory, aShowErrorDialogs );
   265             aMaxQueueMemory, aReconnectDelay,aShowErrorDialogs );
   264     CleanupStack::PushL( obj );
   266     CleanupStack::PushL( obj );
   265     obj->ConstructL( aCommPlugin, aMaxMsgSize, aShowConsole );
   267     obj->ConstructL( aCommPlugin, aMaxMsgSize, aShowConsole );
   266     return obj;
   268     return obj;
   267     }
   269     }
   268 
   270 
   269 CHtiDispatcher* CHtiDispatcher::NewL( const TDesC8& aCommPlugin,
   271 CHtiDispatcher* CHtiDispatcher::NewL( const TDesC8& aCommPlugin,
   270                                 TInt aMaxMsgSize,
   272                                 TInt aMaxMsgSize,
   271                                 TInt aMaxQueueMemory,
   273                                 TInt aMaxQueueMemory,
       
   274                                 TInt aReconnectDelay,
   272                                 TBool aShowConsole,
   275                                 TBool aShowConsole,
   273                                 TBool aShowErrorDialogs )
   276                                 TBool aShowErrorDialogs )
   274     {
   277     {
   275     CHtiDispatcher* obj = NewLC( aCommPlugin, aMaxMsgSize, aMaxQueueMemory,
   278     CHtiDispatcher* obj = NewLC( aCommPlugin, aMaxMsgSize, aMaxQueueMemory,
   276             aShowConsole, aShowErrorDialogs );
   279             aReconnectDelay,aShowConsole, aShowErrorDialogs );
   277     CleanupStack::Pop();
   280     CleanupStack::Pop();
   278     return obj;
   281     return obj;
   279     }
   282     }
   280 
   283 
   281 CConsoleBase* CHtiDispatcher::GetConsole()
   284 CConsoleBase* CHtiDispatcher::GetConsole()
  1238         default:
  1241         default:
  1239             break;
  1242             break;
  1240         }
  1243         }
  1241     return mappedUid;
  1244     return mappedUid;
  1242     }
  1245     }
       
  1246 
       
  1247 TBool CHtiDispatcher::CommReconnect()
       
  1248     {
       
  1249     if(iReconnectDelay == 0)
       
  1250         {
       
  1251         return EFalse;
       
  1252         }
       
  1253     
       
  1254     //Delay
       
  1255     HTI_LOG_FORMAT( "Reconnect deley : %d seconds", iReconnectDelay);
       
  1256     User::After(iReconnectDelay * 1000 * 1000);
       
  1257     
       
  1258     //Reconnect
       
  1259     iIncomingQueue->RemoveAll();
       
  1260     iOutgoingQueue->RemoveAll();
       
  1261     
       
  1262     iListener->Reset();
       
  1263     iSender->Reset();
       
  1264     iListener->ReceiveMessage();
       
  1265 
       
  1266     return ETrue;
       
  1267     }