|
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: MPX parameter for commandline/message |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <s32strm.h> |
|
21 #include <mpxcollectionpath.h> |
|
22 |
|
23 #include "mpxparameter.h" |
|
24 #include "mpxlog.h" |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 const TInt KMPXParameterVesion = 2; |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS ============================== |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // C++ constructor can NOT contain any code that might leave. |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C CMPXParameter::CMPXParameter(): |
|
37 iCollectionPath( NULL ), |
|
38 iType( KNullUid ), |
|
39 iCmdForward( EMPXCmdFwdStandAlone ) |
|
40 { |
|
41 } |
|
42 |
|
43 // Destructor |
|
44 EXPORT_C CMPXParameter::~CMPXParameter() |
|
45 { |
|
46 delete iCollectionPath; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // Externalize the object |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C void CMPXParameter::ExternalizeL( RWriteStream& aStream ) const |
|
54 { |
|
55 MPX_FUNC( "CMPXParameter::ExternalizeL" ); |
|
56 |
|
57 MPX_DEBUG2( "CMPXParameter::ExternalizeL parameter version = %d", KMPXParameterVesion ); |
|
58 aStream.WriteInt32L( KMPXParameterVesion ); |
|
59 |
|
60 MPX_DEBUG2( "CMPXParameter::ExternalizeL iCmdForward = %d", iCmdForward ); |
|
61 aStream.WriteInt32L( iCmdForward ); |
|
62 |
|
63 // externalize playlist |
|
64 if ( iCollectionPath ) |
|
65 { |
|
66 // collection path exist |
|
67 MPX_DEBUG1( "CMPXParameter::ExternalizeL collection path exist" ); |
|
68 MPX_DEBUG_PATH( *iCollectionPath ); |
|
69 aStream.WriteInt32L( 1 ); |
|
70 aStream << *iCollectionPath; |
|
71 } |
|
72 else |
|
73 { |
|
74 // no collection path |
|
75 MPX_DEBUG1( "CMPXParameter::ExternalizeL no collection path" ); |
|
76 aStream.WriteInt32L( 0 ); |
|
77 } |
|
78 |
|
79 MPX_DEBUG2( "CMPXParameter::ExternalizeL collection path type = %d", iPathType ); |
|
80 aStream.WriteInt32L( iPathType ); |
|
81 |
|
82 if ( iType.iUid > 0 ) |
|
83 { |
|
84 // view uid exist |
|
85 MPX_DEBUG2( "CMPXParameter::ExternalizeL uid = 0x%x", iType.iUid ); |
|
86 aStream.WriteInt32L( 1 ); |
|
87 aStream.WriteInt32L( iType.iUid ); |
|
88 } |
|
89 else |
|
90 { |
|
91 // no view uid |
|
92 MPX_DEBUG1( "CMPXParameter::ExternalizeL no uid" ); |
|
93 aStream.WriteInt32L( 0 ); |
|
94 } |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // Internalize the object |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C void CMPXParameter::InternalizeL( RReadStream& aStream ) |
|
102 { |
|
103 MPX_FUNC( "CMPXParameter::InternalizeL" ); |
|
104 delete iCollectionPath; |
|
105 iCollectionPath = NULL; |
|
106 iPathType = EMPXTypeCollectionPath; |
|
107 iType = KNullUid; |
|
108 |
|
109 iVersion = aStream.ReadInt32L(); |
|
110 MPX_DEBUG2( "CMPXParameter::InternalizeL iVersion = %d", iVersion ); |
|
111 |
|
112 switch ( iVersion ) |
|
113 { |
|
114 // this 0/1 is not the actual version number |
|
115 // In the first version of parameter, |
|
116 // 0 means no collection path, 1 means collection path exist |
|
117 case 1: |
|
118 { |
|
119 // collection path exist |
|
120 MPX_DEBUG1( "CMPXParameter::InternalizeL collection path" ); |
|
121 iCollectionPath = CMPXCollectionPath::NewL(); |
|
122 aStream >> *iCollectionPath; |
|
123 MPX_DEBUG_PATH( *iCollectionPath ); |
|
124 } // fall through on purpose |
|
125 case 0: |
|
126 { |
|
127 iVersion = 1; // if it's 0, set the version to 1 |
|
128 iPathType = static_cast<TMPXPathType>( aStream.ReadInt32L() ); |
|
129 MPX_DEBUG2( "CMPXParameter::InternalizeL iPathType = %d", iPathType ); |
|
130 |
|
131 TInt paramExist( aStream.ReadInt32L() ); |
|
132 if ( paramExist == 1 ) |
|
133 { |
|
134 // view uid exist |
|
135 iType.iUid = aStream.ReadInt32L(); |
|
136 MPX_DEBUG2( "CMPXParameter::InternalizeL uid = 0x%x", iType.iUid ); |
|
137 } |
|
138 #ifdef _DEBUG |
|
139 else |
|
140 { |
|
141 MPX_DEBUG1( "CMPXParameter::InternalizeL no uid" ); |
|
142 } |
|
143 #endif |
|
144 break; |
|
145 } |
|
146 case 2: |
|
147 { |
|
148 iCmdForward = aStream.ReadInt32L(); |
|
149 MPX_DEBUG2( "CMPXParameter::InternalizeL iCmdForward = %d", iCmdForward ); |
|
150 |
|
151 TInt paramExist = aStream.ReadInt32L(); |
|
152 if ( paramExist == 1 ) |
|
153 { |
|
154 // collection path exist |
|
155 iCollectionPath = CMPXCollectionPath::NewL(); |
|
156 aStream >> *iCollectionPath; |
|
157 MPX_DEBUG_PATH( *iCollectionPath ); |
|
158 } |
|
159 #ifdef _DEBUG |
|
160 else |
|
161 { |
|
162 MPX_DEBUG1( "CMPXParameter::InternalizeL no collection path" ); |
|
163 } |
|
164 #endif |
|
165 |
|
166 iPathType = static_cast<TMPXPathType>( aStream.ReadInt32L() ); |
|
167 MPX_DEBUG2( "CMPXParameter::InternalizeL iPathType = %d", iPathType ); |
|
168 |
|
169 paramExist = aStream.ReadInt32L(); |
|
170 if ( paramExist == 1 ) |
|
171 { |
|
172 // view uid exist |
|
173 iType.iUid = aStream.ReadInt32L(); |
|
174 MPX_DEBUG2( "CMPXParameter::InternalizeL uid = 0x%x", iType.iUid ); |
|
175 } |
|
176 #ifdef _DEBUG |
|
177 else |
|
178 { |
|
179 MPX_DEBUG1( "CMPXParameter::InternalizeL no uid" ); |
|
180 } |
|
181 #endif |
|
182 break; |
|
183 } |
|
184 default: |
|
185 { |
|
186 User::Leave( KErrNotSupported ); |
|
187 break; |
|
188 } |
|
189 } |
|
190 } |
|
191 |
|
192 |
|
193 // End of File |