videocollection/mpxmyvideoscollection/src/vcxmyvideosmdsdb.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 37 4eb2df7f7cbe
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    76 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    78 //
    78 //
    79 void CVcxMyVideosMdsDb::ConstructL()
    79 void CVcxMyVideosMdsDb::ConstructL()
    80     {
    80     {
    81     MPX_FUNC( "CVcxMyVideosMdsDb::ConstructL" );
    81     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL start" );
    82 
    82 
    83     iCmdQueue = CVcxMyVideosMdsCmdQueue::NewL( *this );
    83     iCmdQueue = CVcxMyVideosMdsCmdQueue::NewL( *this );
    84 
    84 
    85     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
    85     iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
    86     
    86     
    87     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL CMdESession::NewL" );
    87     OpenMdsSessionL();
    88 
    88 
    89     //  Create session
    89     //  Get the schema definitions
       
    90     GetSchemaDefinitionsL();
       
    91         
       
    92     iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver );
       
    93     
       
    94     TCallBack callBack( AsyncHandleQueryCompleted, this );    
       
    95     iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack,
       
    96             CActive::EPriorityStandard );
       
    97 
       
    98     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" );
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // CVcxMyVideosMdsDb::OpenMdsSessionL
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CVcxMyVideosMdsDb::OpenMdsSessionL()
       
   106     {
       
   107     MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL() start" );
       
   108 
    90     iMdsError = KErrNone;
   109     iMdsError = KErrNone;
    91 
   110 
    92     iMdsSession = CMdESession::NewL( *this );
   111     iMdsSession = CMdESession::NewL( *this );
    93     if (!iMdsSession)
   112     if ( !iMdsSession )
    94         {
   113         {
    95         //  Failed to create session, leave
   114         //  Failed to create session, leave
    96         User::Leave( iMdsError );
   115         User::Leave( iMdsError );
    97         }
   116         }
    98 
   117     
    99     //  Wait until session opened
       
   100     iActiveSchedulerWait->Start();
       
   101 
       
   102     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL iActiveSchedulerWait->Start done" );
       
   103 
       
   104     if ( iMdsError != KErrNone )
   118     if ( iMdsError != KErrNone )
   105         {
   119         {
   106         MPX_DEBUG2("Failed to create session to MDS: %d", iMdsError);
   120         MPX_DEBUG2("Failed to create session to MDS: %d", iMdsError);
   107         User::LeaveIfError( iMdsError );
   121         User::LeaveIfError( iMdsError );
   108         }
   122         }
   109 
   123 
   110     //  Get the schema definitions
   124     //  Wait until session opened
   111     iMdsError = KErrNone;
   125     iActiveSchedulerWait->Start();    
   112     GetSchemaDefinitionsL();
   126     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL iActiveSchedulerWait->Start done" );
   113 
   127 
   114     //  Is schema ok
   128     MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL Adding observers" );
   115     if ( iMdsError != KErrNone )
       
   116         {
       
   117         //  Schema not loaded, abort
       
   118         User::Leave( iMdsError );
       
   119         }
       
   120 
       
   121     MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL Adding observers" );
       
   122 
   129 
   123     // We order all object notifications. If we set video condition, then we wont
   130     // We order all object notifications. If we set video condition, then we wont
   124     // receive remove notifications at all (mds feature). Extra notifications
   131     // receive remove notifications at all (mds feature). Extra notifications
   125     // do not bother us much since we try to fetch the item from the db
   132     // do not bother us much since we try to fetch the item from the db
   126     // after the add notification anyways, and then we use video condition.
   133     // after the add notification anyways, and then we use video condition.
   127     // Eventually extra events are ignored.    
   134     // Eventually extra events are ignored.    
   128     iMdsSession->AddObjectObserverL( *this, NULL );
   135     iMdsSession->AddObjectObserverL( *this, NULL );
   129     
   136     
   130     iMdsSession->AddObjectPresentObserverL( *this );
   137     iMdsSession->AddObjectPresentObserverL( *this );
   131     
   138 
   132     iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver );
   139     MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL() exit" );
   133     
       
   134     TCallBack callBack( AsyncHandleQueryCompleted, this );    
       
   135     iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack,
       
   136             CActive::EPriorityStandard );
       
   137     }
   140     }
   138 
   141 
   139 // ---------------------------------------------------------------------------
   142 // ---------------------------------------------------------------------------
   140 // ---------------------------------------------------------------------------
   143 // ---------------------------------------------------------------------------
   141 //
   144 //
   190 //
   193 //
   191 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()
   194 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()
   192     {
   195     {
   193     MPX_FUNC( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()" );
   196     MPX_FUNC( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()" );
   194 
   197 
   195     Cancel();
   198     Cancel( EGetVideoList );
   196 
   199 
       
   200     delete iAlbums;
   197     delete iCmdQueue;    
   201     delete iCmdQueue;    
   198 
   202 
   199     if ( iMdsSession )
   203     if ( iMdsSession )
   200         {
   204         {
   201         TRAP_IGNORE( iMdsSession->RemoveObjectObserverL( *this ) );        
   205         TRAP_IGNORE( iMdsSession->RemoveObjectObserverL( *this ) );        
   202         }
   206         }
   203 
   207 
   204     delete iVideoQuery;
   208     delete iVideoQuery;
   205     delete iAlbums;
       
   206     delete iMdsSession;
   209     delete iMdsSession;
   207     delete iActiveSchedulerWait;
   210     delete iActiveSchedulerWait;
   208     delete iAsyncHandleQueryCompleteCaller;
   211     delete iAsyncHandleQueryCompleteCaller;
   209     }
   212     }
   210 
   213 
   212 // CVcxMyVideosMdsDb::Cancel
   215 // CVcxMyVideosMdsDb::Cancel
   213 // ---------------------------------------------------------------------------
   216 // ---------------------------------------------------------------------------
   214 //
   217 //
   215 void CVcxMyVideosMdsDb::Cancel( TRequestType aType )
   218 void CVcxMyVideosMdsDb::Cancel( TRequestType aType )
   216     {
   219     {
   217     MPX_FUNC("CVcxMyVideosMdsDb::Cancel()");
   220     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() start");
   218     
   221     
   219     iCmdQueue->Cancel( aType );
   222     iCmdQueue->Cancel( aType );
   220     
   223     
   221     if ( aType == EAll || aType == EGetVideoList )
   224     if ( aType == EAll || aType == EGetVideoList )
   222         {
   225         {
   225             iVideoQuery->Cancel();
   228             iVideoQuery->Cancel();
   226             }
   229             }
   227         iVideoListFetchingIsOngoing = EFalse;
   230         iVideoListFetchingIsOngoing = EFalse;
   228         }
   231         }
   229 
   232 
   230     iAlbums->Cancel( aType );    
   233     if ( aType != EGetVideoList )
       
   234         {
       
   235         iAlbums->CancelQueries( aType );
       
   236         }
       
   237     
       
   238     MPX_DEBUG1("CVcxMyVideosMdsDb::Cancel() exit");
   231     }
   239     }
   232     
   240     
   233 // ---------------------------------------------------------------------------
   241 // ---------------------------------------------------------------------------
   234 // CVcxMyVideosMdsDb::AddVideoL
   242 // CVcxMyVideosMdsDb::AddVideoL
   235 // ---------------------------------------------------------------------------
   243 // ---------------------------------------------------------------------------