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