|
1 /* |
|
2 * Copyright (c) 2004 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: SAP data packer for Connection UI. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <s32mem.h> |
|
21 #include <CIMPSSAPSettings.h> |
|
22 #include "CnUiSapDataPacker.h" |
|
23 |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CnUiSapDataPacker::RemovePackedSapL() |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 void CnUiSapDataPacker::RemovePackedSapL( CIMPSSAPSettings& aSap ) |
|
30 { |
|
31 aSap.SetOpaqueInt( KIMPSPackAAClientsKey, EFalse ); |
|
32 } |
|
33 |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CnUiSapDataPacker::PackAAClientsL() |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 void CnUiSapDataPacker::PackAAClientsL( const RArray< TIMPSConnectionClient >& aClients, |
|
40 CIMPSSAPSettings& aContainer ) |
|
41 { |
|
42 if ( aClients.Count() ) |
|
43 { |
|
44 // there is an ao client |
|
45 aContainer.SetOpaqueInt( KIMPSPackAAClientsKey, ETrue ); |
|
46 } |
|
47 } |
|
48 |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CnUiSapDataPacker::ExtractAAClientsL() |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 TBool CnUiSapDataPacker::ExtractAAClientsL( CIMPSSAPSettings& aContainer, |
|
56 RArray< TIMPSConnectionClient >& /* aClients */ ) |
|
57 { |
|
58 TInt returnValue( 0 ); |
|
59 TInt err = aContainer.GetOpaqueInt( KIMPSPackAAClientsKey, returnValue ); |
|
60 //ignore not found, since there cannot be clients if the key is not set at all |
|
61 if ( ( err != KErrNotFound ) && ( err != KErrNone ) ) |
|
62 { |
|
63 User::Leave( err ); |
|
64 } |
|
65 aContainer.SetOpaqueInt( KIMPSPackAAClientsKey, EFalse ); |
|
66 return returnValue; |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CnUiSapDataPacker::WriteMarkL() |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CnUiSapDataPacker::WriteMarkL( RWriteStream& aWStream, TInt8 aMark ) |
|
75 { |
|
76 aWStream.WriteInt8L( aMark ); |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CnUiSapDataPacker::CheckMarkL() |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 TBool CnUiSapDataPacker::CheckMarkL( RReadStream& aRStream, TInt8 aSupposedMark ) |
|
85 { |
|
86 TInt8 streamMark = aRStream.ReadInt8L(); |
|
87 return ( streamMark == aSupposedMark ); |
|
88 } |
|
89 |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CnUiSapDataPacker::WriteClientsL() |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CnUiSapDataPacker::WriteClientsL( RWriteStream& aWStream , |
|
96 const RArray< TIMPSConnectionClient >& aClients ) |
|
97 { |
|
98 const TInt clientCount = aClients.Count(); |
|
99 aWStream.WriteInt32L( clientCount ); |
|
100 for ( TInt index = 0; index < clientCount ; ++index ) |
|
101 { |
|
102 aWStream.WriteInt32L( aClients[ index ] ); |
|
103 } |
|
104 } |
|
105 |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CnUiSapDataPacker::ReadClientsL() |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CnUiSapDataPacker::ReadClientsL( RReadStream& aRStream, |
|
112 RArray< TIMPSConnectionClient >& aClients ) |
|
113 { |
|
114 const TInt clientCount = aRStream.ReadInt32L(); |
|
115 for ( TInt index = 0; index < clientCount ; ++index ) |
|
116 { |
|
117 TInt client = aRStream.ReadInt32L(); |
|
118 User::LeaveIfError( aClients.Append( static_cast< TIMPSConnectionClient >( client ) ) ); |
|
119 } |
|
120 } |
|
121 |
|
122 // End of File |
|
123 |