imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp
branchRCL_3
changeset 5 82749d516180
parent 0 2014ca87e772
child 9 2eb74cf6572e
equal deleted inserted replaced
1:235a7fc86938 5:82749d516180
    88             TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - URI = %S", &object->Uri() );
    88             TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - URI = %S", &object->Uri() );
    89                             
    89                             
    90             if( iUpdateToDb)
    90             if( iUpdateToDb)
    91                 {
    91                 {
    92                 //update IDs to database by Path
    92                 //update IDs to database by Path
    93                 if (iMessage.Handle())
    93                 if (ClientThreadAlive(EFalse))
    94                     {
    94                     {               
    95                     TInt err = iMessage.Read( 0, iRequestParams );
    95                     TInt err = iMessage.Read( 0, iRequestParams );
    96                     if( err == KErrNone)
    96                     if( err == KErrNone)
    97                         {
    97                         {
    98                         TThumbnailRequestParams& params = iRequestParams();
    98                         TThumbnailRequestParams& params = iRequestParams();
    99                         TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), params.iThumbnailId));
    99                         TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), params.iThumbnailId));
   100                         }                   
   100                         }                   
   101                     }
   101                     }
   102                 }
   102                 }
   103     
   103     
   104            // return path to client side            
   104             // return path to client side            
   105             ReturnPath(object->Uri());
   105             ReturnPath(object->Uri());
   106             }
   106             }
   107         else if (iQueryType == EId )
   107         else if (iQueryType == EId )
   108             {
   108             {
   109             const CMdEObject* object = &iQuery->Result(0);
   109             const CMdEObject* object = &iQuery->Result(0);
   117                     TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), object->Id() ));
   117                     TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), object->Id() ));
   118                     }
   118                     }
   119                 else
   119                 else
   120                     {
   120                     {
   121                     // add Id to message
   121                     // add Id to message
   122                     if (iMessage.Handle())
   122                     if (ClientThreadAlive(EFalse))
   123                         {
   123                         {
   124                         TInt ret = iMessage.Read( 0, iRequestParams );
   124                         TInt ret = iMessage.Read( 0, iRequestParams );
   125                         if( ret == KErrNone)
   125                         if( ret == KErrNone)
   126                             {
   126                             {
   127                             TThumbnailRequestParams& params = iRequestParams();
   127                             TThumbnailRequestParams& params = iRequestParams();
   132                     }
   132                     }
   133                 }
   133                 }
   134             
   134             
   135             // complete the message with a code from which client side
   135             // complete the message with a code from which client side
   136             // knows to make a new request using the path
   136             // knows to make a new request using the path
   137             Complete( KThumbnailErrThumbnailNotFound );
   137             if (ClientThreadAlive(EFalse))
   138             ResetMessageData();
   138                 {  
       
   139                 Complete( KThumbnailErrThumbnailNotFound );
       
   140                 ResetMessageData();
       
   141                 }
   139             }
   142             }
   140         else
   143         else
   141             {
   144             {
   142             TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here" );
   145             TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here" );
   143             Complete( KErrNotFound );
   146             if (ClientThreadAlive(EFalse))
   144             ResetMessageData();
   147                 {  
       
   148                 Complete( KErrNotFound );
       
   149                 ResetMessageData();
       
   150                 }
   145             }
   151             }
   146         }
   152         }
   147     else
   153     else
   148         {
   154         {
   149         TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." );
   155         TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." );
   150         
   156         
   151 	        if( iQueryType == EId )
   157         if( iQueryType == EId )
   152 	            {
   158             {
   153 	               if( iUpdateToDb)
   159             if( iUpdateToDb)
   154 	                    {
   160                 {
   155 	                    TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() delete %S", &iUri );
   161                 TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() delete %S", &iUri );
   156 	                    TRAP_IGNORE( iServer.DeleteThumbnailsL( iUri ) );
   162                 TRAP_IGNORE( iServer.DeleteThumbnailsL( iUri ) );
   157 	                    }
   163                 }
   158 	               
   164                
   159 	            Complete( KThumbnailErrThumbnailNotFound );
   165             if (ClientThreadAlive(EFalse))
   160 	            ResetMessageData();
   166                 {     
   161 	            }
   167                 Complete( KThumbnailErrThumbnailNotFound );
   162 	        else 
   168                 ResetMessageData();
   163 	            {
   169                 }
   164 	            Complete( KErrNotFound );
   170             }
   165 	            ResetMessageData();
   171         else 
   166             	}
   172             {
       
   173             if (ClientThreadAlive(EFalse))
       
   174                 {  
       
   175                 Complete( KErrNotFound );
       
   176                 ResetMessageData();
       
   177                 }
       
   178             }
   167         }
   179         }
   168    }
   180    }
   169 
   181 
   170 
   182 
   171 // ---------------------------------------------------------------------------
   183 // ---------------------------------------------------------------------------
   176     {
   188     {
   177     TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::StartL()", this );
   189     TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::StartL()", this );
   178 
   190 
   179     CThumbnailTask::StartL();
   191     CThumbnailTask::StartL();
   180 
   192 
       
   193     // get client thread
       
   194     TInt err = iMessage.Client( iClientThread );
       
   195     if (err != KErrNone)
       
   196         {
       
   197         TN_DEBUG2( "CThumbnailTask(0x%08x)::ClientThreadAlive() - client thread not found", this);
       
   198     
       
   199         ResetMessageData();
       
   200         }
       
   201     
   181     // start query
   202     // start query
   182     iQuery->FindL();
   203     iQuery->FindL();
   183     }
   204     }
   184 
   205 
   185 
   206 
   230 // CThumbnailMDSQueryTask::ReturnPath()
   251 // CThumbnailMDSQueryTask::ReturnPath()
   231 // ---------------------------------------------------------------------------
   252 // ---------------------------------------------------------------------------
   232 //
   253 //
   233 void CThumbnailMDSQueryTask::ReturnPath(const TDesC& aUri)
   254 void CThumbnailMDSQueryTask::ReturnPath(const TDesC& aUri)
   234     {
   255     {
   235     if ( iMessage.Handle())
   256     if ( ClientThreadAlive(EFalse) )
   236         {
   257         {
   237         // add path to message
   258         // add path to message
   238         if (iMessage.Handle())
   259         TInt ret = iMessage.Read( 0, iRequestParams );      
   239             {
   260         if(ret == KErrNone)
   240             TInt ret = iMessage.Read( 0, iRequestParams );      
   261             {
   241             if(ret == KErrNone)
   262             TThumbnailRequestParams& params = iRequestParams();
   242                 {
   263             params.iFileName = aUri;
   243                 TThumbnailRequestParams& params = iRequestParams();
   264             ret = iMessage.Write( 0, iRequestParams );
   244                 params.iFileName = aUri;
   265             }
   245                 ret = iMessage.Write( 0, iRequestParams );
   266             
   246                 }
       
   247             }
       
   248     
       
   249         // complete the message with a code from which client side
   267         // complete the message with a code from which client side
   250         // knows to make a new request using the path
   268         // knows to make a new request using the path
   251         Complete( KThumbnailErrThumbnailNotFound );
   269         Complete( KThumbnailErrThumbnailNotFound );
   252         ResetMessageData();
   270         ResetMessageData();
   253         }
   271         }