![]() |
QBluetoothZero
2.0
|
#include <QBtObjectExchangeClient.h>
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) |
QBtService & | getTransmittingService () |
QBtDevice & | getServerDevice () |
bool | isBusy () const |
bool | isConnected () const |
Friends | |
class | QBtObjectExchangeClientPrivate |
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.
QBtObjectExchangeClient::QBtObjectExchangeClient | ( | QObject * | parent | ) |
QBtObjectExchangeClient::~QBtObjectExchangeClient | ( | ) |
void QBtObjectExchangeClient::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.
files | The list of files to retrieve |
destinationFolder | The 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. |
retrieveOnlyNewFiles | If 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 | ||
) |
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.
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.
file | The 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
dataName | The name of the buffer. |
void QBtObjectExchangeClient::getFile | ( | const QString & | remoteFileAbsolutePath, |
const QString & | destinationFolder | ||
) |
getFile() Get a file from the remote Server
localPath | the path where the file will be saved |
remoteFileNameFull | the 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.
QBtService& QBtObjectExchangeClient::getTransmittingService | ( | ) |
Get info about the service connected to.
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 = "" | ) |
ONLY FOR WINDOWS
Browse the files of a selected folder.
folder | The 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. |
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.
regex | The 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. |
folder | The 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 | ||
) |
send the server a byte sequence.
data,the | data of the buffer |
bufferName,the | name 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.
fileName | The 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.
path | The remote folder to be set as current |
friend class QBtObjectExchangeClientPrivate [friend] |