ximpfw/presence/srcpresencedatamodel/presenceapidataobjfactory.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Base class for API implementations.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "presenceapidataobjfactory.h"
       
    19 #include "ximpapidataobjbase.h"
       
    20 
       
    21 #include <s32strm.h>
       
    22 //#include <s32mem.h>
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS =============================
       
    26 
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CPresenceEventCodec::NewL()
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CPresenceApiDataObjFactory* CPresenceApiDataObjFactory::NewL()
       
    33     {
       
    34     CPresenceApiDataObjFactory* self = new( ELeave ) CPresenceApiDataObjFactory() ;
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop();
       
    38     return self;
       
    39     }
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CPresenceEventCodec::ConstructL()
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 void CPresenceApiDataObjFactory::ConstructL()
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 /**
       
    52  * Method to instantiate new data object object
       
    53  * of requested type and construct it from the stream.
       
    54  *
       
    55  * @param aDataObjInterfaceId
       
    56  * @return Data object constructor function.
       
    57  */
       
    58 CXIMPApiDataObjBase* CPresenceApiDataObjFactory::NewFromStreamLC( 
       
    59             TInt32 aDataObjInterfaceId,
       
    60             RReadStream& aStream )
       
    61     {
       
    62     return NewDataObjectFromStreamLC( aDataObjInterfaceId, aStream );
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CPresenceApiDataObjFactory::CPresenceApiDataObjFactory()
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CPresenceApiDataObjFactory::CPresenceApiDataObjFactory()
       
    70     {
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CPresenceApiDataObjFactory::~CPresenceApiDataObjFactory()
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CPresenceApiDataObjFactory::~CPresenceApiDataObjFactory()
       
    78     {
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // PresenceApiDataObjFactory::InternalizeL
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CPresenceApiDataObjFactory::InternalizeL( 
       
    87         RReadStream& aStream,
       
    88         RPresenceReqParamArray& aArray )
       
    89     {
       
    90     TInt32 arrLen = aStream.ReadInt32L();
       
    91 
       
    92     for ( TInt i = 0; i < arrLen; i++ )
       
    93         {
       
    94         SPresenceReqParam param;
       
    95         param.iParamType = aStream.ReadInt32L();
       
    96         CXIMPApiDataObjBase* dataObject = NewDataObjectFromStreamLC( param.iParamType, aStream );
       
    97         param.iParam = dataObject;
       
    98         aArray.AppendL( param );
       
    99         CleanupStack::Pop( dataObject );
       
   100         }
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // PresenceApiDataObjFactory::ExternalizeL
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CPresenceApiDataObjFactory::ExternalizeL( 
       
   108             RWriteStream& aWs,
       
   109             const RPresenceReqParamArray& aArray )
       
   110     {
       
   111     // write array length
       
   112     aWs.WriteInt32L( aArray.Count() );
       
   113 
       
   114     for ( TInt i = 0; i < aArray.Count(); i++ )
       
   115         {
       
   116         // trust the type within the param struct
       
   117         aWs.WriteInt32L( aArray[ i ].iParamType );
       
   118 
       
   119         // write the actual object
       
   120         CXIMPApiDataObjBase* theBase = aArray[ i ].iParam;
       
   121         theBase->ExternalizeL( aWs );
       
   122         }
       
   123 
       
   124     aWs.CommitL();
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // PresenceApiDataObjFactory::InternalizeLC
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 CXIMPApiDataObjBase* CPresenceApiDataObjFactory::InternalizeLC(
       
   132         RReadStream& aStream )
       
   133     {
       
   134     TInt32 objType = aStream.ReadInt32L();
       
   135     CXIMPApiDataObjBase* dataObject = NewDataObjectFromStreamLC( objType, aStream );
       
   136     return dataObject;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // PresenceApiDataObjFactory::ExternalizeL
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CPresenceApiDataObjFactory::ExternalizeL(
       
   144         RWriteStream& aWs,
       
   145         const CXIMPApiDataObjBase& aDataObj )
       
   146     {
       
   147     aWs.WriteInt32L( aDataObj.Base().GetInterfaceId() );
       
   148     aDataObj.ExternalizeL( aWs );
       
   149     aWs.CommitL();
       
   150     }
       
   151 
       
   152 
       
   153 // End of file
       
   154