00001 /* 00002 * ============================================================================= 00003 * Name : SdpOriginField.h 00004 * Part of : SDP Codec 00005 * Interface : SDK API, SDP Codec API 00006 * Description : 00007 * Version : 1.0 00008 * 00009 * Copyright (c) 2003 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. All rights are reserved. Copying, 00013 * including reproducing, storing, adapting or translating, any 00014 * or all of this material requires the prior written consent of 00015 * Nokia Corporation. This material also contains confidential 00016 * information which may not be disclosed to others without the 00017 * prior written consent of Nokia Corporation. 00018 * ============================================================================= 00019 */ 00020 00021 #ifndef CSDPORIGINFIELD_H 00022 #define CSDPORIGINFIELD_H 00023 00024 // INCLUDES 00025 #include <e32base.h> 00026 #include <in_sock.h> 00027 #include <stringpool.h> 00028 #include "_sdpdefs.h" 00029 00030 // CONSTANTS 00031 const TInt KMaxAddressLength = 256; 00032 00033 // FORWARD DECLARATIONS 00034 class RReadStream; 00035 class RWriteStream; 00036 00037 // CLASS DECLARATION 00052 class CSdpOriginField : public CBase 00053 { 00054 public: // Constructors and destructor 00055 00063 IMPORT_C static CSdpOriginField* DecodeL( const TDesC8& aText ); 00064 00073 IMPORT_C static CSdpOriginField* DecodeLC( const TDesC8& aText ); 00074 00085 IMPORT_C static CSdpOriginField* NewL( const TDesC8& aUserName, 00086 TInt64 aSessionId, 00087 TInt64 aSessionVersion, 00088 TInetAddr& aAddress ); 00089 00101 IMPORT_C static CSdpOriginField* NewLC( const TDesC8& aUserName, 00102 TInt64 aSessionId, 00103 TInt64 aSessionVersion, 00104 TInetAddr& aAddress ); 00105 00120 IMPORT_C static CSdpOriginField* NewL( const TDesC8& aUserName, 00121 TInt64 aSessionId, 00122 TInt64 aSessionVersion, 00123 RStringF aNetType, 00124 RStringF aAddressType, 00125 const TDesC8& aAddress ); 00126 00142 IMPORT_C static CSdpOriginField* NewLC( const TDesC8& aUserName, 00143 TInt64 aSessionId, 00144 TInt64 aSessionVersion, 00145 RStringF aNetType, 00146 RStringF aAddressType, 00147 const TDesC8& aAddress ); 00148 00152 IMPORT_C ~CSdpOriginField(); 00153 00154 public: // New functions 00155 00163 IMPORT_C void EncodeL( RWriteStream& aStream ) const; 00164 00170 IMPORT_C CSdpOriginField* CloneL() const; 00171 00178 IMPORT_C TBool operator == ( const CSdpOriginField& aObj ) const; 00179 00185 IMPORT_C const TDesC8& UserName() const; 00186 00193 IMPORT_C void SetUserNameL( const TDesC8& aValue ); 00194 00200 IMPORT_C TInt64 SessionId() const; 00201 00207 IMPORT_C void SetSessionId( TInt64 aValue ); 00208 00214 IMPORT_C TInt64 Version() const; 00215 00221 IMPORT_C void SetVersion( TInt64 aValue ); 00222 00229 IMPORT_C RStringF NetType() const; 00230 00237 IMPORT_C RStringF AddressType() const; 00238 00247 IMPORT_C const TInetAddr* InetAddress() const; 00248 00254 IMPORT_C const TDesC8& Address() const; 00255 00264 IMPORT_C void SetInetAddress( const TInetAddr& aValue ); 00265 00279 IMPORT_C void SetAddressL( const TDesC8& aAddress, 00280 RStringF aNetType, 00281 RStringF aAddressType ); 00282 00283 public: // Internal to codec 00284 00290 void ExternalizeL( RWriteStream& aStream ) const; 00291 00298 static CSdpOriginField* InternalizeL( RReadStream& aStream ); 00299 00300 private: // Constructors 00301 00305 CSdpOriginField(); 00306 00313 void ConstructL( const TDesC8& aText ); 00314 00324 void ConstructL( const TDesC8& aUserName, 00325 TInt64 aSessionId, 00326 TInt64 aSessionVersion, 00327 TInetAddr& aUnicastAddress ); 00328 00342 void ConstructL( const TDesC8& aUserName, 00343 TInt64 aSessionId, 00344 TInt64 aSessionVersion, 00345 RStringF aNetType, 00346 RStringF aAddressType, 00347 const TDesC8& aAddress ); 00348 00349 // These are unnecessary? Derived from CBase, prevents the use 00350 CSdpOriginField( const CSdpOriginField& ); // Hidden. 00351 CSdpOriginField& operator = ( const CSdpOriginField& ); // Hidden 00352 00353 private: // New methods 00354 00361 TBool IsValidAddress( const TDesC8& aAddress ) const; 00362 00369 TBool IsValidAddress( const TInetAddr& addr ) const; 00370 00379 TBool TypeMatchesWithFormat( 00380 const TDesC8& aAddress, const TDesC8& aType, 00381 RStringPool aPool ) const; 00382 00389 TBool IsValidUserName( const TDesC8& aUserName ) const; 00390 00396 void ParseUserNameL( RArray<TPtrC8>& aArray ); 00397 00404 void ParseSessionIDAndVersionL( RArray<TPtrC8>& aArray ); 00405 00412 void ParseNetTypeAndAddressTypeL( RArray<TPtrC8>& aArray ); 00413 00420 void ParseAddressL( RArray<TPtrC8>& aArray ); 00421 00422 private: // Data 00423 00424 RStringPool iPool; 00425 00426 // <username> 00427 HBufC8* iUserName; 00428 // <session id> 00429 TInt64 iSessionId; 00430 // <version> 00431 TInt64 iSessionVersion; 00432 // <net type> 00433 RStringF iNetType; 00434 // <address type> 00435 RStringF iAddressType; 00436 // <address> 00437 // Either one is used (this or iAddressType/iAddress combo) 00438 // Can be defined as mutable because this variable does not affect 00439 // to the state of the object, but it is needed as const pointer 00440 // is returned on InetAddr() method 00441 mutable TInetAddr iUnicastAddress; 00442 TBuf8<KMaxAddressLength> iAddress; 00443 // For configuring the address into TInetAddr 00444 TBuf<KMaxAddressLength> iAddress16; 00445 00446 __DECLARE_TEST; 00447 }; 00448 00449 // CSDPORIGINFIELD_H 00450 #endif