upnpavcontroller/upnpavcontrollerhelper/src/upnpabstractbrowsingsessionobserver.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 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:      An abstract browsing session observer implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include "upnpavbrowsingsession.h"
       
    25 #include "upnpavbrowsingsessionobserver.h"
       
    26 
       
    27 #include "upnpabstractbrowsingsessionobserver.h"
       
    28 
       
    29 _LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
       
    30 #include "upnplog.h"
       
    31 
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 
       
    36 // METHODS
       
    37 
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // CUPnPAbstractBrowsingSessionObserver::CUPnPAbstractBrowsingSessionObserver
       
    41 //---------------------------------------------------------------------------
       
    42 EXPORT_C CUPnPAbstractBrowsingSessionObserver::
       
    43     CUPnPAbstractBrowsingSessionObserver()
       
    44     {
       
    45     }
       
    46 
       
    47 
       
    48 // --------------------------------------------------------------------------
       
    49 // CUPnPAbstractBrowsingSessionObserver::~CUPnPAbstractBrowsingSessionObserver
       
    50 //---------------------------------------------------------------------------
       
    51 EXPORT_C CUPnPAbstractBrowsingSessionObserver::
       
    52     ~CUPnPAbstractBrowsingSessionObserver()
       
    53     {
       
    54     DisableSessionObserver();
       
    55     }
       
    56 
       
    57 
       
    58 // --------------------------------------------------------------------------
       
    59 // CUPnPAbstractBrowsingSessionObserver::SetSession
       
    60 //---------------------------------------------------------------------------
       
    61 EXPORT_C void CUPnPAbstractBrowsingSessionObserver::SetSession(
       
    62     MUPnPAVBrowsingSession& aHostSession )
       
    63     {
       
    64     // observer bust be disabled when calling this!
       
    65     __ASSERTD( !iObserverEnabled, __FILE__, __LINE__ );
       
    66     iObservedSession = &aHostSession;
       
    67     }
       
    68 
       
    69 
       
    70 
       
    71 // --------------------------------------------------------------------------
       
    72 // CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver
       
    73 //---------------------------------------------------------------------------
       
    74 EXPORT_C void CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver()
       
    75     {
       
    76     __LOG( "AbstractObserver:EnableSessionObserver()" );
       
    77     if ( !iObserverEnabled )
       
    78         {
       
    79         // take original observer as proxy
       
    80         iProxyObserver = iObservedSession->Observer();
       
    81         iObservedSession->RemoveObserver();
       
    82         iObservedSession->SetObserver( *this );
       
    83         iObserverEnabled = ETrue;
       
    84         }
       
    85     }
       
    86 
       
    87 // --------------------------------------------------------------------------
       
    88 // CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver
       
    89 //---------------------------------------------------------------------------
       
    90 EXPORT_C void CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver()
       
    91     {
       
    92     if ( iObserverEnabled )
       
    93         {
       
    94         __LOG( "AbstractObserver:DisableSessionObserver()" );
       
    95         __ASSERTD( iObservedSession != 0, __FILE__, __LINE__ );
       
    96         // check we still are still the observer !!!
       
    97         if ( iObservedSession->Observer() == this )
       
    98             {
       
    99             iObservedSession->RemoveObserver();
       
   100             if ( iProxyObserver )
       
   101                 {
       
   102                 // set proxy observer back
       
   103                 iObservedSession->SetObserver( *iProxyObserver );
       
   104                 iProxyObserver = 0;
       
   105                 }
       
   106             }
       
   107         else
       
   108             {
       
   109             __LOG( "Disable: Not disabling - wrong observer!" );
       
   110             }
       
   111         iObserverEnabled = EFalse;
       
   112         }
       
   113     }
       
   114 
       
   115 // --------------------------------------------------------------------------
       
   116 // CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled
       
   117 //---------------------------------------------------------------------------
       
   118 EXPORT_C TBool CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled()
       
   119     {
       
   120     return iObserverEnabled;
       
   121     }
       
   122 
       
   123 
       
   124 // --------------------------------------------------------------------------
       
   125 // CUPnPAbstractBrowsingSessionObserver::BrowseResponse
       
   126 //---------------------------------------------------------------------------
       
   127 void CUPnPAbstractBrowsingSessionObserver::BrowseResponse(
       
   128     const TDesC8& aBrowseResponse,
       
   129     TInt aError,
       
   130     TInt aMatches,
       
   131     TInt aTotalCount,
       
   132     const TDesC8& aUpdateId )
       
   133     {
       
   134     __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
       
   135     if ( iProxyObserver )
       
   136         {
       
   137         iProxyObserver->BrowseResponse( aBrowseResponse, aError,
       
   138             aMatches, aTotalCount, aUpdateId );
       
   139         }
       
   140     }
       
   141 
       
   142 // --------------------------------------------------------------------------
       
   143 // CUPnPAbstractBrowsingSessionObserver::SearchResponse
       
   144 //---------------------------------------------------------------------------
       
   145 void CUPnPAbstractBrowsingSessionObserver::SearchResponse( 
       
   146     const TDesC8& aSearchResponse,
       
   147     TInt aError,
       
   148     TInt aMatches,
       
   149     TInt aTotalCount,
       
   150     const TDesC8& aUpdateId )
       
   151     {
       
   152     __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
       
   153     if ( iProxyObserver )
       
   154         {
       
   155         iProxyObserver->SearchResponse( aSearchResponse, aError,
       
   156             aMatches, aTotalCount, aUpdateId );
       
   157         }
       
   158     }
       
   159 
       
   160 // --------------------------------------------------------------------------
       
   161 // CUPnPAbstractBrowsingSessionObserver::SearchCapabilitiesResponse
       
   162 //---------------------------------------------------------------------------
       
   163 void CUPnPAbstractBrowsingSessionObserver::SearchCapabilitiesResponse( 
       
   164     TInt aError,
       
   165     const TDesC8& aSearchCapabilities )
       
   166     {
       
   167     __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
       
   168     if ( iProxyObserver )
       
   169         {
       
   170         iProxyObserver->SearchCapabilitiesResponse(
       
   171             aError, aSearchCapabilities );
       
   172         }
       
   173     }
       
   174 
       
   175 // --------------------------------------------------------------------------
       
   176 // CUPnPAbstractBrowsingSessionObserver::CreateContainerResponse
       
   177 //---------------------------------------------------------------------------
       
   178 void CUPnPAbstractBrowsingSessionObserver::CreateContainerResponse(
       
   179     TInt aError, 
       
   180     const TDesC8& aObjectId )
       
   181     {
       
   182     __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
       
   183     if ( iProxyObserver )
       
   184         {
       
   185         iProxyObserver->CreateContainerResponse( aError, aObjectId );
       
   186         }
       
   187     }
       
   188 
       
   189 // --------------------------------------------------------------------------
       
   190 // CUPnPAbstractBrowsingSessionObserver::DeleteObjectResponse
       
   191 //---------------------------------------------------------------------------
       
   192 void CUPnPAbstractBrowsingSessionObserver::DeleteObjectResponse(
       
   193     TInt aError )
       
   194     {
       
   195     __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
       
   196     if ( iProxyObserver )
       
   197         {
       
   198         iProxyObserver->DeleteObjectResponse( aError );
       
   199         }
       
   200     }
       
   201 
       
   202 // --------------------------------------------------------------------------
       
   203 // CUPnPAbstractBrowsingSessionObserver::ReserveLocalMSServicesCompleted
       
   204 //---------------------------------------------------------------------------
       
   205 void CUPnPAbstractBrowsingSessionObserver::
       
   206     ReserveLocalMSServicesCompleted( TInt aError )
       
   207     {
       
   208     __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
       
   209     if ( iProxyObserver )
       
   210         {
       
   211         iProxyObserver->ReserveLocalMSServicesCompleted( aError );
       
   212         }
       
   213     }
       
   214 
       
   215 // --------------------------------------------------------------------------
       
   216 // CUPnPAbstractBrowsingSessionObserver::MediaServerDisappeared
       
   217 //---------------------------------------------------------------------------
       
   218 void CUPnPAbstractBrowsingSessionObserver::MediaServerDisappeared(
       
   219     TUPnPDeviceDisconnectedReason aReason )
       
   220     {
       
   221     __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
       
   222     if ( iProxyObserver )
       
   223         {
       
   224         iProxyObserver->MediaServerDisappeared( aReason );
       
   225         }
       
   226     }
       
   227 
       
   228