|
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 // |
|
15 |
|
16 #include "ineturiproperties.h" |
|
17 |
|
18 CInetUriProperties* CInetUriProperties::NewL ( InetUriList::TServiceType aServiceType, InetUriList::TListType aListType ) |
|
19 { |
|
20 CInetUriProperties* self = new ( ELeave ) CInetUriProperties ( aServiceType, aListType ); |
|
21 return self; |
|
22 } |
|
23 |
|
24 CInetUriProperties::CInetUriProperties ( InetUriList::TServiceType aServiceType, InetUriList::TListType aListType ) |
|
25 : iPropId ( -1 ), |
|
26 iServiceType ( aServiceType ), |
|
27 iListType ( aListType ), |
|
28 iPermission ( InetUriList::EReadWrite ) |
|
29 { |
|
30 |
|
31 } |
|
32 |
|
33 CInetUriProperties::CInetUriProperties () |
|
34 : iPropId ( -1 ), |
|
35 iListType ( InetUriList::EBlackList ), |
|
36 iPermission ( InetUriList::EReadWrite ) |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 CInetUriProperties::~CInetUriProperties () |
|
42 { |
|
43 delete iFavouriteName; |
|
44 iFavouriteName = NULL; |
|
45 } |
|
46 |
|
47 /** |
|
48 Returns the servicetype of the URI |
|
49 */ |
|
50 InetUriList::TServiceType CInetUriProperties::ServiceType () const |
|
51 { |
|
52 return iServiceType; |
|
53 } |
|
54 |
|
55 /** |
|
56 Returns the listtype of the URI |
|
57 */ |
|
58 InetUriList::TListType CInetUriProperties::ListType () const |
|
59 { |
|
60 return iListType; |
|
61 } |
|
62 |
|
63 /** |
|
64 Returns the permission associated with the URI |
|
65 */ |
|
66 InetUriList::TPermission CInetUriProperties::Permission () const |
|
67 { |
|
68 return iPermission; |
|
69 } |
|
70 |
|
71 /** |
|
72 Returns the favouritename associated with the URI. Returns KNullDesC8 |
|
73 if no favouritename is set. |
|
74 */ |
|
75 const TDesC8& CInetUriProperties::FavouriteName () const |
|
76 { |
|
77 if ( iFavouriteName ) |
|
78 return *iFavouriteName; |
|
79 |
|
80 return KNullDesC8(); |
|
81 } |
|
82 |
|
83 /** |
|
84 Returns the Property Id. |
|
85 */ |
|
86 TInt CInetUriProperties::PropId () const |
|
87 { |
|
88 return iPropId; |
|
89 } |
|
90 |
|
91 /** |
|
92 Set the servicetype for the URI |
|
93 */ |
|
94 void CInetUriProperties::SetServiceType ( InetUriList::TServiceType aServiceType ) |
|
95 { |
|
96 iServiceType = aServiceType; |
|
97 } |
|
98 |
|
99 /** |
|
100 Set the listtype for the URI |
|
101 */ |
|
102 void CInetUriProperties::SetListType ( InetUriList::TListType aListType ) |
|
103 { |
|
104 iListType = aListType; |
|
105 } |
|
106 |
|
107 /** |
|
108 Set the permission for the URI |
|
109 */ |
|
110 void CInetUriProperties::SetPermission ( InetUriList::TPermission aPermission ) |
|
111 { |
|
112 iPermission = aPermission; |
|
113 } |
|
114 |
|
115 /** |
|
116 Set the favouritename for the URI |
|
117 */ |
|
118 void CInetUriProperties::SetFavouriteNameL ( const TDesC8& aFavouriteName ) |
|
119 { |
|
120 delete iFavouriteName; |
|
121 iFavouriteName = NULL; |
|
122 iFavouriteName = aFavouriteName.AllocL (); |
|
123 } |
|
124 |
|
125 /** |
|
126 Clear the properties value and sets the default |
|
127 |
|
128 */ |
|
129 void CInetUriProperties::Clear () |
|
130 { |
|
131 delete iFavouriteName; |
|
132 iFavouriteName = NULL; |
|
133 SetPermission ( InetUriList::EReadWrite ); |
|
134 } |
|
135 |
|
136 void CInetUriProperties::SetPropId ( TInt aId ) |
|
137 { |
|
138 iPropId = aId; |
|
139 } |
|
140 |
|
141 /** |
|
142 Total size of the properties. The buffer size for the IPC data is based on this |
|
143 Total size = Property id + Service type + List Type + Permission + Len of Favourite name |
|
144 + actual Favouritename length |
|
145 Property Id, Service type, List type, Permission & Len of Favourite name takes sizeof (TInt) |
|
146 */ |
|
147 TInt CInetUriProperties::Size () |
|
148 { |
|
149 TInt size = ( sizeof ( TInt ) * 5 ); // Property Id + Service Type + List Type + Permission + Length of favourite name |
|
150 |
|
151 size += ( FavouriteName().Length () ); |
|
152 |
|
153 return size; |
|
154 } |
|
155 |
|
156 /** |
|
157 Packs the properties data to set via IPC data to the server. |
|
158 */ |
|
159 void CInetUriProperties::PackL ( RWriteStream& aStream ) |
|
160 { |
|
161 aStream.WriteInt32L ( iPropId ); |
|
162 aStream.WriteInt32L ( iServiceType ); |
|
163 aStream.WriteInt32L ( iListType ); |
|
164 aStream.WriteInt32L ( iPermission ); |
|
165 |
|
166 TPtrC8 ptr ( FavouriteName() ); |
|
167 aStream.WriteInt32L ( ptr.Length() ); |
|
168 aStream.WriteL ( ptr ); |
|
169 } |
|
170 |
|
171 /** |
|
172 Unpacks the properties stream and assign to the respective variables |
|
173 */ |
|
174 void CInetUriProperties::UnpackL ( RReadStream& aStream ) |
|
175 { |
|
176 iPropId = aStream.ReadInt32L (); |
|
177 iServiceType = static_cast < InetUriList::TServiceType > ( aStream.ReadInt32L () ); |
|
178 iListType = static_cast < InetUriList::TListType > ( aStream.ReadInt32L () ); |
|
179 iPermission = static_cast < InetUriList::TPermission > ( aStream.ReadInt32L () ); |
|
180 |
|
181 TInt favouriteNameLength = aStream.ReadInt32L (); |
|
182 |
|
183 HBufC8* favouriteName = HBufC8::NewLC ( favouriteNameLength ); |
|
184 TPtr8 ptr ( favouriteName->Des () ); |
|
185 aStream.ReadL ( ptr, favouriteNameLength ); |
|
186 SetFavouriteNameL ( ptr ); |
|
187 CleanupStack::PopAndDestroy (); // favouriteName |
|
188 } |