|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : sipprofileplugins.cpp |
|
15 // Part of : SIP / SIP Profile Agent / SIP Concrete Profile |
|
16 // Implementation |
|
17 // Version : %version: 2.1.1 % |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprofileplugins.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CSIPProfilePlugins::NewL |
|
29 // Two-phased constructor. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 EXPORT_C CSIPProfilePlugins* CSIPProfilePlugins::NewL() |
|
33 { |
|
34 CSIPProfilePlugins* self = CSIPProfilePlugins::NewLC(); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CSIPProfilePlugins::NewLC |
|
41 // Two-phased constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CSIPProfilePlugins* CSIPProfilePlugins::NewLC() |
|
45 { |
|
46 CSIPProfilePlugins* self = new (ELeave) CSIPProfilePlugins(); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CSIPProfilePlugins::CSIPProfilePlugins |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CSIPProfilePlugins::CSIPProfilePlugins() |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSIPProfilePlugins::ConstructL |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CSIPProfilePlugins::ConstructL() |
|
65 { |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSIPProfilePlugins::~CSIPProfilePlugins |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 EXPORT_C CSIPProfilePlugins::~CSIPProfilePlugins() |
|
73 { |
|
74 iPlugins.Close(); |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CSIPProfilePlugins::Plugins |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C const RArray<TSIPProfileTypeInfo>& CSIPProfilePlugins::Plugins() const |
|
83 { |
|
84 return iPlugins; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSIPProfilePlugins::SetPluginsL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C void CSIPProfilePlugins::SetPluginsL( |
|
92 const RArray<TSIPProfileTypeInfo>& aPlugins) |
|
93 { |
|
94 iPlugins.Reset(); |
|
95 for (TInt i = 0; i < aPlugins.Count(); i++) |
|
96 { |
|
97 User::LeaveIfError(iPlugins.Append(aPlugins[i])); |
|
98 } |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CSIPProfilePlugins::InternalizeL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C CSIPProfilePlugins* CSIPProfilePlugins::InternalizeL( |
|
106 RReadStream& aReadStream) |
|
107 { |
|
108 CSIPProfilePlugins* self = new (ELeave) CSIPProfilePlugins(); |
|
109 CleanupStack::PushL(self); |
|
110 self->DoInternalizeL (aReadStream); |
|
111 CleanupStack::Pop(self); |
|
112 return self; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CSIPProfilePlugins::ExternalizeL |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C void CSIPProfilePlugins::ExternalizeL(RWriteStream& aWriteStream) const |
|
120 { |
|
121 aWriteStream.WriteUint32L(iPlugins.Count()); |
|
122 for (TInt i = 0; i < iPlugins.Count(); i++) |
|
123 { |
|
124 aWriteStream.WriteUint8L(iPlugins[i].iSIPProfileClass); |
|
125 const TPtrC8& value = iPlugins[i].iSIPProfileName; |
|
126 aWriteStream.WriteUint32L(value.Length()); |
|
127 aWriteStream.WriteL(value); |
|
128 } |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CSIPProfilePlugins::ExternalizedSizeL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C TUint CSIPProfilePlugins::ExternalizedSize() const |
|
136 { |
|
137 TInt i = 0; |
|
138 TUint size = 4; |
|
139 |
|
140 for (i = 0; i < iPlugins.Count(); i++) |
|
141 { |
|
142 const TPtrC8& value = iPlugins[i].iSIPProfileName; |
|
143 size = size + 5; // 4 + 1 bytes |
|
144 size = size + value.Length(); |
|
145 } |
|
146 |
|
147 return size; |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CSIPProfilePlugins::DoInternalizeL |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CSIPProfilePlugins::DoInternalizeL(RReadStream& aReadStream) |
|
155 { |
|
156 TInt count = aReadStream.ReadUint32L(); |
|
157 for (TInt i = 0; i < count; i++) |
|
158 { |
|
159 TInt type = aReadStream.ReadUint8L(); |
|
160 TInt valueLen= aReadStream.ReadUint32L(); |
|
161 HBufC8* valueBuf = HBufC8::NewLC(valueLen); |
|
162 TPtr8 value = valueBuf->Des(); |
|
163 aReadStream.ReadL (value, valueLen); |
|
164 TSIPProfileTypeInfo info; |
|
165 info.iSIPProfileClass = (enum TSIPProfileTypeInfo::TSIPProfileClass) type; |
|
166 info.iSIPProfileName = *valueBuf; |
|
167 CleanupStack::PopAndDestroy(valueBuf); |
|
168 iPlugins.AppendL(info); |
|
169 } |
|
170 } |