imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp
changeset 14 2edacbf5d3f9
parent 0 2014ca87e772
child 15 7197e789b953
equal deleted inserted replaced
1:235a7fc86938 14:2edacbf5d3f9
    85             {
    85             {
    86             const CMdEObject* object = &iQuery->Result(0);
    86             const CMdEObject* object = &iQuery->Result(0);
    87             
    87             
    88             TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - URI = %S", &object->Uri() );
    88             TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - URI = %S", &object->Uri() );
    89                             
    89                             
    90             if( iUpdateToDb)
    90             // return path to client side       
       
    91             if( iDelete )
    91                 {
    92                 {
    92                 //update IDs to database by Path
    93                 TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() delete %S", &iUri );
    93                 if (iMessage.Handle())
    94                 TRAP_IGNORE( iServer.DeleteThumbnailsL( iUri ) );
    94                     {
    95                 }
    95                     TInt err = iMessage.Read( 0, iRequestParams );
    96             else
    96                     if( err == KErrNone)
       
    97                         {
       
    98                         TThumbnailRequestParams& params = iRequestParams();
       
    99                         TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), params.iThumbnailId));
       
   100                         }                   
       
   101                     }
       
   102                 }
       
   103     
       
   104            // return path to client side            
       
   105             ReturnPath(object->Uri());
       
   106             }
       
   107         else if (iQueryType == EId )
       
   108             {
       
   109             const CMdEObject* object = &iQuery->Result(0);
       
   110             
       
   111             TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Id = %d",  object->Id());
       
   112             
       
   113             if( object->Id() != KNoId)
       
   114                 {
    97                 {
   115                 if( iUpdateToDb)
    98                 ReturnPath(object->Uri());
   116                     {
    99                 }
   117                     TRAP_IGNORE(iServer.UpdateIDL(object->Uri(), object->Id() ));
       
   118                     }
       
   119                 else
       
   120                     {
       
   121                     // add Id to message
       
   122                     if (iMessage.Handle())
       
   123                         {
       
   124                         TInt ret = iMessage.Read( 0, iRequestParams );
       
   125                         if( ret == KErrNone)
       
   126                             {
       
   127                             TThumbnailRequestParams& params = iRequestParams();
       
   128                             params.iThumbnailId = object->Id();
       
   129                             ret = iMessage.Write( 0, iRequestParams );
       
   130                             }
       
   131                         }
       
   132                     }
       
   133                 }
       
   134             
       
   135             // complete the message with a code from which client side
       
   136             // knows to make a new request using the path
       
   137             Complete( KThumbnailErrThumbnailNotFound );
       
   138             ResetMessageData();
       
   139             }
   100             }
   140         else
   101         else
   141             {
   102             {
   142             TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here" );
   103             TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here!" );
   143             Complete( KErrNotFound );
   104             if (ClientThreadAlive(EFalse))
   144             ResetMessageData();
   105                 {  
       
   106                 Complete( KErrNotFound );
       
   107                 ResetMessageData();
       
   108                 }
       
   109             __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbnailMDSQueryTask::HandleQueryCompleted()"), KErrNotSupported));
   145             }
   110             }
   146         }
   111         }
   147     else
   112     else
   148         {
   113         {
   149         TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." );
   114         TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." );
   150         
   115         if(!iDelete)
   151 	        if( iQueryType == EId )
   116             {
   152 	            {
   117             if (ClientThreadAlive(EFalse))
   153 	               if( iUpdateToDb)
   118                 {  
   154 	                    {
   119                 Complete( KErrNotFound );
   155 	                    TN_DEBUG2( "CThumbnailMDSQueryTask::HandleQueryCompleted() delete %S", &iUri );
   120                 ResetMessageData();
   156 	                    TRAP_IGNORE( iServer.DeleteThumbnailsL( iUri ) );
   121                 }
   157 	                    }
   122             }
   158 	               
       
   159 	            Complete( KThumbnailErrThumbnailNotFound );
       
   160 	            ResetMessageData();
       
   161 	            }
       
   162 	        else 
       
   163 	            {
       
   164 	            Complete( KErrNotFound );
       
   165 	            ResetMessageData();
       
   166             	}
       
   167         }
   123         }
   168    }
   124    }
   169 
   125 
   170 
   126 
   171 // ---------------------------------------------------------------------------
   127 // ---------------------------------------------------------------------------
   176     {
   132     {
   177     TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::StartL()", this );
   133     TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::StartL()", this );
   178 
   134 
   179     CThumbnailTask::StartL();
   135     CThumbnailTask::StartL();
   180 
   136 
       
   137     // get client thread
       
   138     TInt err = iMessage.Client( iClientThread );
       
   139     if (err != KErrNone)
       
   140         {
       
   141         TN_DEBUG2( "CThumbnailTask(0x%08x)::ClientThreadAlive() - client thread not found", this);
       
   142     
       
   143         ResetMessageData();
       
   144         }
       
   145     
   181     // start query
   146     // start query
   182     iQuery->FindL();
   147     iQuery->FindL();
   183     }
   148     }
   184 
   149 
   185 
   150 
   207 
   172 
   208 // ---------------------------------------------------------------------------
   173 // ---------------------------------------------------------------------------
   209 // CThumbnailMDSQueryTask::QueryPathByIdL()
   174 // CThumbnailMDSQueryTask::QueryPathByIdL()
   210 // ---------------------------------------------------------------------------
   175 // ---------------------------------------------------------------------------
   211 //
   176 //
   212 void CThumbnailMDSQueryTask::QueryPathByIdL(TThumbnailId aId)
   177 void CThumbnailMDSQueryTask::QueryPathByIdL(TThumbnailId aId, TBool aDelete)
   213     {
   178     {
   214     TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryPathByIdL()");
   179     TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryPathByIdL()");
   215     iQueryType = EURI;
   180     iQueryType = EURI;
       
   181     iDelete = aDelete;
   216     CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL();
   182     CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL();
   217     CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
   183     CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
   218     
   184     
   219     iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this );
   185     iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this );
   220     iQuery->SetResultMode( EQueryResultModeItem );
   186     iQuery->SetResultMode( EQueryResultModeItem );
   230 // CThumbnailMDSQueryTask::ReturnPath()
   196 // CThumbnailMDSQueryTask::ReturnPath()
   231 // ---------------------------------------------------------------------------
   197 // ---------------------------------------------------------------------------
   232 //
   198 //
   233 void CThumbnailMDSQueryTask::ReturnPath(const TDesC& aUri)
   199 void CThumbnailMDSQueryTask::ReturnPath(const TDesC& aUri)
   234     {
   200     {
   235     if ( iMessage.Handle())
   201     if ( ClientThreadAlive(EFalse) )
   236         {
   202         {
   237         // add path to message
   203         // add path to message
   238         if (iMessage.Handle())
   204         TInt ret = iMessage.Read( 0, iRequestParams );      
   239             {
   205         if(ret == KErrNone)
   240             TInt ret = iMessage.Read( 0, iRequestParams );      
   206             {
   241             if(ret == KErrNone)
   207             TThumbnailRequestParams& params = iRequestParams();
   242                 {
   208             params.iFileName = aUri;
   243                 TThumbnailRequestParams& params = iRequestParams();
   209             ret = iMessage.Write( 0, iRequestParams );
   244                 params.iFileName = aUri;
   210             }
   245                 ret = iMessage.Write( 0, iRequestParams );
   211             
   246                 }
       
   247             }
       
   248     
       
   249         // complete the message with a code from which client side
   212         // complete the message with a code from which client side
   250         // knows to make a new request using the path
   213         // knows to make a new request using the path
   251         Complete( KThumbnailErrThumbnailNotFound );
   214         Complete( KThumbnailErrThumbnailNotFound );
   252         ResetMessageData();
   215         ResetMessageData();
   253         }
   216         }
   254     }
   217     }
   255 
   218 
   256 // ---------------------------------------------------------------------------
   219 // ---------------------------------------------------------------------------
   257 // CThumbnailMDSQueryTask::QueryIdByPathL()
       
   258 // ---------------------------------------------------------------------------
       
   259 //
       
   260 void CThumbnailMDSQueryTask::QueryIdByPathL(const TDesC& aUri)
       
   261     {
       
   262     TN_DEBUG1( "CThumbnailMDSQueryTask()::QueryIdByPathL()");
       
   263     iQueryType = EId;
       
   264     iUri = aUri;
       
   265     CMdENamespaceDef* defNamespace = &iMdESession->GetDefaultNamespaceDefL();
       
   266     CMdEObjectDef& objDef = defNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject );
       
   267     
       
   268     iQuery = iMdESession->NewObjectQueryL( *defNamespace, objDef, this );
       
   269     iQuery->SetResultMode( EQueryResultModeItem );
       
   270 
       
   271     CMdELogicCondition& rootCondition = iQuery->Conditions();
       
   272     rootCondition.SetOperator( ELogicConditionOperatorOr );
       
   273     
       
   274     rootCondition.AddObjectConditionL(EObjectConditionCompareUri, aUri);
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CThumbnailMDSQueryTask::SetUpdateToDb()
   220 // CThumbnailMDSQueryTask::SetUpdateToDb()
   279 // ---------------------------------------------------------------------------
   221 // ---------------------------------------------------------------------------
   280 //
   222 //
   281 void CThumbnailMDSQueryTask::SetUpdateToDb(const TBool& aUpdateToDb )
   223 void CThumbnailMDSQueryTask::SetUpdateToDb(const TBool& aUpdateToDb )
   282     {
   224     {