imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp
changeset 39 1a8af2cd6858
parent 29 4bdfb6b5c9b4
child 41 9d4d3445ce6e
equal deleted inserted replaced
34:1c05ae5a7e41 39:1a8af2cd6858
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include "thumbnailsession.h"
    20 #include "thumbnailsession.h"
    21 #include "thumbnailmanagerconstants.h"
    21 #include "thumbnailmanagerconstants.h"
    22 #include "thumbnaillog.h"
    22 #include "thumbnaillog.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "thumbnailsessionTraces.h"
       
    26 #endif
    23 
    27 
    24 // ======== MEMBER FUNCTIONS ========
    28 // ======== MEMBER FUNCTIONS ========
    25 
    29 
    26 // ---------------------------------------------------------------------------
    30 // ---------------------------------------------------------------------------
    27 // RThumbnailSession::RThumbnailSession()
    31 // RThumbnailSession::RThumbnailSession()
    30 //
    34 //
    31 RThumbnailSession::RThumbnailSession(): RSessionBase()
    35 RThumbnailSession::RThumbnailSession(): RSessionBase()
    32     {
    36     {
    33     // No implementation required
    37     // No implementation required
    34     TN_DEBUG1( "RThumbnailSession::RThumbnailSession");
    38     TN_DEBUG1( "RThumbnailSession::RThumbnailSession");
       
    39     OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_RTHUMBNAILSESSION, "RThumbnailSession::RThumbnailSession" );
    35     }
    40     }
    36 
    41 
    37 
    42 
    38 // ---------------------------------------------------------------------------
    43 // ---------------------------------------------------------------------------
    39 // RThumbnailSession::Connect()
    44 // RThumbnailSession::Connect()
    40 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    41 //
    46 //
    42 TInt RThumbnailSession::Connect()
    47 TInt RThumbnailSession::Connect()
    43     { 
    48     { 
    44     TN_DEBUG1( "RThumbnailSession::Connect - start");
    49     TN_DEBUG1( "RThumbnailSession::Connect - start");
       
    50     OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_CONNECT, "RThumbnailSession::Connect - start" );
    45     
    51     
    46     StartServer();
    52     StartServer();
    47     
    53     
    48     // special case
    54     // special case
    49     // wait possibly needed here to give an old server process
    55     // wait possibly needed here to give an old server process
    56     // special case
    62     // special case
    57     // old server still alive, wait and try again
    63     // old server still alive, wait and try again
    58     while (retry <= 10 && err != KErrNone)
    64     while (retry <= 10 && err != KErrNone)
    59         {
    65         {
    60         TN_DEBUG1( "RThumbnailSession::Connect - retry");
    66         TN_DEBUG1( "RThumbnailSession::Connect - retry");
       
    67         OstTrace0( TRACE_NORMAL, DUP1_RTHUMBNAILSESSION_CONNECT, "RThumbnailSession::Connect - retry" );
    61     
    68     
    62         User::After(retry * 50000);
    69         User::After(retry * 50000);
    63         StartServer();
    70         StartServer();
    64         err = CreateSession( KThumbnailServerName, Version(), KMessageSlots );
    71         err = CreateSession( KThumbnailServerName, Version(), KMessageSlots );
    65         retry++;
    72         retry++;
    66         }
    73         }
    67     
    74     
    68     TN_DEBUG1( "RThumbnailSession::Connect - end");
    75     TN_DEBUG1( "RThumbnailSession::Connect - end");
       
    76     OstTrace0( TRACE_NORMAL, DUP2_RTHUMBNAILSESSION_CONNECT, "RThumbnailSession::Connect - end" );
    69     
    77     
    70     return err;
    78     return err;
    71     }
    79     }
    72 
    80 
    73 
    81 
    77 // ---------------------------------------------------------------------------
    85 // ---------------------------------------------------------------------------
    78 //
    86 //
    79 void RThumbnailSession::Close()
    87 void RThumbnailSession::Close()
    80     {
    88     {
    81     TN_DEBUG1( "RThumbnailSession::Close");
    89     TN_DEBUG1( "RThumbnailSession::Close");
       
    90     OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_CLOSE, "RThumbnailSession::Close" );
    82     
    91     
    83     RSessionBase::Close();
    92     RSessionBase::Close();
    84     }
    93     }
    85 
    94 
    86 
    95 
   102 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   103 //
   112 //
   104 TInt RThumbnailSession::StartServer()
   113 TInt RThumbnailSession::StartServer()
   105     {
   114     {
   106     TN_DEBUG1( "RThumbnailSession::StartServer - start");
   115     TN_DEBUG1( "RThumbnailSession::StartServer - start");
       
   116     OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_STARTSERVER, "RThumbnailSession::StartServer - start" );
   107     
   117     
   108     TInt res( KErrNone );
   118     TInt res( KErrNone );
   109     // create server - if one of this name does not already exist
   119     // create server - if one of this name does not already exist
   110 
   120 
   111     TFindServer findServer( KThumbnailServerName );
   121     TFindServer findServer( KThumbnailServerName );
   112     TFullName name;
   122     TFullName name;
   113     if ( findServer.Next( name ) != KErrNone )
   123     if ( findServer.Next( name ) != KErrNone )
   114         // we don't exist already
   124         // we don't exist already
   115         {
   125         {
   116         TN_DEBUG1( "RThumbnailSession::StartServer - server process doesn't exist yet");
   126         TN_DEBUG1( "RThumbnailSession::StartServer - server process doesn't exist yet");
       
   127         OstTrace0( TRACE_NORMAL, DUP1_RTHUMBNAILSESSION_STARTSERVER, "RThumbnailSession::StartServer - server process doesn't exist yet" );
   117     
   128     
   118         RProcess server;
   129         RProcess server;
   119         // Create the server process
   130         // Create the server process
   120         // KNullDesC param causes server's E32Main() to be run
   131         // KNullDesC param causes server's E32Main() to be run
   121         res = server.Create( KThumbnailServerExe, KNullDesC );
   132         res = server.Create( KThumbnailServerExe, KNullDesC );
   122         if ( res != KErrNone )
   133         if ( res != KErrNone )
   123             {
   134             {
   124             TN_DEBUG2( "RThumbnailSession::StartServer - error creating process: %d", res);
   135             TN_DEBUG2( "RThumbnailSession::StartServer - error creating process: %d", res);
       
   136             OstTrace1( TRACE_NORMAL, DUP2_RTHUMBNAILSESSION_STARTSERVER, "RThumbnailSession::StartServer;res=%d", res );
   125             return res;
   137             return res;
   126             }
   138             }
   127         
   139         
   128         TN_DEBUG1( "RThumbnailSession::StartServer - process created");
   140         TN_DEBUG1( "RThumbnailSession::StartServer - process created");
       
   141         OstTrace0( TRACE_NORMAL, DUP3_RTHUMBNAILSESSION_STARTSERVER, "RThumbnailSession::StartServer - process created" );
   129 
   142 
   130         // Process created successfully
   143         // Process created successfully
   131         TRequestStatus status;
   144         TRequestStatus status;
   132         server.Rendezvous( status );
   145         server.Rendezvous( status );
   133         server.Resume(); // start it going
   146         server.Resume(); // start it going
   136         User::WaitForRequest( status );
   149         User::WaitForRequest( status );
   137 
   150 
   138         if ( status != KErrNone )
   151         if ( status != KErrNone )
   139             {
   152             {
   140             TN_DEBUG2( "RThumbnailSession::StartServer - status: %d, closing", status.Int() );
   153             TN_DEBUG2( "RThumbnailSession::StartServer - status: %d, closing", status.Int() );
       
   154             OstTrace1( TRACE_NORMAL, DUP4_RTHUMBNAILSESSION_STARTSERVER, "RThumbnailSession::StartServer;status.Int()=%d", status.Int() );
   141         
   155         
   142             server.Close();
   156             server.Close();
   143             return status.Int();
   157             return status.Int();
   144             }
   158             }
   145         
   159         
   146         // Server created successfully
   160         // Server created successfully
   147         server.Close(); // we're no longer interested in the other process
   161         server.Close(); // we're no longer interested in the other process
   148         }
   162         }
   149     
   163     
   150     TN_DEBUG1( "RThumbnailSession::StartServer - end");
   164     TN_DEBUG1( "RThumbnailSession::StartServer - end");
       
   165     OstTrace0( TRACE_NORMAL, DUP5_RTHUMBNAILSESSION_STARTSERVER, "RThumbnailSession::StartServer - end" );
   151     
   166     
   152     return res;
   167     return res;
   153     }
   168     }
   154 
   169 
   155 
   170 
   223         TRequestStatus& aStatus  )
   238         TRequestStatus& aStatus  )
   224     {
   239     {
   225     if( !aBuffer )
   240     if( !aBuffer )
   226         {
   241         {
   227         TN_DEBUG1( "RThumbnailSession::RequestSetThumbnailL() - !aBuffer KErrArgument");
   242         TN_DEBUG1( "RThumbnailSession::RequestSetThumbnailL() - !aBuffer KErrArgument");
       
   243         OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_REQUESTSETTHUMBNAILL, "RThumbnailSession::RequestSetThumbnailL - !aBuffer KErrArgument" );
   228         User::Leave( KErrArgument );
   244         User::Leave( KErrArgument );
   229         }
   245         }
   230     
   246     
   231     TIpcArgs args( &aParams, aBuffer, aBuffer->Length(), KCheckValue );
   247     TIpcArgs args( &aParams, aBuffer, aBuffer->Length(), KCheckValue );
   232     aParams().iTargetUri = aTargetUri;
   248     aParams().iTargetUri = aTargetUri;
   239         TRequestStatus& aStatus  )
   255         TRequestStatus& aStatus  )
   240     {
   256     {
   241     if( !aBitmapHandle )
   257     if( !aBitmapHandle )
   242         {
   258         {
   243         TN_DEBUG1( "RThumbnailSession::RequestSetThumbnailL() - !aBitmapHandle KErrArgument");
   259         TN_DEBUG1( "RThumbnailSession::RequestSetThumbnailL() - !aBitmapHandle KErrArgument");
       
   260         OstTrace0( TRACE_NORMAL, DUP1_RTHUMBNAILSESSION_REQUESTSETTHUMBNAILL, "RThumbnailSession::RequestSetThumbnailL - !aBitmapHandle KErrArgument" );
   244         User::Leave( KErrArgument );
   261         User::Leave( KErrArgument );
   245         }
   262         }
   246     
   263     
   247     TIpcArgs args( &aParams, aBitmapHandle, KCheckValue );
   264     TIpcArgs args( &aParams, aBitmapHandle, KCheckValue );
   248     aParams().iTargetUri = aTargetUri;
   265     aParams().iTargetUri = aTargetUri;
   257     {
   274     {
   258     TInt err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle ));
   275     TInt err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle ));
   259     while ( err == KErrServerBusy )
   276     while ( err == KErrServerBusy )
   260         {
   277         {
   261         TN_DEBUG1( "RThumbnailSession::ReleaseBitmap() - server slots full");
   278         TN_DEBUG1( "RThumbnailSession::ReleaseBitmap() - server slots full");
       
   279         OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_RELEASEBITMAP, "RThumbnailSession::ReleaseBitmap - server slots full" );
   262     
   280     
   263         err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle ));
   281         err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle ));
   264         }
   282         }
   265     }
   283     }
   266 
   284 
   273     {
   291     {
   274     TInt err = Send( ECancelRequest, TIpcArgs( aRequestId ));
   292     TInt err = Send( ECancelRequest, TIpcArgs( aRequestId ));
   275     while ( err == KErrServerBusy )
   293     while ( err == KErrServerBusy )
   276         {
   294         {
   277         TN_DEBUG1( "RThumbnailSession::CancelRequest() - server slots full");
   295         TN_DEBUG1( "RThumbnailSession::CancelRequest() - server slots full");
       
   296         OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_CANCELREQUEST, "RThumbnailSession::CancelRequest - server slots full" );
   278     
   297     
   279         err = Send( ECancelRequest, TIpcArgs( aRequestId ));
   298         err = Send( ECancelRequest, TIpcArgs( aRequestId ));
   280         }
   299         }
   281     return err;
   300     return err;
   282     }
   301     }
   291     {
   310     {
   292     TInt err = Send( EChangePriority, TIpcArgs( aRequestId, aNewPriority ));
   311     TInt err = Send( EChangePriority, TIpcArgs( aRequestId, aNewPriority ));
   293     while ( err == KErrServerBusy )
   312     while ( err == KErrServerBusy )
   294         {
   313         {
   295         TN_DEBUG1( "RThumbnailSession::ChangePriority() - server slots full");
   314         TN_DEBUG1( "RThumbnailSession::ChangePriority() - server slots full");
       
   315         OstTrace0( TRACE_NORMAL, RTHUMBNAILSESSION_CHANGEPRIORITY, "RThumbnailSession::ChangePriority - server slots full" );
   296     
   316     
   297         err = Send( EChangePriority, TIpcArgs( aRequestId, aNewPriority ));
   317         err = Send( EChangePriority, TIpcArgs( aRequestId, aNewPriority ));
   298         }
   318         }
   299     return err;
   319     return err;
   300     }
   320     }