obex/obexprotocol/obex/src/obexconstants.cpp
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 1997-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 <obexconstants.h>
       
    17 #include "obexconstantsinternal.h"
       
    18 #include <obex/internal/obexinternalconstants.h>
       
    19 #include "logger.h"
       
    20 
       
    21 #ifdef __FLOG_ACTIVE
       
    22 _LIT8(KLogComponent, "OBEX");
       
    23 #endif
       
    24 
       
    25 /**
       
    26 @file
       
    27 @internalComponent
       
    28 */
       
    29 
       
    30 /**
       
    31 Sets up class with default values
       
    32 @publishedAll
       
    33 @released
       
    34 */
       
    35 EXPORT_C TObexProtocolPolicy::TObexProtocolPolicy ()
       
    36 	{
       
    37 	LOG_LINE
       
    38 	LOG_FUNC
       
    39 
       
    40 	// Default set-up for version 0
       
    41 	// This is set for backwards compatibility, so change with caution!
       
    42 	iVersion = 0;
       
    43 	iReceiveMtu = KObexPacketDefaultSize;
       
    44 	iTransmitMtu = KObexPacketDefaultSize;
       
    45 	}
       
    46 
       
    47 /**
       
    48 Sets the maximum size of the receive packet buffer for the policy.
       
    49 For the IrDA transport, if the new receive buffer size is different to
       
    50 KObexPacketDefaultSize the receive packet size is set to equal the new
       
    51 buffer size.  Otherwise the packet size is set to the protocol defined limit.
       
    52 @param aReceiveMtu The new buffer size
       
    53 @return KErrNone on success. KErrArgument if the packet size is not supported
       
    54 @publishedAll
       
    55 @released
       
    56 */
       
    57 EXPORT_C TInt TObexProtocolPolicy::SetReceiveMtu ( TUint16 aReceiveMtu )
       
    58 	{
       
    59 	LOG_LINE
       
    60 	LOG_FUNC
       
    61 	LOG1(_L8("\taReceiveMtu = %d"), aReceiveMtu);
       
    62 
       
    63 	// Can't set size greater than the maximum, so only check if it's too small
       
    64 	if ( aReceiveMtu >= KObexPacketMinSize )
       
    65 		iReceiveMtu = aReceiveMtu;
       
    66 	
       
    67 	TInt ret = ( iReceiveMtu == aReceiveMtu ) ? KErrNone : KErrArgument;	
       
    68 	LOG1(_L8("\tret = %d"), ret);
       
    69 	return ret;
       
    70 	}
       
    71 
       
    72 /**
       
    73 Sets the maximum size of the transmit packet buffer for the policy
       
    74 @param aTransmitMtu The new buffer size
       
    75 @return KErrNone on success. KErrArgument if the packet size is not supported
       
    76 @publishedAll
       
    77 @released
       
    78 */
       
    79 EXPORT_C TInt TObexProtocolPolicy::SetTransmitMtu ( TUint16 aTransmitMtu )
       
    80 	{
       
    81 	LOG_LINE
       
    82 	LOG_FUNC
       
    83 	LOG1(_L8("\taTransmitMtu = %d"), aTransmitMtu);
       
    84 
       
    85 	// Can't set size greater than the maximum, so only check if it's too small
       
    86 	if ( aTransmitMtu >= KObexPacketMinSize )
       
    87 		iTransmitMtu = aTransmitMtu;
       
    88 
       
    89 	TInt ret = ( iTransmitMtu == aTransmitMtu ) ? KErrNone : KErrArgument;
       
    90 	LOG1(_L8("\tret = %d"), ret);
       
    91 	return ret;
       
    92 	}
       
    93 
       
    94 /**
       
    95 Gets the version of the protocol policy format that this class supports
       
    96 @return Protocol policy version
       
    97 @publishedAll
       
    98 @released
       
    99 */
       
   100 EXPORT_C TUint16 TObexProtocolPolicy::Version () const
       
   101 	{
       
   102 	LOG_LINE
       
   103 	LOG_FUNC
       
   104 
       
   105 	LOG1(_L8("\tiVersion = %d"), iVersion);
       
   106 	return iVersion;
       
   107 	}
       
   108 
       
   109 /**
       
   110 Gets the policy's receive packet buffer size
       
   111 @return Receive packet buffer size
       
   112 @publishedAll
       
   113 @released
       
   114 */
       
   115 EXPORT_C TUint16 TObexProtocolPolicy::ReceiveMtu () const
       
   116 	{
       
   117 	LOG_LINE
       
   118 	LOG_FUNC
       
   119 	   
       
   120 	LOG1(_L8("\tiReceiveMtu = %d"), iReceiveMtu);
       
   121 	return iReceiveMtu;
       
   122 	}
       
   123 
       
   124 /**
       
   125 Gets the policy's transmit packet buffer size
       
   126 @return Transmit packet buffer size
       
   127 @publishedAll
       
   128 @released
       
   129 */
       
   130 EXPORT_C TUint16 TObexProtocolPolicy::TransmitMtu () const
       
   131 	{
       
   132 	LOG_LINE
       
   133 	LOG_FUNC
       
   134 
       
   135 	LOG1(_L8("\tiTransmitMtu = %d"), iTransmitMtu);
       
   136 	return iTransmitMtu;
       
   137 	}
       
   138 
       
   139 // TObexConnectInfo
       
   140 /**
       
   141 @publishedAll
       
   142 @released
       
   143 */
       
   144 EXPORT_C TObexConnectInfo::TObexConnectInfo() 
       
   145 	{
       
   146 	LOG_LINE
       
   147 	LOG_FUNC
       
   148 
       
   149 	iVersion = KObexVersion;
       
   150 	iFlags = 0;
       
   151 	}
       
   152 
       
   153 /**
       
   154 @publishedAll
       
   155 @released
       
   156 */
       
   157 EXPORT_C TUint8 TObexConnectInfo::VersionMajor() const 
       
   158 	{
       
   159 	LOG_LINE
       
   160 	LOG_FUNC
       
   161 
       
   162 	return(STATIC_CAST(TUint8,(iVersion & 0xF0) >> 4));
       
   163 	}
       
   164 
       
   165 /**
       
   166 @publishedAll
       
   167 @released
       
   168 */
       
   169 EXPORT_C TUint8 TObexConnectInfo::VersionMinor() const 
       
   170 	{ 
       
   171 	LOG_LINE
       
   172 	LOG_FUNC
       
   173 
       
   174 	return(STATIC_CAST(TUint8,(iVersion & 0x0F)));
       
   175 	}