QBluetoothZero  2.0
QBtObjectExchangeServer.h
Go to the documentation of this file.
00001 /*
00002  * QBtObjectExchangeServer.h
00003  *
00004  *
00005  *      Author: Ftylitakis Nikolaos
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *      http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 
00020 #ifndef QBTOBJECTEXCHANGESERVER_H_
00021 #define QBTOBJECTEXCHANGESERVER_H_
00022 
00023 #include <QBtGlobal.h>
00024 #include <QBtTypes.h>
00025 #include <QBtServiceAdvertiser.h>
00026 #include <QtCore/QObject>
00027 
00028 QBT_NAMESPACE_BEGIN
00029 
00030 //Forward declaration
00031 class QBtObjectExchangeServerPrivate;
00032 
00033 // suggestion: (LV)
00034 //
00035 // use smart pointers for the service advertiser and reset it when
00036 // 'startServer' is called
00037 
00051 class DLL_EXPORT QBtObjectExchangeServer : public QObject
00052 {
00053     Q_OBJECT
00054 
00055 public:
00056     enum ErrorCode{
00057         QObexServerUndefined,
00058         QObexServerFailedToInitialize,
00059         QObexServerInUse,
00060         QObexServerClientAbortedTransfer,
00061         QObexServerAbortedTransmission,
00062         QObexServerSessionError,
00063         QObexServerSessionPutRequestProblem,
00064         QObexServerSessionCopyFileError
00065     };
00066 
00067 public:
00068     QBtObjectExchangeServer(QObject* parent);
00069     ~QBtObjectExchangeServer();
00070 
00074     bool isConnected();
00075 
00081     QBtService& getTransmittingServiceInfo();
00082 
00083 protected:
00084     void setTransmittingService(const QBtService& service);
00085 
00090     void startAdvertisingService(const QBtService& service);
00091 
00095     void stopAdvertisingService();
00096 
00097 public slots:
00104     void startServer (const QBtUuid & serviceId, const QString& serviceName = "My OBEX Service");
00105 
00110     void stopServer();
00111 
00112 signals:
00113 
00117     void serverStarted();
00118 
00122     void serverStopped();
00123 
00127     void error(ErrorCode code);
00128 
00133     void receivingObjectInfo(int overalDataSize, int bytesSent);
00134 
00139     void receivingStarted();
00140 
00147     void receivingStopped (const QString & receivedFileName);
00148 
00154     void transmittingRejected();
00155 
00160     void transmittingObjectInfo(int overalDataSize, int byteSent);
00161 
00165     void transmittingStarted (const QString & transmittingfileName);
00166 
00171     void transmittingStopped (const QString & transmittingfileName);
00172 
00176     void clientAbortedTransmittion();
00177 
00178 private:    
00179     QBtServiceAdvertiser*                       _advertiser;
00180     QBtService*                                         _service;
00181     QBtObjectExchangeServerPrivate* _implPtr;    
00182     bool                                                        _isConnected;
00183     
00184     friend class QBtObjectExchangeServerPrivate;
00185 };
00186 
00187 QBT_NAMESPACE_END
00188 
00189 //Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtObjectExchangeServer))
00190 
00191 #endif /* QBTOBJECTEXCHANGESERVER_H_ */