videofeeds/clientapi/src/CIptvVodContentCategoryBriefDetails.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2004-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 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 category data class structure for the API*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <s32strm.h>
       
    22 #include "IptvDebug.h"
       
    23 #include "CIptvVodContentCategoryBriefDetails.h"
       
    24 
       
    25 const TInt KTUint32SizeInBytes( 4 );
       
    26 
       
    27 #ifdef _DEBUG
       
    28 
       
    29     _LIT( KIptvDatePrint, "%D%M%Y%/0%1%/1%2%/2%3%/3" );
       
    30     _LIT( KIptvTimePrint, "%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B" );
       
    31 
       
    32 #endif
       
    33 
       
    34 // ======== MEMBER FUNCTIONS ========
       
    35 
       
    36 // --------------------------------------------------------------------------
       
    37 // Two-phased constructor.
       
    38 // --------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C CIptvVodContentCategoryBriefDetails*
       
    41     CIptvVodContentCategoryBriefDetails::NewL()
       
    42     {
       
    43     CIptvVodContentCategoryBriefDetails* self =
       
    44         new ( ELeave ) CIptvVodContentCategoryBriefDetails();
       
    45 
       
    46     return self;
       
    47     }
       
    48 
       
    49 // --------------------------------------------------------------------------
       
    50 // C++ destructor
       
    51 // --------------------------------------------------------------------------
       
    52 //
       
    53 CIptvVodContentCategoryBriefDetails::~CIptvVodContentCategoryBriefDetails()
       
    54     {
       
    55     }
       
    56 
       
    57 // --------------------------------------------------------------------------
       
    58 // C++ default constructor
       
    59 // --------------------------------------------------------------------------
       
    60 //
       
    61 CIptvVodContentCategoryBriefDetails::CIptvVodContentCategoryBriefDetails()
       
    62     {
       
    63     }
       
    64 
       
    65 // --------------------------------------------------------------------------
       
    66 // Serialize data content to stream.
       
    67 // --------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C void CIptvVodContentCategoryBriefDetails::ExternalizeL(
       
    70     RWriteStream& aStream ) const
       
    71     {
       
    72     // Category Id
       
    73     aStream.WriteUint32L( iCategoryId );
       
    74 
       
    75     // Is search category
       
    76     aStream.WriteUint32L( iIsSearchCategory );
       
    77 
       
    78     // Category name
       
    79     CIptvUtil::WriteDesToStreamL( iName, aStream );
       
    80 
       
    81 #ifdef _DEBUG
       
    82 
       
    83     // PubDate
       
    84     TBuf<100> datePrint;
       
    85     iPubDate.FormatL( datePrint, KIptvDatePrint );
       
    86     IPTVLOGSTRING2_LOW_LEVEL(
       
    87         "CIptvVodContentCategoryBriefDetails::ExternalizeL -- Category publish date : %S",
       
    88         &datePrint );
       
    89 
       
    90     TBuf<100> timePrint;
       
    91     iPubDate.FormatL( timePrint, KIptvTimePrint );
       
    92     IPTVLOGSTRING2_LOW_LEVEL(
       
    93         "CIptvVodContentCategoryBriefDetails::ExternalizeL -- Category publish time : %S",
       
    94         &timePrint );
       
    95 
       
    96 #endif
       
    97 
       
    98     TInt64 time = iPubDate.Int64();    // Obsolete field
       
    99     TUint32 lower = static_cast<TInt32>( ( 0x00000000FFFFFFFFULL ) & time );
       
   100     TUint32 upper = static_cast<TInt32>( ( 0x00000000FFFFFFFFULL ) & ( time >> 32 ) );
       
   101     aStream.WriteUint32L( lower );
       
   102     aStream.WriteUint32L( upper );
       
   103 
       
   104     // Thumbnail path - Obsolete field
       
   105     CIptvUtil::WriteDesToStreamL( iThumbnailPath, aStream );
       
   106 
       
   107     // Content count
       
   108     aStream.WriteUint32L( iContentCount );
       
   109     }
       
   110 
       
   111 // --------------------------------------------------------------------------
       
   112 // Read serialized data content from stream.
       
   113 // --------------------------------------------------------------------------
       
   114 //
       
   115 EXPORT_C void CIptvVodContentCategoryBriefDetails::InternalizeL(
       
   116     RReadStream& aStream )
       
   117     {
       
   118     // Category Id
       
   119     iCategoryId = aStream.ReadUint32L();
       
   120 
       
   121     iIsSearchCategory = aStream.ReadUint32L();
       
   122 
       
   123     // Category name
       
   124     CIptvUtil::ReadDesFromStreamL( iName, aStream );
       
   125 
       
   126     // PubDate - Obsolete field
       
   127     TUint32 lower = aStream.ReadUint32L();
       
   128     TUint32 upper = aStream.ReadUint32L();
       
   129     TInt64 time = 0;
       
   130     time = static_cast<TInt64>( lower );
       
   131     TInt64 longUpper = static_cast<TInt64>( upper );
       
   132     longUpper = longUpper << 32;
       
   133     longUpper = longUpper & ( 0xFFFFFFFF00000000ULL );
       
   134     time |= longUpper;
       
   135     iPubDate = time;
       
   136 
       
   137 #ifdef _DEBUG
       
   138 
       
   139     TBuf<100> datePrint;
       
   140     iPubDate.FormatL( datePrint, KIptvDatePrint );
       
   141     IPTVLOGSTRING2_LOW_LEVEL(
       
   142         "CIptvVodContentCategoryBriefDetails::InternalizeL -- Category publish date : %S",
       
   143         &datePrint );
       
   144 
       
   145     TBuf<100> timePrint;
       
   146     iPubDate.FormatL( timePrint, KIptvTimePrint );
       
   147     IPTVLOGSTRING2_LOW_LEVEL(
       
   148         "CIptvVodContentCategoryBriefDetails::InternalizeL -- Category publish time : %S",
       
   149         &timePrint );
       
   150 
       
   151 #endif
       
   152 
       
   153     // Thumbnail path - Obsolete field
       
   154     CIptvUtil::ReadDesFromStreamL( iThumbnailPath, aStream );
       
   155 
       
   156     // Content count
       
   157     iContentCount = aStream.ReadUint32L();
       
   158     }
       
   159 
       
   160 // --------------------------------------------------------------------------
       
   161 // Count externalized size.
       
   162 // --------------------------------------------------------------------------
       
   163 //
       
   164 EXPORT_C TUint32 CIptvVodContentCategoryBriefDetails::CountExternalizeSize()
       
   165     {
       
   166     TUint32 size = 0;
       
   167 
       
   168     size =
       
   169         // Category Id
       
   170         KTUint32SizeInBytes +
       
   171 
       
   172         // iIsSearchCategory
       
   173         KTUint32SizeInBytes +
       
   174 
       
   175         // Name
       
   176         2 + ( iName.Length() * 2 ) +
       
   177 
       
   178         // PubDate - Obsolete field
       
   179         8 +
       
   180 
       
   181         // Thumbnail path - Obsolete field
       
   182         2 + ( iThumbnailPath.Length() * 2 ) +
       
   183 
       
   184         // Content count
       
   185         KTUint32SizeInBytes;
       
   186 
       
   187     return size;
       
   188     }