QBluetoothZero  2.0
QBtObjectExchangeClient Class Reference

#include <QBtObjectExchangeClient.h>

List of all members.

Public Types

enum  ErrorCode {
  OBEXClientConnectionError, OBEXClientSendError, OBEXClientReceiveError, OBEXClientDisconnected,
  OBEXClientInUse, OBEXClientInternalError, OBEXClientNoSelectedDevice, OBEXClientNoSelectedService,
  OBEXClientUnableToSetPath, OBEXFeatureNotSupported, OBEXClientBrowseError
}

Public Slots

void disconnect ()

Signals

void error (QBtObjectExchangeClient::ErrorCode code)
void connectedToServer ()
void disconnectedFromServer ()
void objectSent ()
void fileReceived (const QString &fileName)
void dataReceived (const QByteArray &data)
void remotePathSet (const QString &pathName)
void folderBrowsingResultElement (const QBtRemoteFileInfo &file)

Public Member Functions

 QBtObjectExchangeClient (QObject *parent)
 ~QBtObjectExchangeClient ()
void connectToServer (const QBtDevice &remoteDevice, const QBtService &remoteService)
void getFile (const QString &remoteFileAbsolutePath, const QString &destinationFolder)
void getByteBuffer (const QString &dataName)
void putFile (const QString &fileName)
void putByteBuffer (const QByteArray &data, const QString &bufferName)
void abort ()
void setPath (const QString &path)
QString getWorkingPath ()
QList< QBtRemoteFileInfo * > initiateFolderBrowsing (const QString &folderPath="")
QList< QBtRemoteFileInfo * > locateFiles (QRegExp *regex=0, QString folder="")
void batchFileRetrieval (const QList< QBtRemoteFileInfo * > &files, const QString destinationFolder, bool retrieveOnlyNewFiles=false)
QBtServicegetTransmittingService ()
QBtDevicegetServerDevice ()
bool isBusy () const
bool isConnected () const

Friends

class QBtObjectExchangeClientPrivate

Detailed Description

Class that provides the mechanism to connect to a remote OBEX server and send or recieve files or raw data.

After instantiation user can call connectToServer(QBtDevice&, QBtService&) to connect to the remote server specified by the remoteDevice argument to its service provide by remoteService argument.

P.S. At the remote service, one of the supported protocols must be QBtConstants::OBEX. Suggestion, use a service whose class is equal to QBtConstants::OBEXObjectPush or QBtConstants::OBEXFileTransfer. Again, it is suggested to use QBtConstants::OBEXObjectPush. Both options will work fine if the user wants to send a file to the server, but at present further operations can be done using QBtConstants::OBEXObjectPush.

Signal connectedToServer() is emitted upon successfull connection to the OBEX server.

After the successfull connection to the server, user can call putFile(const QString&) to send to the remote server the file specified by the string passed as argument. If successfull then objectSent() signal is emitted.

Also user is able to send a request to get a file from the remote server specifing the absolute path of the file to be fetched at the remote device's file system. Also a local path must be set which is where the file will be stored after the successfull transfer. getFile(const QString& localPath, const QString& remoteFileNameFull) If successfull then fileReceived(const QString) is emitted.

getByteBuffer() and putByteBuffer() are implemented but not tested. If successfull they emit dataReceived(const QByteArray) and objectSent() respectively.

If connected to an OBEX FTP bluetooth service then setPath() can be called to set the remote working directory. If successfull then remotePathSet(const QString) will be emitted.

User can abort any transmittion in progress by calling abort().

User can disconnect from the server at any time or the disconnection will take place at destruction time. Any transmittion in progress will be terminated instantly. A successfull disconnection emits disconnectedFromServer() signal.


Member Enumeration Documentation

Enumerator:
OBEXClientConnectionError 
OBEXClientSendError 
OBEXClientReceiveError 
OBEXClientDisconnected 
OBEXClientInUse 
OBEXClientInternalError 
OBEXClientNoSelectedDevice 
OBEXClientNoSelectedService 
OBEXClientUnableToSetPath 
OBEXFeatureNotSupported 
OBEXClientBrowseError 

Constructor & Destructor Documentation

QBtObjectExchangeClient::QBtObjectExchangeClient ( QObject *  parent)
QBtObjectExchangeClient::~QBtObjectExchangeClient ( )

Member Function Documentation

void QBtObjectExchangeClient::abort ( )

abort()

abort any panding or running transmittion.

void QBtObjectExchangeClient::batchFileRetrieval ( const QList< QBtRemoteFileInfo * > &  files,
const QString  destinationFolder,
bool  retrieveOnlyNewFiles = false 
)

batchFileRetrieval

ONLY FOR WINDOWS

Convenient method to retrieve multiple files in the row.

Parameters:
filesThe list of files to retrieve
destinationFolderThe folder in the local file system where the files will be stored. The files are placed all in that directory same directory so the structure in the remote file system is not preserved.
retrieveOnlyNewFilesIf set true, then it first check if the file defined already exists in the destination folder. If it does then it skips it. By default it is set to copy every file it founds.
void QBtObjectExchangeClient::connectedToServer ( ) [signal]

Emitted upon successfull connection to the OBEX server.

void QBtObjectExchangeClient::connectToServer ( const QBtDevice remoteDevice,
const QBtService remoteService 
)

connectToServer()

Connect to a remote server defined by parameter 1 to its service defined by parameter 2.

P.S. At the remote service, one of the supported protocols must be QBtConstants::OBEX. Suggestion, use a service whose class is equal to QBtConstants::OBEXObjectPush or QBtConstants::OBEXFileTransfer. Again, it is suggested to use QBtConstants::OBEXObjectPush. Both options will work fine if the user wants to send a file to the server, but at present further operations can be done using QBtConstants::OBEXObjectPush.

Parameters:
remoteDevice
remoteService
void QBtObjectExchangeClient::dataReceived ( const QByteArray &  data) [signal]

Emitted when a byte buffer is received from the server

void QBtObjectExchangeClient::disconnect ( ) [slot]
void QBtObjectExchangeClient::disconnectedFromServer ( ) [signal]

Emitted upon disconnection from the server.

void QBtObjectExchangeClient::error ( QBtObjectExchangeClient::ErrorCode  code) [signal]

Emitted in case of error

void QBtObjectExchangeClient::fileReceived ( const QString &  fileName) [signal]

Emitted when a file is received from the server

void QBtObjectExchangeClient::folderBrowsingResultElement ( const QBtRemoteFileInfo file) [signal]

Emitted after calling initiateFolderBrowsing function for every result found from browsing.

Parameters:
fileThe file info. See QBtRemoteFileInfo class for the info provided.
void QBtObjectExchangeClient::getByteBuffer ( const QString &  dataName)

getByteBuffer(const QString& dataName) Request from the server to GET the data buffer defined in the argument

Parameters:
dataNameThe name of the buffer.
void QBtObjectExchangeClient::getFile ( const QString &  remoteFileAbsolutePath,
const QString &  destinationFolder 
)

getFile() Get a file from the remote Server

Parameters:
localPaththe path where the file will be saved
remoteFileNameFullthe name of the file to be transfered containing the full path of its remote location
QBtDevice& QBtObjectExchangeClient::getServerDevice ( )

Get info about the server connected to.

Returns:
An object containing the remote server device info.
QBtService& QBtObjectExchangeClient::getTransmittingService ( )

Get info about the service connected to.

Returns:
An object containing the service info
QString QBtObjectExchangeClient::getWorkingPath ( )

getWorkingPath

ONLY FOR WINDOWS

Return as QString holding the absolute path of the current working directory

QList<QBtRemoteFileInfo*> QBtObjectExchangeClient::initiateFolderBrowsing ( const QString &  folderPath = "")

initiateFolderBrowsing()

ONLY FOR WINDOWS

Browse the files of a selected folder.

Parameters:
folderThe folder path must either be absolute (e.g. :), or it must be the name of the folder you are going to browse as long as the folder is inside the current working directory of yours.
Returns:
QList<QBtRemoteFileInfo*> a list of the files/folders found and their attributes
bool QBtObjectExchangeClient::isBusy ( ) const

Checks if the client is performing some operation.

bool QBtObjectExchangeClient::isConnected ( ) const

Checks if the client got a connection (it does not check *now* if the client is still connected).

QList<QBtRemoteFileInfo*> QBtObjectExchangeClient::locateFiles ( QRegExp *  regex = 0,
QString  folder = "" 
)

locateFiles

ONLY FOR WINDOWS

Locate files/folders that comply to the regex passed as arguments. For example can be used to isolate files of specific type.

Parameters:
regexThe regex that describes the files that are needed to be selected. If this parameter is not set, the default operation is to select all the files in the specified folder.
folderThe folder path must either be absolute (e.g. :), or it must be the name of the folder you are going to browse as long as the folder is inside the current working directory of yours. If this parameter is not set, the default operation is to search in the current working directory.
void QBtObjectExchangeClient::objectSent ( ) [signal]

Emitted upon successfull transmittion of an object

void QBtObjectExchangeClient::putByteBuffer ( const QByteArray &  data,
const QString &  bufferName 
)

putByteBuffer()

send the server a byte sequence.

Parameters:
data,thedata of the buffer
bufferName,thename of the buffer (used for convenience on the data processing of the server)
void QBtObjectExchangeClient::putFile ( const QString &  fileName)

Send a specified file from the local file system to the remote OBEX server.

Parameters:
fileNameThe file name of the file to be sent. The absolute path of the file is required.
void QBtObjectExchangeClient::remotePathSet ( const QString &  pathName) [signal]

Emitted upon successfull set of the remote current working directory.

void QBtObjectExchangeClient::setPath ( const QString &  path)

setPath(const QString path)

Set the current path of the remote device OBEX session.

Parameters:
pathThe remote folder to be set as current

Friends And Related Function Documentation

friend class QBtObjectExchangeClientPrivate [friend]

The documentation for this class was generated from the following file: