upnpsharing/upnpsharingalgorithm/src/upnpcdsliteobject.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
       
     1 /*
       
     2 * Copyright (c) 2009 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 "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: Implementation of CUpnpCdsLiteObject
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "upnpcdsliteobject.h"
       
    20 #include "upnpsharingalgorithmconstants.h"
       
    21 #include "upnplog.h"
       
    22 
       
    23 // --------------------------------------------------------------------------
       
    24 // CUpnpCdsLiteObject::NewL
       
    25 // --------------------------------------------------------------------------
       
    26 //
       
    27 EXPORT_C CUpnpCdsLiteObject* CUpnpCdsLiteObject::NewL( const TDesC8 &aName,
       
    28                                               const TCdsLiteObjectType aType,
       
    29                                               const TDesC8 &aObjectId,
       
    30                                               const TDesC8 &aParentId,
       
    31                                               const TDesC8 &aObjectClass )
       
    32     {
       
    33     __LOG( "[CUpnpSharingAlgorithm]\t CUpnpCdsLiteObject::NewL" );
       
    34 
       
    35     // Verify the validity of the parameters
       
    36     if( aName == KNullDesC8 ||
       
    37         aObjectId == KNullDesC8 ||
       
    38         aParentId == KNullDesC8 ||
       
    39         aObjectClass == KNullDesC8 ||
       
    40         ( aType != EContainer &&
       
    41           aType != EItem &&
       
    42           aType != EItemReference ) )
       
    43         {
       
    44         User::Leave( KErrArgument );
       
    45         }
       
    46 
       
    47     CUpnpCdsLiteObject* self = new ( ELeave ) CUpnpCdsLiteObject();
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL( aName, aType, aObjectId, aParentId, aObjectClass );
       
    50     CleanupStack::Pop( self );
       
    51 
       
    52     return self;
       
    53     }
       
    54 
       
    55 // --------------------------------------------------------------------------
       
    56 // CUpnpCdsLiteObject::CUpnpCdsLiteObject
       
    57 // --------------------------------------------------------------------------
       
    58 //
       
    59 CUpnpCdsLiteObject::CUpnpCdsLiteObject()
       
    60     {
       
    61     iType = EUnknown;
       
    62     iName = NULL;
       
    63     iObjectId = NULL;
       
    64     iParentId = NULL;
       
    65     iObjectClass = NULL;
       
    66     iOriginalItemId = NULL;
       
    67     }
       
    68 
       
    69 // --------------------------------------------------------------------------
       
    70 // CUpnpCdsLiteObject::~CUpnpCdsLiteObject
       
    71 // --------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C CUpnpCdsLiteObject::~CUpnpCdsLiteObject()
       
    74     {
       
    75     __LOG( "[CUpnpSharingAlgorithm]\t CUpnpCdsLiteObject::\
       
    76 ~CUpnpCdsLiteObject" );
       
    77     delete iName;
       
    78     iName = NULL;
       
    79 
       
    80     delete iObjectId;
       
    81     iObjectId = NULL;
       
    82 
       
    83     delete iParentId;
       
    84     iParentId = NULL;
       
    85 
       
    86     delete iObjectClass;
       
    87     iObjectClass = NULL;
       
    88 
       
    89     delete iOriginalItemId;
       
    90     iOriginalItemId = NULL;
       
    91     }
       
    92 
       
    93 // --------------------------------------------------------------------------
       
    94 // CUpnpCdsLiteObject::ConstructL
       
    95 // --------------------------------------------------------------------------
       
    96 //
       
    97 void CUpnpCdsLiteObject::ConstructL( const TDesC8 &aName,
       
    98                                      const TCdsLiteObjectType aType,
       
    99                                      const TDesC8 &aObjectId,
       
   100                                      const TDesC8 &aParentId,
       
   101                                      const TDesC8 &aObjectClass )
       
   102     {
       
   103     __LOG( "[CUpnpSharingAlgorithm]\t CUpnpCdsLiteObject::ConstructL" );
       
   104 
       
   105     iType = aType;
       
   106     iName = aName.AllocL();
       
   107     iObjectId = aObjectId.AllocL();
       
   108     iParentId = aParentId.AllocL();
       
   109     iObjectClass = aObjectClass.AllocL();
       
   110     }
       
   111 
       
   112 // --------------------------------------------------------------------------
       
   113 // CUpnpCdsLiteObject::Name
       
   114 // --------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C TDesC8& CUpnpCdsLiteObject::Name()
       
   117     {
       
   118     return *iName;
       
   119     }
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // CUpnpCdsLiteObject::Type
       
   123 // --------------------------------------------------------------------------
       
   124 //
       
   125 EXPORT_C CUpnpCdsLiteObject::TCdsLiteObjectType CUpnpCdsLiteObject::Type()
       
   126     {
       
   127     return iType;
       
   128     }
       
   129 
       
   130 // --------------------------------------------------------------------------
       
   131 // CUpnpCdsLiteObject::ObjectId
       
   132 // --------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C TDesC8& CUpnpCdsLiteObject::ObjectId()
       
   135     {
       
   136     return *iObjectId;
       
   137     }
       
   138 
       
   139 // --------------------------------------------------------------------------
       
   140 // CUpnpCdsLiteObject::ParentId
       
   141 // --------------------------------------------------------------------------
       
   142 //
       
   143 EXPORT_C TDesC8& CUpnpCdsLiteObject::ParentId()
       
   144     {
       
   145     return *iParentId;
       
   146     }
       
   147 
       
   148 // --------------------------------------------------------------------------
       
   149 // CUpnpCdsLiteObject::ObjectClass
       
   150 // --------------------------------------------------------------------------
       
   151 //
       
   152 EXPORT_C TDesC8& CUpnpCdsLiteObject::ObjectClass()
       
   153     {
       
   154     return *iObjectClass;
       
   155     }
       
   156 
       
   157 // --------------------------------------------------------------------------
       
   158 // CUpnpCdsLiteObject::OriginalItemIdL
       
   159 // --------------------------------------------------------------------------
       
   160 //
       
   161 EXPORT_C TDesC8& CUpnpCdsLiteObject::OriginalItemIdL()
       
   162     {
       
   163     if( iType != EItemReference )
       
   164         {
       
   165         User::Leave( KErrNotSupported );
       
   166         }
       
   167 
       
   168     return *iOriginalItemId;
       
   169     }
       
   170 
       
   171 // --------------------------------------------------------------------------
       
   172 // CUpnpCdsLiteObject::SetOriginalItemIdL
       
   173 // --------------------------------------------------------------------------
       
   174 //
       
   175 EXPORT_C void CUpnpCdsLiteObject::SetOriginalItemIdL(
       
   176                                             const TDesC8 &aOriginalItemId )
       
   177     {
       
   178     __LOG( "[CUpnpSharingAlgorithm]\t CUpnpCdsLiteObject::\
       
   179 SetOriginalItemIdL" );
       
   180 
       
   181     // Check the parameter
       
   182     if( aOriginalItemId == KNullDesC8 )
       
   183         {
       
   184         User::Leave( KErrArgument );
       
   185         }
       
   186 
       
   187     // Delete the previously set value (if set)
       
   188     if( iOriginalItemId )
       
   189         {
       
   190         delete iOriginalItemId;
       
   191         iOriginalItemId = NULL;
       
   192         }
       
   193 
       
   194     iOriginalItemId = aOriginalItemId.AllocL();
       
   195     }
       
   196 
       
   197 // End of file