videofeeds/clientapi/src/CIptvMyVideosContentUpdateObserver.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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 the License "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:    Observer for content updates from server.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <s32mem.h>
       
    22 #include "IptvDebug.h"
       
    23 
       
    24 #include "IptvClientServerCommon.h"
       
    25 #include "RIptvClientSession.h"
       
    26 #include "CIptvMyVideosContentUpdateObserver.h"
       
    27 #include "MIptvMyVideosClientObserver.h"
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CIptvMyVideosContentUpdateObserver::CIptvMyVideosContentUpdateObserver()
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CIptvMyVideosContentUpdateObserver::CIptvMyVideosContentUpdateObserver(
       
    36     MIptvMyVideosClientObserver& aClientObserver,
       
    37     RIptvClientSession& aSession )
       
    38  :  CActive( EPriorityStandard ),
       
    39     iClientObserver( aClientObserver ),
       
    40     iSession( aSession ),
       
    41     iObserverMsgPtr( static_cast<unsigned char*>( 0 ), 0 )
       
    42     {
       
    43     CActiveScheduler::Add( this );
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CIptvMyVideosContentUpdateObserver::NewL()
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CIptvMyVideosContentUpdateObserver* CIptvMyVideosContentUpdateObserver::NewL(
       
    51     MIptvMyVideosClientObserver& aClientObserver,
       
    52     RIptvClientSession& aSession )
       
    53     {
       
    54     CIptvMyVideosContentUpdateObserver* self =
       
    55         new ( ELeave ) CIptvMyVideosContentUpdateObserver(
       
    56             aClientObserver, aSession );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CIptvMyVideosContentUpdateObserver::ConstructL()
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CIptvMyVideosContentUpdateObserver::ConstructL()
       
    68     {
       
    69     SendObserverRequestL();
       
    70     SetActive();
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CIptvMyVideosContentUpdateObserver::~CIptvMyVideosContentUpdateObserver()
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CIptvMyVideosContentUpdateObserver::~CIptvMyVideosContentUpdateObserver()
       
    78     {
       
    79     delete iObserverMsg;
       
    80     Cancel();
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CIptvMyVideosContentUpdateObserver::RunL()
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CIptvMyVideosContentUpdateObserver::RunL()
       
    88     {
       
    89     if ( iStatus.Int() == KErrNone )
       
    90         {
       
    91         MIptvMyVideosClientObserver::TIptvContentUpdatedEvent event;
       
    92 
       
    93         RDesReadStream stream;
       
    94         stream.Open( iObserverMsgPtr );
       
    95         CleanupClosePushL( stream );
       
    96 
       
    97         event.iEventType = static_cast<MIptvMyVideosClientObserver::TIptvContentUpdatedEventType>
       
    98             ( stream.ReadUint32L() );
       
    99         event.iDrive = stream.ReadUint32L();
       
   100         event.iFileId = stream.ReadUint32L();
       
   101         CleanupStack::PopAndDestroy( &stream );
       
   102 
       
   103         iClientObserver.ContentsUpdated( event );
       
   104 
       
   105         // Only set active if previous completed without error. Otherwise
       
   106         // we make eternal loop; client sending new messages and server
       
   107         // completing them instantly with error.
       
   108         SendObserverRequestL();
       
   109         SetActive();
       
   110         }
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CIptvMyVideosContentUpdateObserver::SendObserverRequestL
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CIptvMyVideosContentUpdateObserver::SendObserverRequestL()
       
   118     {
       
   119     IPTVLOGSTRING_LOW_LEVEL(
       
   120         "CIptvMyVideosContentUpdateObserver::SendObserverRequestL" );
       
   121 
       
   122     delete iObserverMsg;
       
   123     iObserverMsg = NULL;
       
   124 
       
   125     iObserverMsg = HBufC8::NewL( KIptvMyVideosObserverRequestSize );
       
   126     iObserverMsgPtr.Set( iObserverMsg->Des() );
       
   127 
       
   128     iSession.SendRequest(
       
   129         EIptvEngineMyVideosContentUpdateReq,
       
   130         iObserverMsgPtr,
       
   131         iStatus );
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // CIptvMyVideosContentUpdateObserver::DoCancel()
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 void CIptvMyVideosContentUpdateObserver::DoCancel()
       
   139     {
       
   140     }