📄 trfcommserviceseeker.h
字号:
/*****************************************************************************
COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2003.
The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
The use of the software is subject to the terms of the end-user license
agreement which accompanies or is included with the software. The software is
provided "as is" and Sony Ericsson specifically disclaim any warranty or
condition whatsoever regarding merchantability or fitness for a specific
purpose, title or non-infringement. No warranty of any kind is made in
relation to the condition, suitability, availability, accuracy, reliability,
merchantability and/or non-infringement of the software provided herein.
*****************************************************************************/
#ifndef _TRFCOMMSERVICESEEKER_H_
#define _TRFCOMMSERVICESEEKER_H_
#include <btsdp.h>
class MRFCOMMServiceSeeker
{
public:
virtual void SearchResult(TInt aError, TUint8 aPort)=0; // user implemented
};
class CRFCOMMServiceFinder : public CBase, public MSdpElementBuilder, public MSdpAgentNotifier
{
public:
static CRFCOMMServiceFinder* NewL( const TUUID& aServiceClass,
const TBTDevAddr& aDevAddr,
MRFCOMMServiceSeeker& aSeeker);
// Destruction
~CRFCOMMServiceFinder();
void FindPortL(); //Starts the search
//Inherits MBuilder and MSdpAgentNotifier interfaces,
//most importantly...
MSdpElementBuilder* BuildUintL(const TDesC8& aUint);
MSdpElementBuilder* BuildUUIDL(const TUUID& aUUID);
MSdpElementBuilder* BuildDESL() {return this;}
MSdpElementBuilder* BuildDEAL() {return this;}
MSdpElementBuilder* StartListL() {return this;}
MSdpElementBuilder* EndListL() {return this;}
// All others are errors, so don't override the default (leaves)
void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount);
void AttributeRequestResult(TSdpServRecordHandle, TSdpAttributeID, CSdpAttrValue*) {User::Panic(_L("RFCOMMSEEK"), 0);} // Not using this API form
void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
private:
// Constructor
CRFCOMMServiceFinder(const TUUID& aServiceClass, MRFCOMMServiceSeeker& aSeeker);
void ConstructL(const TBTDevAddr& aDevAddr, const TUUID& aServiceClass);
// Member data
CSdpAgent* iAgent;
CSdpSearchPattern* iPattern;
TUUID iServiceClassUUID;
TBool iFoundRFCOMMUUID;
//TUint8 iPort;
MRFCOMMServiceSeeker& iSeeker;//initialised from aSeeker in the constructor
public:
TUint8 iPort;
};
class CActiveRFCOMMPortFinder : public CActive, public MRFCOMMServiceSeeker
{
public:
static CActiveRFCOMMPortFinder* NewL( const TUUID& aServiceClass,
const TBTDevAddr& aDevAddr);
~CActiveRFCOMMPortFinder();
protected:
void RunL();
void DoCancel();
public:
void SearchResult(TInt aError, TUint8 aPort);
private:
CActiveRFCOMMPortFinder();
void ConstructL(const TUUID& aServiceClass, const TBTDevAddr& aDevAddr);
enum TPortFinderStates
{
EPFStateInitiating,
EPFStateFinding
};
TPortFinderStates iState;
CRFCOMMServiceFinder* iFinder;
public:
TUint8 iFoundPort;
};
#endif // define _TRFCOMMSERVICESEEKER_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -