videofeeds/clientapi/src/CIptvVodContentContentBriefDetails.cpp
branchRCL_3
changeset 23 befca0ec475f
parent 0 96612d01cf9f
equal deleted inserted replaced
22:839377eedc2b 23:befca0ec475f
       
     1 /*
       
     2 * Copyright (c) 2004-2005 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:    Defines data class structure for the API*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 #include <s32strm.h>
       
    23 #include "CIptvVodContentContentBriefDetails.h"
       
    24 #include "CIptvMyVideosGlobalFileId.h"
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KTUint32SizeInBytes = 4;
       
    28 const TInt KTUint16SizeInBytes = 2;
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // ---------------------------------------------------------
       
    33 // CIptvVodContentContentBriefDetails::ConstructL
       
    34 // Symbian 2nd phase constructor can leave.
       
    35 // ---------------------------------------------------------
       
    36 //
       
    37 void CIptvVodContentContentBriefDetails::ConstructL()
       
    38     {
       
    39     iFileId = CIptvMyVideosGlobalFileId::NewL();
       
    40     iPreviewGlobalFileId = CIptvMyVideosGlobalFileId::NewL();
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------
       
    44 // CIptvVodContentContentBriefDetails::NewL
       
    45 // Two-phased constructor.
       
    46 // ---------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CIptvVodContentContentBriefDetails* CIptvVodContentContentBriefDetails::NewL()
       
    49     {
       
    50     CIptvVodContentContentBriefDetails* self = new(ELeave) CIptvVodContentContentBriefDetails();
       
    51     CleanupStack::PushL(self);
       
    52 
       
    53     self->ConstructL();
       
    54 
       
    55     CleanupStack::Pop(self);
       
    56     return self;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CIptvVodContentContentBriefDetails::~CIptvVodContentContentBriefDetails
       
    61 // Destructor
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CIptvVodContentContentBriefDetails::~CIptvVodContentContentBriefDetails()
       
    65     {    
       
    66     delete iFileId;    
       
    67     delete iPreviewGlobalFileId;
       
    68     delete iBrowserUrl;
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CIptvVodContentContentBriefDetails::CIptvVodContentContentBriefDetails
       
    73 // C++ default constructor
       
    74 // ---------------------------------------------------------
       
    75 //
       
    76 CIptvVodContentContentBriefDetails::CIptvVodContentContentBriefDetails()
       
    77     {
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // Set browser URL
       
    82 // 
       
    83 // -----------------------------------------------------------------------------
       
    84 //    
       
    85 EXPORT_C void CIptvVodContentContentBriefDetails::SetBrowserUrlL(const TDesC& aBrowserUrl)
       
    86     {
       
    87     if (aBrowserUrl.Length() > 0)
       
    88         {
       
    89         delete iBrowserUrl;
       
    90         iBrowserUrl = NULL;
       
    91         iBrowserUrl = HBufC::NewL(aBrowserUrl.Length());
       
    92         TPtr16 p = iBrowserUrl->Des();
       
    93         p.Copy(aBrowserUrl);    
       
    94         }
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // Get browser URL
       
    99 // 
       
   100 // -----------------------------------------------------------------------------
       
   101 //  
       
   102 EXPORT_C TPtrC CIptvVodContentContentBriefDetails::GetBrowserUrlL()
       
   103     {
       
   104     if (iBrowserUrl)
       
   105         {
       
   106         return iBrowserUrl->Des();
       
   107         }
       
   108           
       
   109     return TPtrC();
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // Externalize
       
   114 // 
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 EXPORT_C void CIptvVodContentContentBriefDetails::ExternalizeL(RWriteStream& aStream) const
       
   118     {
       
   119     // Global file id
       
   120     iFileId->ExternalizeL(aStream);
       
   121 
       
   122     // Preview global file id
       
   123     iPreviewGlobalFileId->ExternalizeL(aStream);
       
   124 
       
   125     // Content ID indetifier.
       
   126     aStream.WriteUint32L(iContentId);
       
   127     
       
   128     // Content name
       
   129     CIptvUtil::WriteDesToStreamL(iName, aStream);
       
   130         
       
   131     // Complete thumbnail load path.
       
   132     CIptvUtil::WriteDesToStreamL(iThumbnailPath, aStream);
       
   133 
       
   134     // PubDate
       
   135     TInt64 time = iPubDate.Int64();    
       
   136     TUint32 lower = (0x00000000FFFFFFFFULL) & time;
       
   137     TUint32 upper = (0x00000000FFFFFFFFULL) & (time >> 32);
       
   138     aStream.WriteUint32L(lower);
       
   139     aStream.WriteUint32L(upper);
       
   140 
       
   141     // Browser url
       
   142     if (iBrowserUrl)
       
   143         {
       
   144         CIptvUtil::WriteDesToStreamL(*iBrowserUrl, aStream);
       
   145         }
       
   146     else
       
   147         {
       
   148         aStream.WriteUint16L(0);
       
   149         }    
       
   150 
       
   151     // Size
       
   152     aStream.WriteUint32L(iSize);    
       
   153 
       
   154     // Duration (playtime)
       
   155     aStream.WriteUint32L(iPlaytime);    
       
   156 
       
   157     // Language
       
   158     CIptvUtil::WriteDesToStreamL(iLanguage, aStream);
       
   159 
       
   160     // Rating age.
       
   161     aStream.WriteUint16L( iRatingAge );
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // Internalize
       
   166 // 
       
   167 // ---------------------------------------------------------
       
   168 //
       
   169 EXPORT_C void CIptvVodContentContentBriefDetails::InternalizeL(RReadStream& aStream)
       
   170     {
       
   171     // Global file id
       
   172     iFileId->InternalizeL(aStream);
       
   173 
       
   174     // Preview global file id
       
   175     iPreviewGlobalFileId->InternalizeL(aStream);
       
   176 
       
   177     // Content ID indetifier.
       
   178     iContentId = aStream.ReadUint32L();
       
   179 
       
   180     // Content name
       
   181     CIptvUtil::ReadDesFromStreamL(iName, aStream);
       
   182     
       
   183     // Thumbnail path
       
   184     CIptvUtil::ReadDesFromStreamL(iThumbnailPath, aStream);
       
   185 
       
   186     // PubDate
       
   187     TUint32 lower = aStream.ReadUint32L();
       
   188     TUint32 upper = aStream.ReadUint32L();
       
   189     TInt64 time = 0;
       
   190     time = lower;    
       
   191     TInt64 longUpper = (TInt64) upper;
       
   192     longUpper = longUpper << 32;        
       
   193     longUpper &= (0xFFFFFFFF00000000ULL);
       
   194     time |= longUpper;
       
   195     iPubDate = time;
       
   196 
       
   197     // Browser url
       
   198     delete iBrowserUrl;
       
   199     iBrowserUrl = NULL;
       
   200     iBrowserUrl = HBufC::NewL(KIptvEpgContentBrowserUrlMaxLength);
       
   201     TPtr16 p = iBrowserUrl->Des();
       
   202     CIptvUtil::ReadDesFromStreamL(p, aStream);
       
   203     iBrowserUrl = iBrowserUrl->ReAllocL(iBrowserUrl->Length());
       
   204 
       
   205     // Size
       
   206     iSize = aStream.ReadUint32L();
       
   207 
       
   208     // Duration (playtime)
       
   209     iPlaytime = aStream.ReadUint32L();
       
   210 
       
   211     // Language
       
   212     CIptvUtil::ReadDesFromStreamL(iLanguage, aStream);
       
   213 
       
   214     // Rating age.
       
   215     iRatingAge = aStream.ReadUint16L();
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------
       
   219 // Count externalized size
       
   220 // 
       
   221 // ---------------------------------------------------------
       
   222 //
       
   223 EXPORT_C TUint32 CIptvVodContentContentBriefDetails::CountExternalizeSize()
       
   224     {    
       
   225     TUint32 size           = 0;
       
   226     TUint32 browserUrlSize = 0;
       
   227     
       
   228     if (iBrowserUrl)
       
   229         {
       
   230         browserUrlSize = (iBrowserUrl->Length() * 2);
       
   231         }
       
   232 
       
   233     // Global file id
       
   234     size = iFileId->CountExternalizeSize() +
       
   235 
       
   236     // Preview global file id
       
   237     iPreviewGlobalFileId->CountExternalizeSize() +
       
   238 
       
   239     // Content ID indetifier.
       
   240     KTUint32SizeInBytes +    
       
   241 
       
   242     // Content name
       
   243     KTUint16SizeInBytes + (iName.Length() * 2) +
       
   244     
       
   245     // Thumbnail path
       
   246     KTUint16SizeInBytes + (iThumbnailPath.Length() * 2) +
       
   247 
       
   248     // pubDate
       
   249     ( KTUint32SizeInBytes * 2 ) +
       
   250 
       
   251     // Browser url
       
   252     KTUint16SizeInBytes + browserUrlSize +
       
   253 
       
   254     // Size
       
   255     KTUint32SizeInBytes +
       
   256 
       
   257     // Duration (playtime)
       
   258     KTUint32SizeInBytes +
       
   259 
       
   260     // Language
       
   261     KTUint16SizeInBytes + (iLanguage.Length() * 2) +
       
   262 
       
   263     // Rating age.
       
   264     KTUint16SizeInBytes;
       
   265     
       
   266     return size;
       
   267     }
       
   268 
       
   269 // End of file.