|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : ChatServiceSearcher.cpp 00004 * Part of : Chat 00005 * Interface : 00006 * Description : 00007 * Version : 00008 * 00009 * Copyright (c) 2005-2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 // INCLUDE FILES 00017 #include <bt_sock.h> 00018 #include "ChatServiceSearcher.h" 00019 #include "ChatBtServiceSearcher.pan" 00020 00021 00022 // ============================ MEMBER FUNCTIONS =============================== 00023 00024 // ---------------------------------------------------------------------------- 00025 // CChatServiceSearcher::NewL() 00026 // Two-phased constructor. 00027 // ---------------------------------------------------------------------------- 00028 // 00029 CChatServiceSearcher* CChatServiceSearcher::NewL( MLog& aLog ) 00030 { 00031 CChatServiceSearcher* self = CChatServiceSearcher::NewLC( aLog ); 00032 CleanupStack::Pop( self ); 00033 return self; 00034 } 00035 00036 // ---------------------------------------------------------------------------- 00037 // CChatServiceSearcher::NewLC() 00038 // Two-phased constructor. 00039 // ---------------------------------------------------------------------------- 00040 // 00041 CChatServiceSearcher* CChatServiceSearcher::NewLC( MLog& aLog ) 00042 { 00043 CChatServiceSearcher* self = new ( ELeave ) CChatServiceSearcher( aLog ); 00044 CleanupStack::PushL( self ); 00045 self->ConstructL(); 00046 return self; 00047 } 00048 00049 // ---------------------------------------------------------------------------- 00050 // CChatServiceSearcher::CChatServiceSearcher() 00051 // Construcor. 00052 // ---------------------------------------------------------------------------- 00053 // 00054 CChatServiceSearcher::CChatServiceSearcher( MLog& aLog ) 00055 : CChatBtServiceSearcher( aLog ), 00056 iServiceClass( KServiceClass ), 00057 iPort( -1 ) 00058 { 00059 } 00060 00061 // ---------------------------------------------------------------------------- 00062 // CChatServiceSearcher::~CChatServiceSearcher() 00063 // Destructor. 00064 // ---------------------------------------------------------------------------- 00065 // 00066 CChatServiceSearcher::~CChatServiceSearcher() 00067 { 00068 iProtocolArray.Close(); 00069 } 00070 00071 // ---------------------------------------------------------------------------- 00072 // CChatServiceSearcher::ConstructL() 00073 // Symbian 2nd phase constructor can leave. 00074 // ---------------------------------------------------------------------------- 00075 // 00076 void CChatServiceSearcher::ConstructL() 00077 { 00078 // no implementation required 00079 } 00080 00081 // ---------------------------------------------------------------------------- 00082 // CChatServiceSearcher::ServiceClass() 00083 // The service class to search. 00084 // ---------------------------------------------------------------------------- 00085 // 00086 const TUUID& CChatServiceSearcher::ServiceClass() const 00087 { 00088 return iServiceClass; 00089 } 00090 00091 // ---------------------------------------------------------------------------- 00092 // CChatServiceSearcher::ProtocolList() 00093 // The list of Protocols required by the service. 00094 // ---------------------------------------------------------------------------- 00095 // 00096 RArray <TChatSdpAttributeParser::TChatSdpAttributeNode>& CChatServiceSearcher 00097 ::ProtocolList() 00098 { 00099 TChatSdpAttributeParser::TChatSdpAttributeNode attrib; 00100 attrib.SetCommand( TChatSdpAttributeParser::ECheckType ); 00101 attrib.SetType( ETypeDES ); 00102 iProtocolArray.Append( attrib ); 00103 00104 attrib.SetCommand( TChatSdpAttributeParser::ECheckType ); 00105 attrib.SetType( ETypeDES ); 00106 iProtocolArray.Append( attrib ); 00107 00108 attrib.SetCommand( TChatSdpAttributeParser::ECheckValue ); 00109 attrib.SetType( ETypeUUID ); 00110 attrib.SetValue( KL2CAP ); 00111 iProtocolArray.Append( attrib ); 00112 00113 attrib.SetCommand( TChatSdpAttributeParser::ECheckEnd ); 00114 iProtocolArray.Append( attrib ); 00115 00116 attrib.SetCommand( TChatSdpAttributeParser::ECheckType ); 00117 attrib.SetType( ETypeDES ); 00118 iProtocolArray.Append( attrib ); 00119 00120 attrib.SetCommand( TChatSdpAttributeParser::ECheckValue ); 00121 attrib.SetType( ETypeUUID ); 00122 attrib.SetValue( KRFCOMM ); 00123 iProtocolArray.Append( attrib ); 00124 00125 attrib.SetCommand( TChatSdpAttributeParser::EReadValue ); 00126 attrib.SetType( ETypeUint ); 00127 attrib.SetValue( KRfcommChannel ); 00128 iProtocolArray.Append( attrib ); 00129 00130 attrib.SetCommand( TChatSdpAttributeParser::ECheckEnd ); 00131 iProtocolArray.Append( attrib ); 00132 00133 attrib.SetCommand( TChatSdpAttributeParser::ECheckEnd ); 00134 iProtocolArray.Append( attrib ); 00135 00136 attrib.SetCommand( TChatSdpAttributeParser::EFinished ); 00137 iProtocolArray.Append( attrib ); 00138 00139 return iProtocolArray; 00140 } 00141 00142 // ---------------------------------------------------------------------------- 00143 // CChatServiceSearcher::FoundElementL() 00144 // Read the data element. 00145 // ---------------------------------------------------------------------------- 00146 // 00147 void CChatServiceSearcher::FoundElementL( TInt aKey, CSdpAttrValue& aValue ) 00148 { 00149 __ASSERT_ALWAYS( aKey == static_cast<TInt>( KRfcommChannel ), 00150 Panic( EChatBtServiceSearcherProtocolRead ) ); 00151 iPort = aValue.Uint(); 00152 } 00153 00154 // ---------------------------------------------------------------------------- 00155 // CChatServiceSearcher::Port() 00156 // Port connection on the remote machine. 00157 // ---------------------------------------------------------------------------- 00158 // 00159 TInt CChatServiceSearcher::Port() 00160 { 00161 return iPort; 00162 } 00163 00164 // End of File
|
© Nokia 2006 |