imagehandlingutilities/thumbnailmanager/tmiadrestart/src/tmiadrestart.cpp
branchRCL_3
changeset 21 6257223ede8a
parent 20 2b4b06654caa
child 22 9d4d3445ce6e
equal deleted inserted replaced
20:2b4b06654caa 21:6257223ede8a
    20 #include <e32std.h>  
    20 #include <e32std.h>  
    21 #include <e32property.h>
    21 #include <e32property.h>
    22 #include "thumbnaillog.h"
    22 #include "thumbnaillog.h"
    23 
    23 
    24 #include "thumbnailmanagerconstants.h"
    24 #include "thumbnailmanagerconstants.h"
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "tmiadrestartTraces.h"
       
    28 #endif
    25 
    29 
    26 LOCAL_C void MainL()
    30 LOCAL_C void MainL()
    27     {
    31     {
    28     // delay so that cenrep has time to read new config
    32     // delay so that cenrep has time to read new config
    29     TN_DEBUG1( "MainL() after" );
    33     TN_DEBUG1( "MainL() after" );
       
    34     OstTrace0( TRACE_NORMAL, _MAINL, "::MainL - after" );
       
    35     
    30     User::After(5000000);
    36     User::After(5000000);
    31     
    37     
    32     TInt res( KErrNone );
    38     TInt res( KErrNone );
    33     RProcess process;
    39     RProcess process;
    34     TFullName name;
    40     TFullName name;
    35     
    41     
    36     // find and terminate Thumb AG Daemon
    42     // find and terminate Thumb AG Daemon
    37     TN_DEBUG1( "MainL() KTAGDaemonProcess find" );
    43     TN_DEBUG1( "MainL() KTAGDaemonProcess find" );
       
    44     OstTrace0( TRACE_NORMAL, DUP1__MAINL, "::MainL - find" );
    38     TFindProcess findProcess( KTAGDaemonProcess );   
    45     TFindProcess findProcess( KTAGDaemonProcess );   
    39 
    46 
    40     if ( findProcess.Next(name) == KErrNone )
    47     if ( findProcess.Next(name) == KErrNone )
    41         {
    48         {
    42         res = process.Open(name);
    49         res = process.Open(name);
    43         TN_DEBUG2( "MainL() KTAGDaemonProcess open res = %d", res );    
    50         TN_DEBUG2( "MainL() KTAGDaemonProcess open res = %d", res );    
       
    51         OstTrace1( TRACE_NORMAL, DUP2__MAINL, "::MainL;res=%d - open res", res );
    44         
    52         
    45         // logon to get termination signal
    53         // logon to get termination signal
    46         TRequestStatus status;
    54         TRequestStatus status;
    47         TN_DEBUG1( "MainL() KTAGDaemonProcess logon" );
    55         TN_DEBUG1( "MainL() KTAGDaemonProcess logon" );
       
    56         OstTrace0( TRACE_NORMAL, DUP3__MAINL, "::MainL - logon" );
    48         process.Logon(status);
    57         process.Logon(status);
    49 
    58 
    50         // shutdown using P&S key
    59         // shutdown using P&S key
    51         TN_DEBUG2( "MainL() KTAGDaemonProcess Set = %d", res );
    60         TN_DEBUG2( "MainL() KTAGDaemonProcess Set = %d", res );
       
    61         OstTrace1( TRACE_NORMAL, DUP4__MAINL, "::MainL - Set = res;res=%d", res );
    52         res = RProperty::Set(KTAGDPSNotification,KShutdown,1);
    62         res = RProperty::Set(KTAGDPSNotification,KShutdown,1);
    53        
    63        
    54         // blocks here until thread is terminated
    64         // blocks here until thread is terminated
    55         TN_DEBUG1( "MainL() KTAGDaemonProcess wait" );
    65         TN_DEBUG1( "MainL() KTAGDaemonProcess wait" );
       
    66         OstTrace0( TRACE_NORMAL, DUP5__MAINL, "::MainL - KTAGDaemonProcess wait" );
    56         User::WaitForRequest(status);
    67         User::WaitForRequest(status);
    57         
    68         
    58         // reset key
    69         // reset key
    59         TN_DEBUG1( "MainL() KTAGDaemonProcess reset" );
    70         TN_DEBUG1( "MainL() KTAGDaemonProcess reset" );
       
    71         OstTrace0( TRACE_NORMAL, DUP6__MAINL, "::MainL - KTAGDaemonProcess reset" );
    60         res = RProperty::Set(KTAGDPSNotification, KShutdown, 0);
    72         res = RProperty::Set(KTAGDPSNotification, KShutdown, 0);
    61         
    73         
    62         TN_DEBUG1( "MainL() KTAGDaemonProcess close" );
    74         TN_DEBUG1( "MainL() KTAGDaemonProcess close" );
       
    75         OstTrace0( TRACE_NORMAL, DUP7__MAINL, "::MainL - close" );
    63         process.Close();
    76         process.Close();
    64         }
    77         }
    65     
    78     
    66     // find and terminate Thumbnail Server
    79     // find and terminate Thumbnail Server
    67     TFindProcess findProcess2( KThumbnailServerProcess );
    80     TFindProcess findProcess2( KThumbnailServerProcess );
    68     TN_DEBUG1( "MainL() KThumbnailServerProcess find" );
    81     TN_DEBUG1( "MainL() KThumbnailServerProcess find" );
       
    82     OstTrace0( TRACE_NORMAL, DUP8__MAINL, "::MainL - find" );
    69     if ( findProcess2.Next(name) == KErrNone )
    83     if ( findProcess2.Next(name) == KErrNone )
    70         {
    84         {
    71         res = process.Open(name);
    85         res = process.Open(name);
    72         TN_DEBUG2( "MainL() KThumbnailServerProcess open res = %d", res );
    86         TN_DEBUG2( "MainL() KThumbnailServerProcess open res = %d", res );
       
    87         OstTrace1( TRACE_NORMAL, DUP9__MAINL, "::MainL - KThumbnailServerProcess open;res=%d", res );
    73         
    88         
    74         // logon to get termination signal
    89         // logon to get termination signal
    75         TRequestStatus status;
    90         TRequestStatus status;
    76         TN_DEBUG1( "MainL() KThumbnailServerProcess logon" );
    91         TN_DEBUG1( "MainL() KThumbnailServerProcess logon" );
       
    92         OstTrace0( TRACE_NORMAL, DUP10__MAINL, "::MainL - KThumbnailServerProcess logon" );
    77         process.Logon(status);
    93         process.Logon(status);
    78           
    94           
    79         // shutdown using P&S key
    95         // shutdown using P&S key
    80         TN_DEBUG2( "MainL() KThumbnailServerProcess Set res = %d", res );
    96         TN_DEBUG2( "MainL() KThumbnailServerProcess Set res = %d", res );
       
    97         OstTrace1( TRACE_NORMAL, DUP11__MAINL, "::MainL - KThumbnailServerProcess Set;res=%d", res );
    81         res = RProperty::Set(KTMPSNotification,KShutdown,1);
    98         res = RProperty::Set(KTMPSNotification,KShutdown,1);
    82          
    99          
    83         // blocks here until thread is terminated
   100         // blocks here until thread is terminated
    84         TN_DEBUG1( "MainL() KThumbnailServerProcess wait" );
   101         TN_DEBUG1( "MainL() KThumbnailServerProcess wait" );
       
   102         OstTrace0( TRACE_NORMAL, DUP12__MAINL, "::MainL - KThumbnailServerProcess wait" );
    85         User::WaitForRequest(status);
   103         User::WaitForRequest(status);
    86          
   104          
    87         // reset key
   105         // reset key
    88         TN_DEBUG2( "MainL() KThumbnailServerProcess reset res = %d", res );
   106         TN_DEBUG2( "MainL() KThumbnailServerProcess reset res = %d", res );
       
   107         OstTrace1( TRACE_NORMAL, DUP13__MAINL, "::MainL;res=%d - KThumbnailServerProcess reset", res );
    89         res = RProperty::Set(KTMPSNotification, KShutdown, 0);
   108         res = RProperty::Set(KTMPSNotification, KShutdown, 0);
    90 
   109 
    91         TN_DEBUG1( "MainL() KThumbnailServerProcess close" );
   110         TN_DEBUG1( "MainL() KThumbnailServerProcess close" );
       
   111         OstTrace0( TRACE_NORMAL, DUP14__MAINL, "::MainL - close" );
    92         process.Close();
   112         process.Close();
    93         }    
   113         }    
    94     
   114     
    95     // delay just in case old daemon hasn't died yet
   115     // delay just in case old daemon hasn't died yet
    96     TN_DEBUG1( "MainL() after" );
   116     TN_DEBUG1( "MainL() after" );
   101     TInt retryCount = 0;
   121     TInt retryCount = 0;
   102     
   122     
   103     // Create the server process
   123     // Create the server process
   104     // KNullDesC param causes server's E32Main() to be run
   124     // KNullDesC param causes server's E32Main() to be run
   105     TN_DEBUG2( "MainL() KTAGDaemonExe create res = %d", res );
   125     TN_DEBUG2( "MainL() KTAGDaemonExe create res = %d", res );
       
   126     OstTrace1( TRACE_NORMAL, DUP15__MAINL, "::MainL - KTAGDaemonExe create res;res=%d", res );
   106     res = server.Create( KTAGDaemonExe, KNullDesC );
   127     res = server.Create( KTAGDaemonExe, KNullDesC );
   107     
   128     
   108     // try again 3 times if fails
   129     // try again 3 times if fails
   109     while ( res != KErrNone)
   130     while ( res != KErrNone)
   110         {
   131         {
   111         TN_DEBUG1( "MainL() KTAGDaemonExe retry" );
   132         TN_DEBUG1( "MainL() KTAGDaemonExe retry" );
       
   133         OstTrace0( TRACE_NORMAL, DUP16__MAINL, "::MainL- KTAGDaemonExe retry" );
   112         if (retryCount > 2)
   134         if (retryCount > 2)
   113             {
   135             {
   114             TN_DEBUG1( "MainL() KTAGDaemonExe retry > 2" );
   136             TN_DEBUG1( "MainL() KTAGDaemonExe retry > 2" );
       
   137             OstTrace0( TRACE_NORMAL, DUP17__MAINL, "::MainL - KTAGDaemonExe retry > 2" );
   115             return;
   138             return;
   116             }
   139             }
   117         
   140         
   118         TN_DEBUG1( "MainL() after" );
   141         TN_DEBUG1( "MainL() after" );
       
   142         OstTrace0( TRACE_NORMAL, DUP18__MAINL, "::MainL - after" );
   119         User::After(2500000);
   143         User::After(2500000);
   120         TN_DEBUG2( "MainL() KTAGDaemonExe create res = %d", res );
   144         TN_DEBUG2( "MainL() KTAGDaemonExe create res = %d", res );
       
   145         OstTrace1( TRACE_NORMAL, DUP19__MAINL, "::MainL - KTAGDaemonExe create;res=%d", res );
   121         res = server.Create( KTAGDaemonExe, KNullDesC );
   146         res = server.Create( KTAGDaemonExe, KNullDesC );
   122         retryCount++;
   147         retryCount++;
   123         }
   148         }
   124     
   149     
   125     // Process created successfully
   150     // Process created successfully
   126     TRequestStatus status;
   151     TRequestStatus status;
   127     TN_DEBUG1( "MainL() Rendezvous" );
   152     TN_DEBUG1( "MainL() Rendezvous" );
       
   153     OstTrace0( TRACE_NORMAL, DUP20__MAINL, "::MainL - Rendezvous" );
   128     server.Rendezvous( status );
   154     server.Rendezvous( status );
   129     TN_DEBUG1( "MainL() Resume" );
   155     TN_DEBUG1( "MainL() Resume" );
       
   156     OstTrace0( TRACE_NORMAL, DUP21__MAINL, "::MainL - resume" );
   130     server.Resume(); // start it going
   157     server.Resume(); // start it going
   131     
   158     
   132     
   159     
   133     // Wait until the completion of the server creation
   160     // Wait until the completion of the server creation
   134     TN_DEBUG1( "MainL() wait" );
   161     TN_DEBUG1( "MainL() wait" );
       
   162     OstTrace0( TRACE_NORMAL, DUP22__MAINL, "::MainL - wait" );
   135     User::WaitForRequest( status );
   163     User::WaitForRequest( status );
   136     TN_DEBUG1( "MainL() wait done" );
   164     TN_DEBUG1( "MainL() wait done" );
       
   165     OstTrace0( TRACE_NORMAL, DUP23__MAINL, "::MainL - wait done"  );
   137     
   166     
   138     // Server created successfully
   167     // Server created successfully
   139     server.Close(); // we're no longer interested in the other process
   168     server.Close(); // we're no longer interested in the other process
   140     }
   169     }
   141 
   170