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