omadrm/drmengine/dcfrepository/server/src/FileScan.cpp
changeset 84 b09186059647
parent 23 493788a4a8a4
equal deleted inserted replaced
82:a117e284a2c6 84:b09186059647
     1 /*
     1 /*
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   119 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   120 //
   120 //
   121 void CFileScan::ConstructL()
   121 void CFileScan::ConstructL()
   122     {
   122     {
   123     TInt err = 0;
   123     TInt err = 0;
       
   124     CActiveScheduler::Add( this );
       
   125 
   124     if ( !iFs )
   126     if ( !iFs )
   125         {
   127         {
   126         err = KErrArgument;
   128         err = KErrArgument;
   127         }
   129         }
   128     else
   130     else
   148 
   150 
   149 
   151 
   150 // Destructor
   152 // Destructor
   151 CFileScan::~CFileScan()
   153 CFileScan::~CFileScan()
   152     {
   154     {
       
   155     Deque();
   153     CleanInternal();
   156     CleanInternal();
   154     iServer = NULL;
   157     iServer = NULL;
   155     iFs = NULL;
   158     iFs = NULL;
   156     }
   159     }
   157 
   160 
   194 // (other items were commented in a header).
   197 // (other items were commented in a header).
   195 // -----------------------------------------------------------------------------
   198 // -----------------------------------------------------------------------------
   196 //
   199 //
   197 void CFileScan::RunL()
   200 void CFileScan::RunL()
   198     {
   201     {
   199     TInt err = KErrNone;
   202     TInt err (iStatus.Int());
   200     if ( iSearching && iServer->State()!=EStateIdle )
   203     if ( !err && iSearching && iServer->State()!=EStateIdle )
   201         {
   204         {
   202         err = SearchNext();
   205         err = SearchNext();
   203         if ( err == KErrCancel )
   206         if ( err == KErrCancel )
   204             {
   207             {
   205             err = KErrNone;
   208             err = KErrNone;
   206             }
   209             }
   207         if ( !err )
   210         if ( !err )
   208             {
   211             {
   209             SetActive();
   212             if (iServer->State() != EStateIdle)
   210             TRequestStatus* status = &iStatus;
   213                 {
   211             User::RequestComplete( status , err );
   214                 if (iSearching)
   212             }
   215                     {
   213         }
   216                     SetActive();
   214     else
   217                     TRequestStatus* status = &iStatus;
       
   218                     User::RequestComplete(status, err);
       
   219                     }
       
   220                 else
       
   221                     {
       
   222                     iServer->CompleteScanning(err);
       
   223                     }
       
   224                 }
       
   225             else
       
   226                 {
       
   227                 CleanInternal();
       
   228                 }
       
   229             }
       
   230         }
       
   231     if ( err )
   215         {
   232         {
   216         CleanInternal();
   233         CleanInternal();
   217         iServer->CompleteScanning(err);
   234         iServer->CompleteScanning(err);
   218         Deque();
       
   219         }
       
   220     if ( err )
       
   221         {
       
   222         CleanInternal();
       
   223         iServer->CompleteScanning(err);
       
   224         Deque();
       
   225         }
   235         }
   226     }
   236     }
   227 
   237 
   228 
   238 
   229 
   239 
   235 //
   245 //
   236 TInt CFileScan::SearchContent( CDcfRepSrv* aServer )
   246 TInt CFileScan::SearchContent( CDcfRepSrv* aServer )
   237     {
   247     {
   238     TInt err = KErrNone;
   248     TInt err = KErrNone;
   239 
   249 
   240     iServer = aServer;
   250     if ( IsActive() )
   241     CActiveScheduler::Add( this );
   251         {
   242 
   252         err=KErrServerBusy;
   243     iSearching = ETrue;
   253         }
   244     err = SearchNext();
   254 
   245     if ( err )
   255     if ( !err )
   246         {
   256         {
   247         return err;
   257         iServer = aServer;
   248         }
   258         iSearching = ETrue;
   249     SetActive();
   259         SetActive();
   250     TRequestStatus* status = &iStatus;
   260         TRequestStatus* status = &iStatus;
   251     User::RequestComplete( status , KErrNone );
   261         User::RequestComplete( status , KErrNone );
       
   262         }
   252     return err;
   263     return err;
   253     }
   264     }
   254 
   265 
   255 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   256 // CFileScan::SearchDrive
   267 // CFileScan::SearchDrive