1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/tldlistdef.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,476 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +
1.18 +
1.19 +/** @file
1.20 +@publishedAll
1.21 +@released
1.22 +*/
1.23 +
1.24 +#ifndef __TLDLISTDEF_H__
1.25 +#define __TLDLISTDEF_H__
1.26 +
1.27 +#include <e32base.h>
1.28 +#include <ineturilistdef.h>
1.29 +
1.30 +using namespace InetUriList;
1.31 +
1.32 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.33 +
1.34 +class TBase
1.35 + {
1.36 + friend class TPolicyQueryArgs;
1.37 + friend class TQueryResults;
1.38 +
1.39 +public:
1.40 + /**
1.41 + Default constructor
1.42 + */
1.43 + inline TBase ()
1.44 + :iFlags ( 0 )
1.45 + {}
1.46 +
1.47 +private:
1.48 + /**
1.49 + Bit width of the type.
1.50 + */
1.51 + enum
1.52 + {
1.53 + KBitsPerType = 3
1.54 + };
1.55 +
1.56 + /**
1.57 + Maximum number of arguments. Currently set as 4.
1.58 + */
1.59 + enum
1.60 + {
1.61 + KMaxArguments = 4
1.62 + };
1.63 +
1.64 +protected:
1.65 + TInt iArgs [KMaxArguments];
1.66 + TInt iFlags;
1.67 + };
1.68 +
1.69 +//-----------------------------------------------------------------
1.70 +class TPolicyQueryArgs:public TBase
1.71 + {
1.72 + public:
1.73 + /**
1.74 + The argument types.
1.75 + */
1.76 + enum TPolicyArgType
1.77 + {
1.78 + ETldUri = 1,
1.79 + ETldListType,
1.80 + ETldQueryType
1.81 + };
1.82 +
1.83 + /**
1.84 + Default constructor
1.85 + */
1.86 + inline TPolicyQueryArgs ()
1.87 + :TBase()
1.88 + {}
1.89 +
1.90 + /**
1.91 + A templated constructor that constructs the query argument.
1.92 + It takes one argument.
1.93 + */
1.94 + template < class T0 >
1.95 + explicit inline TPolicyQueryArgs ( T0 a0 )
1.96 + {
1.97 + Assign ( a0 );
1.98 + iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType));
1.99 + }
1.100 +
1.101 + /**
1.102 + A templated constructor that constructs the query argument.
1.103 + It takes two arguments.
1.104 + */
1.105 + template < class T0, class T1 >
1.106 + inline TPolicyQueryArgs ( T0 a0, T1 a1 )
1.107 + {
1.108 + Assign ( a0 );
1.109 + Assign ( a1 );
1.110 + iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType)) |
1.111 + (Type(a1)<<(( Type(a1))*KBitsPerType));
1.112 + }
1.113 +
1.114 + /**
1.115 + A templated constructor that constructs the query argument.
1.116 + It takes three arguments.
1.117 + */
1.118 + template < class T0, class T1, class T2 >
1.119 + inline TPolicyQueryArgs ( T0 a0, T1 a1, T2 a2 )
1.120 + {
1.121 + Assign ( a0 );
1.122 + Assign ( a1 );
1.123 + Assign ( a2 );
1.124 + iFlags=(Type(a0)<<(Type(a0)*KBitsPerType)) |
1.125 + (Type(a1)<<(Type(a1)*KBitsPerType)) |
1.126 + (Type(a2)<<(Type(a2)*KBitsPerType));
1.127 + }
1.128 + /**
1.129 + Returns the argument if set, otherwise returns KErrNotFound.
1.130 + */
1.131 + TInt Get ( TPolicyArgType aType ) const
1.132 + {
1.133 + if ( IsSet ( aType ) )
1.134 + return iArgs[aType - 1];
1.135 + return KErrNotFound;
1.136 + }
1.137 +
1.138 + private:
1.139 + /**
1.140 + Checks whether the flag is set for the given argument type.
1.141 + */
1.142 + TBool IsSet ( TPolicyArgType aType ) const
1.143 + {
1.144 + TInt val = iFlags & ( aType << ( aType * KBitsPerType ) );
1.145 + return iFlags & ( aType << ( aType * KBitsPerType ) );
1.146 + }
1.147 +
1.148 + TPolicyArgType Type ( const TDesC8* )
1.149 + {
1.150 + return ETldUri;
1.151 + }
1.152 +
1.153 + TPolicyArgType Type ( InetUriList::TListType )
1.154 + {
1.155 + return ETldListType;
1.156 + }
1.157 +
1.158 + TPolicyArgType Type ( InetUriList::TTLDQueryType )
1.159 + {
1.160 + return ETldQueryType;
1.161 + }
1.162 +
1.163 + void Assign ( const TDesC8* aValue )
1.164 + {
1.165 + iArgs[Type(aValue)-1] = (TInt)aValue;
1.166 + }
1.167 +
1.168 + void Assign ( InetUriList::TListType aValue )
1.169 + {
1.170 + iArgs[Type(aValue)-1] = aValue;
1.171 + }
1.172 +
1.173 + void Assign ( InetUriList::TTLDQueryType aValue )
1.174 + {
1.175 + iArgs[Type(aValue)-1] = aValue;
1.176 + }
1.177 +
1.178 +
1.179 + };
1.180 +
1.181 +#else
1.182 +class TBase
1.183 + {
1.184 +public:
1.185 + /**
1.186 + Bit width of the type.
1.187 +
1.188 + @internalComponent
1.189 + */
1.190 + enum
1.191 + {
1.192 + KBitsPerType = 3
1.193 + };
1.194 +
1.195 + /**
1.196 + Maximum number of arguments. Currently set as 4.
1.197 +
1.198 + @internalComponent
1.199 + */
1.200 + enum
1.201 + {
1.202 + KMaxArguments = 4
1.203 + };
1.204 +
1.205 + /**
1.206 + Default constructor
1.207 + */
1.208 + inline TBase ()
1.209 + :iFlags ( 0 )
1.210 + {}
1.211 +
1.212 +protected:
1.213 + TInt iArgs [KMaxArguments];
1.214 + TInt iFlags;
1.215 + };
1.216 +
1.217 +//-----------------------------------------------------------------
1.218 +class TPolicyQueryArgs:public TBase
1.219 + {
1.220 + public:
1.221 + /**
1.222 + The argument types.
1.223 +
1.224 + @internalComponent
1.225 + */
1.226 + enum TPolicyArgType
1.227 + {
1.228 + ETldUri = 1,
1.229 + ETldListType,
1.230 + ETldQueryType
1.231 + };
1.232 +
1.233 + /**
1.234 + Default constructor
1.235 + */
1.236 + inline TPolicyQueryArgs ()
1.237 + :TBase()
1.238 + {}
1.239 +
1.240 +
1.241 + /**
1.242 + A templated constructor that constructs the query argument.
1.243 + It takes one argument.
1.244 + */
1.245 + template < class T0 >
1.246 + explicit inline TPolicyQueryArgs ( T0 a0 )
1.247 + {
1.248 + Assign ( a0 );
1.249 + iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType));
1.250 + }
1.251 +
1.252 + /**
1.253 + A templated constructor that constructs the query argument.
1.254 + It takes two arguments.
1.255 + */
1.256 + template < class T0, class T1 >
1.257 + inline TPolicyQueryArgs ( T0 a0, T1 a1 )
1.258 + {
1.259 + Assign ( a0 );
1.260 + Assign ( a1 );
1.261 + iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType)) |
1.262 + (Type(a1)<<(( Type(a1))*KBitsPerType));
1.263 + }
1.264 +
1.265 + /**
1.266 + A templated constructor that constructs the query argument.
1.267 + It takes three arguments.
1.268 + */
1.269 + template < class T0, class T1, class T2 >
1.270 + inline TPolicyQueryArgs ( T0 a0, T1 a1, T2 a2 )
1.271 + {
1.272 + Assign ( a0 );
1.273 + Assign ( a1 );
1.274 + Assign ( a2 );
1.275 + iFlags=(Type(a0)<<(Type(a0)*KBitsPerType)) |
1.276 + (Type(a1)<<(Type(a1)*KBitsPerType)) |
1.277 + (Type(a2)<<(Type(a2)*KBitsPerType));
1.278 + }
1.279 +
1.280 + /**
1.281 + Checks whether the flag is set for the given argument type.
1.282 +
1.283 + @internalComponent
1.284 + */
1.285 + TBool IsSet ( TPolicyArgType aType ) const
1.286 + {
1.287 + TInt val = iFlags & ( aType << ( aType * KBitsPerType ) );
1.288 + return iFlags & ( aType << ( aType * KBitsPerType ) );
1.289 + }
1.290 +
1.291 + /**
1.292 + Returns the argument if set, otherwise returns KErrNotFound.
1.293 +
1.294 + @internalComponent
1.295 + */
1.296 + TInt Get ( TPolicyArgType aType ) const
1.297 + {
1.298 + if ( IsSet ( aType ) )
1.299 + return iArgs[aType - 1];
1.300 + return KErrNotFound;
1.301 + }
1.302 +
1.303 +
1.304 + private:
1.305 +
1.306 + /**
1.307 + @internalComponent
1.308 + */
1.309 + TPolicyArgType Type ( const TDesC8* )
1.310 + {
1.311 + return ETldUri;
1.312 + }
1.313 +
1.314 + TPolicyArgType Type ( InetUriList::TListType )
1.315 + {
1.316 + return ETldListType;
1.317 + }
1.318 +
1.319 + TPolicyArgType Type ( InetUriList::TTLDQueryType )
1.320 + {
1.321 + return ETldQueryType;
1.322 + }
1.323 +
1.324 + void Assign ( const TDesC8* aValue )
1.325 + {
1.326 + iArgs[Type(aValue)-1] = (TInt)aValue;
1.327 + }
1.328 +
1.329 + void Assign ( InetUriList::TListType aValue )
1.330 + {
1.331 + iArgs[Type(aValue)-1] = aValue;
1.332 + }
1.333 +
1.334 + void Assign ( InetUriList::TTLDQueryType aValue )
1.335 + {
1.336 + iArgs[Type(aValue)-1] = aValue;
1.337 + }
1.338 +
1.339 +
1.340 + };
1.341 +
1.342 +
1.343 +#endif //SYMBIAN_ENABLE_SPLIT_HEADERS
1.344 +
1.345 +
1.346 +//------------------------------------------------------------------------
1.347 +class TQueryResults: public TBase
1.348 + {
1.349 + public:
1.350 + /**
1.351 + Default constructor
1.352 + */
1.353 + inline TQueryResults ()
1.354 + :TBase()
1.355 + {}
1.356 +
1.357 + ~TQueryResults ()
1.358 + {
1.359 + if ( IsSet( TQueryResults::ETldCharSet ) )
1.360 + {
1.361 + //Delete memory on Heap.
1.362 + HBufC8* uriBuf = (reinterpret_cast<HBufC8*> ( Get ( TQueryResults::ETldCharSet ) ));
1.363 + delete uriBuf;
1.364 + }
1.365 + }
1.366 +
1.367 + /**
1.368 + returns a pointer to policydata
1.369 + */
1.370 + HBufC8* CharsetL()
1.371 + {
1.372 + __ASSERT_ALWAYS( IsSet(TQueryResults::ETldCharSet), User::Panic( KTldInvalidRequest, KErrPolicyDataNotPresent ));
1.373 + const TDesC8& uri = *( reinterpret_cast<TDesC8*> (Get ( TQueryResults::ETldCharSet ) ) );
1.374 + return uri.AllocL();
1.375 + }
1.376 +
1.377 + /**
1.378 + returns a list type
1.379 + */
1.380 + InetUriList::TListType ListType()
1.381 + {
1.382 + __ASSERT_ALWAYS( IsSet(TQueryResults::ETldListType), User::Panic( KTldInvalidRequest, KErrPolicyListTypeNotPresent ));
1.383 + return (static_cast<InetUriList::TListType> (Get ( TQueryResults::ETldListType ) ));
1.384 + }
1.385 +
1.386 + /**
1.387 + A templated constructor that constructs the query argument.
1.388 + It takes one argument. --Check this
1.389 + */
1.390 + template < class T0 >
1.391 + inline void Set ( T0 a0 )
1.392 + {
1.393 + Assign ( a0 );
1.394 + iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType));
1.395 + }
1.396 +
1.397 + private:
1.398 + #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.399 + /**
1.400 + The argument types.
1.401 + */
1.402 + #else
1.403 + /**
1.404 + The argument types.
1.405 +
1.406 + @internalComponent
1.407 + */
1.408 + #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
1.409 + enum TResultsArgType
1.410 + {
1.411 + ETldCharSet = 1,
1.412 + ETldListType
1.413 + };
1.414 +
1.415 + #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.416 + /**
1.417 + Checks whether the flag is set for the given argument type.
1.418 + */
1.419 + #else
1.420 + /**
1.421 + Checks whether the flag is set for the given argument type.
1.422 +
1.423 + @internalComponent
1.424 + */
1.425 + #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
1.426 + TBool IsSet ( TResultsArgType aType ) const
1.427 + {
1.428 + TInt val = iFlags & ( aType << ( aType * KBitsPerType ) );
1.429 + return iFlags & ( aType << ( aType * KBitsPerType ) );
1.430 + }
1.431 +
1.432 + #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
1.433 + /**
1.434 + Returns the argument if set, otherwise returns KErrNotFound.
1.435 + */
1.436 + #else
1.437 + /**
1.438 + Returns the argument if set, otherwise returns KErrNotFound.
1.439 +
1.440 + @internalComponent
1.441 + */
1.442 + #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
1.443 + TInt Get ( TResultsArgType aType ) const
1.444 + {
1.445 + if ( IsSet ( aType ) )
1.446 + return iArgs[aType - 1];
1.447 + return KErrNotFound;
1.448 + }
1.449 +
1.450 + private:
1.451 + #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
1.452 + /**
1.453 + @internalComponent
1.454 + */
1.455 + #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
1.456 +
1.457 + TResultsArgType Type ( const TDesC8* )
1.458 + {
1.459 + return ETldCharSet;
1.460 + }
1.461 +
1.462 + TResultsArgType Type ( InetUriList::TListType )
1.463 + {
1.464 + return ETldListType;
1.465 + }
1.466 +
1.467 + void Assign ( const TDesC8* aValue )
1.468 + {
1.469 + iArgs[Type(aValue)-1] = (TInt)aValue;
1.470 + }
1.471 +
1.472 + void Assign ( InetUriList::TListType aValue )
1.473 + {
1.474 + iArgs[Type(aValue)-1] = aValue;
1.475 + }
1.476 + };
1.477 +
1.478 +#endif // __TLDLISTDEF_H__
1.479 +