upnpsharing/applicationengine/src/upnpcontentrequestao.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:      CUpnpContentRequestAO class implementation
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 // System
       
    25 #include <s32file.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 // upnp stack api
       
    29 #include <upnpstring.h>
       
    30 
       
    31 // upnpframework / avcontroller api
       
    32 #include "upnpavcontrollerfactory.h"
       
    33 
       
    34 // homeconnect internal
       
    35 #include "upnpcontentrequestao.h"
       
    36 #include "upnpfilesharingengine.h"
       
    37 
       
    38 _LIT( KComponentLogfile, "applicationengine.txt");
       
    39 #include "upnplog.h"
       
    40 
       
    41 // ============================ MEMBER FUNCTIONS ============================
       
    42 
       
    43 // --------------------------------------------------------------------------
       
    44 // CUpnpContentRequestAO::CUpnpContentRequestAO
       
    45 // C++ default constructor can NOT contain any code, that
       
    46 // might leave.
       
    47 // --------------------------------------------------------------------------
       
    48 //
       
    49 CUpnpContentRequestAO::CUpnpContentRequestAO( 
       
    50     CUPnPFileSharingEngine& aEngine,
       
    51     RUpnpContentServerClient& aContentServer )
       
    52     : CActive( CActive::EPriorityStandard ),
       
    53       iEngine( aEngine ),
       
    54       iContentServer( aContentServer )
       
    55     {
       
    56     CActiveScheduler::Add( this );
       
    57     }
       
    58 
       
    59 // --------------------------------------------------------------------------
       
    60 // CUpnpContentRequestAO::~CUpnpContentRequestAO()
       
    61 // Destructor
       
    62 // --------------------------------------------------------------------------
       
    63 //
       
    64 CUpnpContentRequestAO::~CUpnpContentRequestAO()
       
    65     {
       
    66     if ( IsActive() )
       
    67         {
       
    68         __LOG( "CUpnpContentRequestAO destructor: IsActive == TRUE!" );
       
    69         TRequestStatus* stat = &iStatus;
       
    70         User::RequestComplete( stat, KErrNone );
       
    71         }
       
    72     
       
    73     Cancel();
       
    74     }
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 // CUpnpContentRequestAO::RequestSelectionContentL
       
    78 // ( other items are commented in header )
       
    79 // --------------------------------------------------------------------------
       
    80 //
       
    81 void CUpnpContentRequestAO::RequestSelectionContentL( 
       
    82     UpnpContentServer::TUpnpMediaType aType )
       
    83     {
       
    84     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::RequestSelectionContentL\
       
    85  begin");
       
    86 
       
    87     // check media server availibility
       
    88     if ( IsActive() ||
       
    89          UPnPAVControllerFactory::MSServicesInUse() )
       
    90         {
       
    91         User::Leave( KErrInUse );
       
    92         }
       
    93     iContentServer.GetSelectionContentL( aType, iStatus );
       
    94     SetActive();
       
    95     iState = ERequestContent;
       
    96  
       
    97     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::RequestSelectionContentL\
       
    98  end");
       
    99     }
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CUpnpContentRequestAO::GetSelectionContentL
       
   103 // ( other items are commented in header )
       
   104 // --------------------------------------------------------------------------
       
   105 //
       
   106 void CUpnpContentRequestAO::GetSelectionContentL( CDesCArray& aArray )
       
   107     {
       
   108     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::GetSelectionContentL\
       
   109  begin");
       
   110     
       
   111     if ( IsActive() )
       
   112         {
       
   113         User::Leave( KErrInUse );
       
   114         }
       
   115     iContentServer.GetSelectionContentResultL( aArray );
       
   116 
       
   117     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::GetSelectionContentL\
       
   118  end");
       
   119     }
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // CUpnpContentRequestAO::RequestSelectionIndexesL
       
   123 // ( other items are commented in header )
       
   124 // --------------------------------------------------------------------------
       
   125 //
       
   126 void CUpnpContentRequestAO::RequestSelectionIndexesL(
       
   127     UpnpContentServer::TUpnpMediaType aType )
       
   128     {
       
   129     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::RequestSelectionIndexesL\
       
   130  begin");
       
   131 
       
   132     if ( IsActive() )
       
   133         {
       
   134         User::Leave( KErrInUse );
       
   135         }
       
   136     iContentServer.GetSelectionIndexesL( aType, iStatus );
       
   137     SetActive();
       
   138     iState = ERequestIndexes;
       
   139 
       
   140     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::RequestSelectionIndexesL\
       
   141  end");
       
   142     }
       
   143 
       
   144 // --------------------------------------------------------------------------
       
   145 // CUpnpContentRequestAO::GetSelectionIndexesL
       
   146 // ( other items are commented in header )
       
   147 // --------------------------------------------------------------------------
       
   148 //
       
   149 void CUpnpContentRequestAO::GetSelectionIndexesL(
       
   150     CArrayFix<TInt>& aCurrentSelection )
       
   151     {
       
   152     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::GetSelectionIndexesL\
       
   153  begin");
       
   154 
       
   155     if ( IsActive() )
       
   156         {
       
   157         User::Leave( KErrInUse );
       
   158         }
       
   159     iContentServer.GetSelectionIndexesResultL( aCurrentSelection );
       
   160 
       
   161     __LOG("[UPNP_ENGINE]\t CUpnpContentRequestAO::GetSelectionIndexesL\
       
   162  end");
       
   163     }
       
   164 
       
   165 // --------------------------------------------------------------------------
       
   166 // CUpnpContentRequestAO::RunL
       
   167 // Called when asyncronous request is ready
       
   168 // --------------------------------------------------------------------------
       
   169 //
       
   170 void CUpnpContentRequestAO::RunL()
       
   171     {
       
   172     __LOG1("[UPNP_ENGINE]\t CUpnpContentRequestAO::RunL, error=%d", 
       
   173         iStatus.Int());
       
   174 
       
   175     TState state( iState );
       
   176     iState = ENone;
       
   177 
       
   178     if ( iStatus.Int() )
       
   179         {
       
   180         __LOG1("CUpnpContentRequestAO::RunL: Error %d in iStatus",
       
   181             iStatus.Int() );
       
   182         }
       
   183 
       
   184     if ( iEngine.Observer() )
       
   185         {
       
   186         if ( state == ERequestContent )
       
   187             {
       
   188             iEngine.Observer()->HandleSelectionContent( 
       
   189                 iEngine, iStatus.Int() );
       
   190             }
       
   191         else if ( state == ERequestIndexes )
       
   192             {
       
   193             iEngine.Observer()->HandleSelectionIndexes( 
       
   194                 iEngine, iStatus.Int() ); 
       
   195             }
       
   196         else
       
   197             {
       
   198             __PANICD( __FILE__, __LINE__ );
       
   199             }
       
   200         }
       
   201     }
       
   202 
       
   203 // --------------------------------------------------------------------------
       
   204 // CUpnpContentRequestAO::DoCancel
       
   205 // Cancels the active request
       
   206 // --------------------------------------------------------------------------
       
   207 //
       
   208 void CUpnpContentRequestAO::DoCancel()
       
   209     {
       
   210     }
       
   211 
       
   212 // End of file