browserutilities/feedsengine/FeedsServer/Client/src/Enclosure.cpp
changeset 0 dd21522fd290
child 25 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 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:  Holds information about a feed encloures.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "FeedAttributes.h"
       
    20 #include "FeedsServerFeed.h"
       
    21 #include "Logger.h"
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 // CEnclosure::NewL
       
    25 //
       
    26 // Two-phased constructor.
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CEnclosure* CEnclosure::NewL(CFeedsEntity* aFeedsEntity)
       
    30     {
       
    31     CEnclosure* self = new (ELeave) CEnclosure(aFeedsEntity);
       
    32 
       
    33     CleanupStack::PushL(self);
       
    34 
       
    35     self->ConstructL();
       
    36     CleanupStack::Pop();
       
    37 
       
    38     return self;
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CEnclosure::CEnclosure
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CEnclosure::CEnclosure(CFeedsEntity* aFeedsEntity):iLeakTracker(CLeakTracker::EEnclosure),
       
    48         iFeedsEntity(aFeedsEntity), iContentType(KNullDesC), 
       
    49         iSize(KNullDesC), iUrl(KNullDesC)
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CEnclosure::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CEnclosure::ConstructL()
       
    59     {
       
    60     TPtrC aContentType;
       
    61     TPtrC aSize;
       
    62     TPtrC aUrl;
       
    63 
       
    64     iFeedsEntity->GetStringValue( EEnclosureAttributeContentType, aContentType);
       
    65     SetAttribute( EEnclosureAttributeContentType, aContentType);
       
    66 
       
    67     iFeedsEntity->GetStringValue( EEnclosureAttributeSize, aSize);  
       
    68     SetAttribute( EEnclosureAttributeSize, aSize);
       
    69 
       
    70     iFeedsEntity->GetStringValue( EEnclosureAttributeLink, aUrl);  
       
    71     SetAttribute( EEnclosureAttributeLink, aUrl);    
       
    72 
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CEnclosure::~CEnclosure
       
    77 // Deconstructor.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CEnclosure::~CEnclosure()
       
    81     {
       
    82     }
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CEnclosure::ContentType
       
    87 //
       
    88 // Returns the ContentType.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C const TDesC& CEnclosure::ContentType() const
       
    92     {  
       
    93     return iContentType;
       
    94     }
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CEnclosure::Size
       
    99 //
       
   100 // Returns the Size.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 EXPORT_C const TDesC& CEnclosure::Size() const
       
   104     {
       
   105     return iSize;
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CEnclosure::Url
       
   110 //
       
   111 // Returns the url.
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 EXPORT_C const TDesC& CEnclosure::Url() const
       
   115     {           
       
   116     return iUrl;
       
   117     }
       
   118 
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CEnclosure::SetAttribute
       
   122 //
       
   123 // Sets an attribute.
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void CEnclosure::SetAttribute(TUint aAttribute, const TPtrC& aAttributeValue)
       
   127     {
       
   128     switch (aAttribute)
       
   129         {
       
   130         case EEnclosureAttributeContentType:
       
   131             iContentType.Set( aAttributeValue);
       
   132             break;
       
   133 
       
   134         case EEnclosureAttributeSize:
       
   135             iSize.Set( aAttributeValue);
       
   136             break;
       
   137 
       
   138         case EEnclosureAttributeLink:
       
   139             iUrl.Set( aAttributeValue);
       
   140             break;
       
   141 
       
   142         default:
       
   143             break;
       
   144         }
       
   145     }
       
   146 
       
   147 
       
   148 //#ifdef _DEBUG
       
   149 // -----------------------------------------------------------------------------
       
   150 // CEnclosure::Debug_Print
       
   151 //
       
   152 // Prints the item to the log file.
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 EXPORT_C void CEnclosure::Debug_Print(void) const
       
   156     {
       
   157     FEED_LOG(_L("Feeds"), _L("Feeds_Dump.log"), 
       
   158         EFileLoggingModeAppend, _L("\tItem:"));
       
   159 
       
   160     if (iContentType.Length() > 0)
       
   161         {
       
   162         FEED_LOG1(_L("Feeds"), _L("Feeds_Dump.log"), 
       
   163             EFileLoggingModeAppend, _L("\t\tTitle: %S"), &iContentType);
       
   164         }
       
   165 
       
   166     if (iSize.Length() > 0)
       
   167         {
       
   168         FEED_LOG1(_L("Feeds"), _L("Feeds_Dump.log"), 
       
   169             EFileLoggingModeAppend, _L("\t\tSize: %S"), &iSize);
       
   170         }
       
   171 
       
   172     if (iUrl.Length() > 0)
       
   173         {
       
   174         FEED_LOG1(_L("Feeds"), _L("Feeds_Dump.log"), 
       
   175             EFileLoggingModeAppend, _L("\t\tLink: %S"), &iUrl);
       
   176         }
       
   177     }