syncmlfw/ds/hostserver/dshostclient/src/nsmldshostitem.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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 "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:  Utilities for DS Loader Framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "nsmldshostitem.h"
       
    21 
       
    22 // ================================= MEMBER FUNCTIONS =============================================
       
    23 
       
    24 // ------------------------------------------------------------------------------------------------
       
    25 // CNSmlDSHostItem::NewL
       
    26 // Creates new instance of CNSmlDSHostItem based class.
       
    27 // ------------------------------------------------------------------------------------------------
       
    28 EXPORT_C CNSmlDSHostItem* CNSmlDSHostItem::NewL()
       
    29 	{	
       
    30 	CNSmlDSHostItem* self = NewLC();
       
    31 	CleanupStack::Pop();
       
    32 	return self;
       
    33 	}
       
    34 	
       
    35 // ------------------------------------------------------------------------------------------------
       
    36 // CNSmlDSHostItem::NewLC
       
    37 // Creates new instance of CNSmlDSHostItem based class.
       
    38 // ------------------------------------------------------------------------------------------------
       
    39 EXPORT_C CNSmlDSHostItem* CNSmlDSHostItem::NewLC()
       
    40 	{
       
    41 	CNSmlDSHostItem* self = new (ELeave) CNSmlDSHostItem();
       
    42 	CleanupStack::PushL( self );
       
    43 	self->ConstructL();
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 // ------------------------------------------------------------------------------------------------
       
    48 // CNSmlDSHostItem::~CNSmlDSHostItem
       
    49 // C++ Destructor.
       
    50 // ------------------------------------------------------------------------------------------------
       
    51 EXPORT_C CNSmlDSHostItem::~CNSmlDSHostItem()
       
    52 	{
       
    53 	delete iMimeType;
       
    54 	delete iMimeVer;
       
    55 	}
       
    56 
       
    57 // ------------------------------------------------------------------------------------------------
       
    58 // CNSmlDSHostItem::ExternalizeL
       
    59 // This method externalizes class to stream.
       
    60 // ------------------------------------------------------------------------------------------------
       
    61 EXPORT_C void CNSmlDSHostItem::ExternalizeL( RWriteStream& aStream ) const
       
    62 	{
       
    63 	aStream.WriteInt32L( iUid );
       
    64 	aStream.WriteInt32L( iFieldChange );
       
    65 	aStream.WriteInt32L( iSize );
       
    66 	aStream.WriteInt32L( iParentUid );
       
    67 	aStream.WriteUint32L( iMimeType->Length() );
       
    68 	aStream << *iMimeType;
       
    69 	aStream.WriteUint32L( iMimeVer->Length() );
       
    70 	aStream << *iMimeVer;
       
    71 	}
       
    72 		
       
    73 // ------------------------------------------------------------------------------------------------
       
    74 // CNSmlDSHostItem::InternalizeL
       
    75 // This method internalizes class from stream.
       
    76 // ------------------------------------------------------------------------------------------------
       
    77 EXPORT_C void CNSmlDSHostItem::InternalizeL( RReadStream& aStream )
       
    78 	{
       
    79 	iUid = aStream.ReadInt32L();
       
    80 	iFieldChange = aStream.ReadInt32L();
       
    81 	iSize = aStream.ReadInt32L();
       
    82 	iParentUid = aStream.ReadInt32L();
       
    83 
       
    84 	delete iMimeType;
       
    85 	iMimeType = NULL;
       
    86 	delete iMimeVer;
       
    87 	iMimeVer = NULL;
       
    88 	
       
    89 	iMimeType = HBufC8::NewL( aStream, aStream.ReadUint32L() );
       
    90 	iMimeVer = HBufC8::NewL( aStream, aStream.ReadUint32L() );
       
    91 	}
       
    92 		
       
    93 // ------------------------------------------------------------------------------------------------
       
    94 // CNSmlDSHostItem::Uid
       
    95 // Returns UID of item.
       
    96 // ------------------------------------------------------------------------------------------------
       
    97 EXPORT_C TSmlDbItemUid CNSmlDSHostItem::Uid() const
       
    98 	{
       
    99 	return iUid;
       
   100 	}
       
   101 
       
   102 // ------------------------------------------------------------------------------------------------
       
   103 // CNSmlDSHostItem::SetUid
       
   104 // Sets UID of item.
       
   105 // ------------------------------------------------------------------------------------------------
       
   106 EXPORT_C void CNSmlDSHostItem::SetUid( const TSmlDbItemUid aItemId )
       
   107 	{
       
   108 	iUid = aItemId;
       
   109 	}
       
   110 	
       
   111 // ------------------------------------------------------------------------------------------------
       
   112 // CNSmlDSHostItem::FieldChange
       
   113 // Returns fieldChange info.
       
   114 // ------------------------------------------------------------------------------------------------
       
   115 EXPORT_C TBool CNSmlDSHostItem::FieldChange() const
       
   116 	{
       
   117 	return iFieldChange;
       
   118 	}
       
   119 		
       
   120 // ------------------------------------------------------------------------------------------------
       
   121 // CNSmlDSHostItem::SetFieldChange
       
   122 // Sets fieldChange info.
       
   123 // ------------------------------------------------------------------------------------------------
       
   124 EXPORT_C void CNSmlDSHostItem::SetFieldChange( const TBool aFieldChange )
       
   125 	{
       
   126 	iFieldChange = aFieldChange;
       
   127 	}
       
   128 
       
   129 // ------------------------------------------------------------------------------------------------
       
   130 // CNSmlDSHostItem::Size
       
   131 // Returns size of item.
       
   132 // ------------------------------------------------------------------------------------------------
       
   133 EXPORT_C TInt CNSmlDSHostItem::Size() const
       
   134 	{
       
   135 	return iSize;
       
   136 	}
       
   137 		
       
   138 // ------------------------------------------------------------------------------------------------
       
   139 // CNSmlDSHostItem::SetSize
       
   140 // Sets size of item.
       
   141 // ------------------------------------------------------------------------------------------------
       
   142 EXPORT_C void CNSmlDSHostItem::SetSize( const TInt aSize )
       
   143 	{
       
   144 	iSize = aSize;
       
   145 	}	
       
   146 
       
   147 // ------------------------------------------------------------------------------------------------
       
   148 // CNSmlDSHostItem::ParentUid
       
   149 // Returns UID of parent of item.
       
   150 // ------------------------------------------------------------------------------------------------
       
   151 EXPORT_C TSmlDbItemUid CNSmlDSHostItem::ParentUid() const
       
   152 	{
       
   153 	return iParentUid;
       
   154 	}
       
   155 		
       
   156 // ------------------------------------------------------------------------------------------------
       
   157 // CNSmlDSHostItem::SetParentUid
       
   158 // Sets UID of parent of item.
       
   159 // ------------------------------------------------------------------------------------------------
       
   160 EXPORT_C void CNSmlDSHostItem::SetParentUid( const TSmlDbItemUid aParentId )
       
   161 	{
       
   162 	iParentUid = aParentId;
       
   163 	}			
       
   164 
       
   165 // ------------------------------------------------------------------------------------------------
       
   166 // CNSmlDSHostItem::MimeTypeL
       
   167 // Returns mime type of item.
       
   168 // ------------------------------------------------------------------------------------------------
       
   169 EXPORT_C const HBufC8* CNSmlDSHostItem::MimeType() const
       
   170 	{
       
   171 	return iMimeType;
       
   172 	}
       
   173 		
       
   174 // ------------------------------------------------------------------------------------------------
       
   175 // CNSmlDSHostItem::SetMimeTypeL
       
   176 // Sets mime type of item.
       
   177 // ------------------------------------------------------------------------------------------------
       
   178 EXPORT_C void CNSmlDSHostItem::SetMimeTypeL( const TDesC8& aMimeType )
       
   179 	{
       
   180 	delete iMimeType;
       
   181 	iMimeType = NULL;
       
   182 	iMimeType = aMimeType.AllocL();
       
   183 	}		
       
   184 
       
   185 // ------------------------------------------------------------------------------------------------
       
   186 // CNSmlDSHostItem::MimeVerL
       
   187 // Returns mime version of item.
       
   188 // ------------------------------------------------------------------------------------------------
       
   189 EXPORT_C const HBufC8* CNSmlDSHostItem::MimeVer() const
       
   190 	{
       
   191 	return iMimeVer;
       
   192 	}
       
   193 		
       
   194 // ------------------------------------------------------------------------------------------------
       
   195 // CNSmlDSHostItem::SetMimeVerL
       
   196 // Sets mime version of item.
       
   197 // ------------------------------------------------------------------------------------------------
       
   198 EXPORT_C void CNSmlDSHostItem::SetMimeVerL( const TDesC8& aMimeVer )
       
   199 	{
       
   200 	delete iMimeVer;
       
   201 	iMimeVer = NULL;
       
   202 	iMimeVer = aMimeVer.AllocL();
       
   203 	}
       
   204 
       
   205 // ------------------------------------------------------------------------------------------------
       
   206 // CNSmlDSHostItem::CNSmlDSHostItem
       
   207 // C++ constructor.
       
   208 // ------------------------------------------------------------------------------------------------
       
   209 EXPORT_C CNSmlDSHostItem::CNSmlDSHostItem() : 
       
   210 		iUid( 0 ),iFieldChange( EFalse ), iSize( 0 ), iParentUid( KNullDataItemId ),
       
   211 		iMimeType( 0 ), iMimeVer( 0 )
       
   212 	{
       
   213 	}
       
   214 
       
   215 // ------------------------------------------------------------------------------------------------
       
   216 // CNSmlDSHostItem::ConstrucL
       
   217 // ConstructL
       
   218 // ------------------------------------------------------------------------------------------------
       
   219 EXPORT_C void CNSmlDSHostItem::ConstructL()
       
   220 	{
       
   221 	iMimeType = HBufC8::NewL( 0 );
       
   222 	iMimeVer = HBufC8::NewL( 0 );
       
   223 	}
       
   224 	
       
   225 // End of File