irda/irdastack/SSRC/client-side/IASQuery.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1999-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 /**
       
    17  @file
       
    18  @internalAll
       
    19 */
       
    20 
       
    21 #include <ir_sock.h>
       
    22 #include "client_util.H"
       
    23 
       
    24 EXPORT_C TIASQuery::TIASQuery()
       
    25 /** Constructs an empty IAS query object.
       
    26 
       
    27 The class name, the attribute and the remote device name must be set before 
       
    28 this query object can be used. */
       
    29 	{
       
    30 	}
       
    31 
       
    32 EXPORT_C TIASQuery::TIASQuery(const TDesC8& aClass,const TDesC8& aAttribute,TUint aRemoteDevAddr)
       
    33 /** Constructs a new IAS query taking the class name, the attribute and the remote 
       
    34 device address.
       
    35 
       
    36 @param aClass The IAS query class name. 
       
    37 @param aAttribute The IAS query attribute. 
       
    38 @param aRemoteDevAddr The 32 bit address of the remote device to be queried. 
       
    39 This is needed because the underlying IrLAP connection may not yet have been 
       
    40 established. */
       
    41 	{
       
    42 	Set(aClass,aAttribute,aRemoteDevAddr);
       
    43 	}
       
    44 
       
    45 //
       
    46 // Construct a descriptor with an IAS query inside it.
       
    47 //
       
    48 EXPORT_C void TIASQuery::Set(const TDesC8& aClass,const TDesC8& aAttribute,TUint aRemoteDevAddr)
       
    49 /** Changes the class name, the attribute and the remote device address of the 
       
    50 IAS query.
       
    51 
       
    52 @param aClass The IAS query class name. 
       
    53 @param aAttribute The IAS query attribute. 
       
    54 @param aRemoteDevAddr The 32 bit address of the remote device to be queried. */
       
    55 	{
       
    56 	Zero();
       
    57 	*WPtr()=(TUint8)aClass.Length();
       
    58 	SetLength(1);
       
    59 
       
    60 	//handle class name and attribute
       
    61 	Append(aClass);
       
    62 	SetLength(Length()+1);
       
    63 	operator[](Length()-1)=(TUint8)aAttribute.Length();
       
    64 	Append(aAttribute);
       
    65 
       
    66 	//handle device address
       
    67 	__ASSERT_ALWAYS(Length()+4<=MaxLength(),IrdaUtil::Panic(EIASQueryDes8Overflow));
       
    68 	BigEndian::Put32(WPtr()+Size(),aRemoteDevAddr);
       
    69 	SetLength(Length()+4);
       
    70 	}
       
    71 
       
    72 //
       
    73 // Dole out our contents
       
    74 //
       
    75 EXPORT_C void TIASQuery::Get(TDes8& aClass,TDes8& aAttribute,TUint& aRemoteDevAddr)
       
    76 /** Retrieves the detail of this IAS query.
       
    77 
       
    78 @param aClass On return, contains the IAS query class name. 
       
    79 @param aAttribute On return, contains the IAS query attribute. 
       
    80 @param aRemoteDevAddr On return, contains the 32 bit address of the remote 
       
    81 device to be queried. */
       
    82 	{
       
    83 	aClass.Copy(Ptr()+1,operator[](0));
       
    84 	aAttribute.Copy(Ptr()+1+operator[](0),operator[](operator[](0)+1));
       
    85    	aRemoteDevAddr=BigEndian::Get32(Ptr()+Length()-4);
       
    86 	}
       
    87 
       
    88 // EOF