videofeeds/clientapi/src/CIptvMyVideosTotalVideoLengthObserver.cpp
branchRCL_3
changeset 23 befca0ec475f
parent 0 96612d01cf9f
equal deleted inserted replaced
22:839377eedc2b 23:befca0ec475f
       
     1 /*
       
     2 * Copyright (c) 2006 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 completed total video length requests.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <s32mem.h>
       
    22 #include "IptvClientServerCommon.h"
       
    23 #include "RIptvClientSession.h"
       
    24 #include "CIptvMyVideosTotalVideoLengthObserver.h"
       
    25 #include "MIptvMyVideosClientObserver.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KTUint32SizeInBytes = 4;
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // ---------------------------------------------------------
       
    33 // CIptvMyVideosTotalVideoLengthObserver::CIptvMyVideosTotalVideoLengthObserver()
       
    34 // ---------------------------------------------------------
       
    35 //
       
    36 CIptvMyVideosTotalVideoLengthObserver::CIptvMyVideosTotalVideoLengthObserver(MIptvMyVideosClientObserver& aClientObserver, RIptvClientSession& aSession) 
       
    37  :  CActive(EPriorityStandard),
       
    38     iClientObserver(aClientObserver),
       
    39     iSession(aSession),
       
    40     iMsgPtr((unsigned char*)0, 0)
       
    41     {
       
    42     CActiveScheduler::Add(this);
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // CIptvMyVideosTotalVideoLengthObserver::NewL()
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 CIptvMyVideosTotalVideoLengthObserver* CIptvMyVideosTotalVideoLengthObserver::NewL(MIptvMyVideosClientObserver& aClientObserver, RIptvClientSession& aSession)
       
    50     {
       
    51 	CIptvMyVideosTotalVideoLengthObserver* self = new (ELeave) CIptvMyVideosTotalVideoLengthObserver(aClientObserver, aSession);
       
    52 	CleanupStack::PushL(self);
       
    53 	self->ConstructL();
       
    54 	CleanupStack::Pop(self);
       
    55 	return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------
       
    59 // CIptvMyVideosTotalVideoLengthObserver::ConstructL()
       
    60 // ---------------------------------------------------------
       
    61 //
       
    62 void CIptvMyVideosTotalVideoLengthObserver::ConstructL()
       
    63     {
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // CIptvMyVideosTotalVideoLengthObserver::~CIptvMyVideosTotalVideoLengthObserver()
       
    68 // ---------------------------------------------------------
       
    69 //
       
    70 CIptvMyVideosTotalVideoLengthObserver::~CIptvMyVideosTotalVideoLengthObserver()
       
    71     {
       
    72     if ( IsActive() )
       
    73         {
       
    74         Cancel();
       
    75         }
       
    76 
       
    77     delete iMsg;
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CIptvMyVideosTotalVideoLengthObserver::SetActiveL()
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 void CIptvMyVideosTotalVideoLengthObserver::SetActiveL()
       
    85     {
       
    86     if (! IsActive())
       
    87         {
       
    88         delete iMsg;
       
    89         iMsg = NULL;
       
    90 
       
    91         iMsg = HBufC8::NewL(2 * KTUint32SizeInBytes);
       
    92         iMsgPtr.Set(iMsg->Des());
       
    93         iSession.SendRequest(EIptvEngineMyVideosGetTotalVideoLenghtRequestReq, iMsgPtr, iStatus);
       
    94         SetActive();        
       
    95         }
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // CIptvMyVideosTotalVideoLengthObserver::RunL()
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 void CIptvMyVideosTotalVideoLengthObserver::RunL()
       
   103     {
       
   104     if (iStatus.Int() == KErrNone)
       
   105         {
       
   106         TIptvPlayTime  playTime = 0;
       
   107         TIptvFileSize  fileSize = 0;
       
   108 
       
   109         if (iMsg)
       
   110             {
       
   111             RDesReadStream stream;
       
   112             stream.Open(iMsgPtr);
       
   113             CleanupClosePushL( stream );
       
   114             playTime = stream.ReadUint32L();
       
   115             fileSize = stream.ReadUint32L();
       
   116             CleanupStack::PopAndDestroy( &stream );
       
   117             }
       
   118             
       
   119         iClientObserver.TotalVideoLenghtResponse(playTime, fileSize);
       
   120         }
       
   121     // Inform client about errors too, otherwise it might stay waiting for ever.
       
   122     else
       
   123         {
       
   124         iClientObserver.TotalVideoLenghtResponse(0, 0);
       
   125         }
       
   126  
       
   127     delete iMsg;
       
   128     iMsg = NULL;
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------
       
   132 // CIptvMyVideosTotalVideoLengthObserver::DoCancel()
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 void CIptvMyVideosTotalVideoLengthObserver::DoCancel()
       
   136     {
       
   137     iClientObserver.TotalVideoLenghtResponse(0, 0);
       
   138     }
       
   139 
       
   140 // End of file.