videofeeds/server/IptvSearchManager/src/CIptvContentIdMediaContentItem.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     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 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "CIptvMediaContent.h"
       
    22 
       
    23 #include "CIptvMyVideosGlobalFileId.h"
       
    24 #include "CIptvContentIdMediaContentItem.h"
       
    25 
       
    26 // ---------------------------------------------------------
       
    27 // CIptvContentIdMediaContentItem::NewL
       
    28 // 
       
    29 // ---------------------------------------------------------
       
    30 CIptvContentIdMediaContentItem* CIptvContentIdMediaContentItem::NewL()
       
    31 	{
       
    32 	CIptvContentIdMediaContentItem* self = new (ELeave) CIptvContentIdMediaContentItem();
       
    33 
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // CIptvContentIdMediaContentItem::CIptvContentIdMediaContentItem
       
    39 // 
       
    40 // ---------------------------------------------------------
       
    41 CIptvContentIdMediaContentItem::CIptvContentIdMediaContentItem()
       
    42 	{
       
    43 	}
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // CIptvContentIdMediaContentItem::~CIptvContentIdMediaContentItem
       
    47 // 
       
    48 // ---------------------------------------------------------
       
    49 CIptvContentIdMediaContentItem::~CIptvContentIdMediaContentItem()
       
    50 	{
       
    51 	iMediaContentArray.ResetAndDestroy();
       
    52 	}
       
    53 
       
    54 // ---------------------------------------------------------
       
    55 // CIptvContentIdMediaContentItem::SetMediaContentArrayL
       
    56 // 
       
    57 // ---------------------------------------------------------
       
    58 void CIptvContentIdMediaContentItem::SetMediaContentArrayL(
       
    59         RPointerArray<CIptvMediaContent>& aArray )
       
    60 	{
       
    61 	for( TInt i = 0; i < aArray.Count(); i++ )
       
    62 		{
       
    63 		CIptvMediaContent* original = aArray[i];
       
    64 		CIptvMediaContent* newContent = CIptvMediaContent::NewL();
       
    65 		CleanupStack::PushL( newContent );
       
    66 		CopyMediaContentL( *original, newContent );
       
    67 		newContent->iContentKey = iContentId;
       
    68 		iMediaContentArray.AppendL( newContent );
       
    69 		CleanupStack::Pop( newContent );
       
    70 		}
       
    71 	}
       
    72 	
       
    73 // ---------------------------------------------------------
       
    74 // CIptvContentIdMediaContentItem::CopyMediaContentL
       
    75 // 
       
    76 // ---------------------------------------------------------
       
    77 void CIptvContentIdMediaContentItem::CopyMediaContentL( CIptvMediaContent& aOriginal,
       
    78 														CIptvMediaContent* aNew )
       
    79 	{
       
    80     aNew->iContentKey = aOriginal.iContentKey;
       
    81     aNew->iIndex = aOriginal.iIndex;
       
    82     aNew->iDownloadType = aOriginal.iDownloadType;
       
    83     aNew->iFileId = aOriginal.iFileId;
       
    84     aNew->iDriveId = aOriginal.iDriveId;
       
    85     aNew->iFileSize = aOriginal.iFileSize; 
       
    86     aNew->iMimeType.Copy( aOriginal.iMimeType );
       
    87     aNew->iMedium.Copy( aOriginal.iMedium );
       
    88     aNew->iIsDefault = aOriginal.iIsDefault;
       
    89     aNew->iExpression = aOriginal.iExpression;
       
    90     aNew->iBitrate = aOriginal.iBitrate;
       
    91     aNew->iFramerate = aOriginal.iFramerate;
       
    92     aNew->iSamplingrate = aOriginal.iSamplingrate;
       
    93     aNew->iDuration = aOriginal.iDuration;  
       
    94     aNew->iHeight = aOriginal.iHeight;
       
    95     aNew->iWidth = aOriginal.iWidth;
       
    96     aNew->iLanguage.Copy( aOriginal.iLanguage );
       
    97     aNew->iLastPosition = aOriginal.iLastPosition;
       
    98     aNew->SetMediaContentUrlL( aOriginal.GetMediaContentUrl() );
       
    99 	}
       
   100 
       
   101 	
       
   102 // ---------------------------------------------------------
       
   103 // CIptvContentIdMediaContentItem::GetMediaContentsL
       
   104 // 
       
   105 // ---------------------------------------------------------
       
   106 void CIptvContentIdMediaContentItem::GetMediaContentsL( RPointerArray<CIptvMediaContent>& aArray )
       
   107 	{
       
   108 	for( TInt i = 0; i < iMediaContentArray.Count(); i++ )
       
   109 		{
       
   110 		CIptvMediaContent* original = iMediaContentArray[i];
       
   111 		CIptvMediaContent* newContent = CIptvMediaContent::NewL();
       
   112 		CleanupStack::PushL( newContent );
       
   113 		CopyMediaContentL( *original, newContent );
       
   114 		aArray.AppendL( newContent );
       
   115 		CleanupStack::Pop( newContent );
       
   116 		}
       
   117 	}
       
   118 
       
   119 // ---------------------------------------------------------
       
   120 // CIptvContentIdMediaContentItem::MediaContentByIndexL
       
   121 // 
       
   122 // ---------------------------------------------------------
       
   123 CIptvMediaContent* CIptvContentIdMediaContentItem::MediaContentByIndexL( TInt aIndex )
       
   124 	{
       
   125 	CIptvMediaContent* returnContent = NULL;
       
   126 	if( aIndex < iMediaContentArray.Count() )
       
   127 		{
       
   128 		CIptvMediaContent* content = iMediaContentArray[aIndex];
       
   129 		CleanupStack::PushL( content );
       
   130 		returnContent = CIptvMediaContent::NewL();
       
   131 		CopyMediaContentL( *content, returnContent );
       
   132 		CleanupStack::Pop( content );
       
   133 		}
       
   134 	return returnContent;
       
   135 	}
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CIptvContentIdMediaContentItem::SetContentId
       
   139 // 
       
   140 // ---------------------------------------------------------
       
   141 void CIptvContentIdMediaContentItem::SetContentId( TUint32 aContentId )
       
   142 	{
       
   143 	iContentId = aContentId;
       
   144 	}
       
   145 	
       
   146 // ---------------------------------------------------------
       
   147 // CIptvContentIdMediaContentItem::ContentId
       
   148 // 
       
   149 // ---------------------------------------------------------
       
   150 TUint32 CIptvContentIdMediaContentItem::ContentId() const
       
   151 	{
       
   152 	return iContentId;
       
   153 	}
       
   154 	
       
   155 // ---------------------------------------------------------
       
   156 // CIptvContentIdMediaContentItem::MediaContentCount
       
   157 // 
       
   158 // ---------------------------------------------------------
       
   159 TInt CIptvContentIdMediaContentItem::MediaContentCount() const
       
   160 	{
       
   161 	return iMediaContentArray.Count();
       
   162 	}
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // CIptvContentIdMediaContentItem::ResetGlobalId
       
   166 // 
       
   167 // ---------------------------------------------------------
       
   168 TInt CIptvContentIdMediaContentItem::ResetGlobalId( CIptvMyVideosGlobalFileId& aId )
       
   169 	{
       
   170 	TInt retVal = KErrNotFound;
       
   171 	for( TInt i = 0; i < iMediaContentArray.Count(); i++ )
       
   172 		{
       
   173 		CIptvMediaContent* content = iMediaContentArray[i]; // Owned by the array
       
   174 		if( content->iFileId == aId.iFileId &&
       
   175 			content->iDriveId == aId.iDrive )
       
   176 			{
       
   177 			content->iFileId = 0;
       
   178 			content->iDriveId = 0;
       
   179 			retVal = KErrNone;
       
   180 			i = iMediaContentArray.Count(); // break; would've done the same
       
   181 			}
       
   182 		}
       
   183 	return retVal;
       
   184 	}
       
   185 	
       
   186 // ---------------------------------------------------------
       
   187 // CIptvContentIdMediaContentItem::SetGlobalId
       
   188 // 
       
   189 // ---------------------------------------------------------
       
   190 TInt CIptvContentIdMediaContentItem::SetGlobalId( TUint32 aContentKey,
       
   191 					  							  CIptvMyVideosGlobalFileId& aId,
       
   192 					  							  TUint32 aIndex )
       
   193 	{
       
   194 	TInt retVal = KErrNotFound;
       
   195 	if( aContentKey == iContentId && aIndex < iMediaContentArray.Count() )
       
   196 		{
       
   197 		CIptvMediaContent* content = iMediaContentArray[aIndex]; // Owned by the array
       
   198 		content->iFileId = aId.iFileId;
       
   199 		content->iDriveId = aId.iDrive;
       
   200 		retVal = KErrNone;
       
   201 		}
       
   202 	return retVal;
       
   203 	}
       
   204 
       
   205 	
       
   206 // End of file