123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- /*
- * QBtObjectExchangeServer.h
- *
- *
- * Author: Ftylitakis Nikolaos
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #ifndef QBTOBJECTEXCHANGESERVER_H_
- #define QBTOBJECTEXCHANGESERVER_H_
- #include <QBtGlobal.h>
- #include <QBtTypes.h>
- #include <QBtServiceAdvertiser.h>
- #include <QtCore/QObject>
- QBT_NAMESPACE_BEGIN
- //Forward declaration
- class QBtObjectExchangeServerPrivate;
- // suggestion: (LV)
- //
- // use smart pointers for the service advertiser and reset it when
- // 'startServer' is called
- /**
- * This class is used to create an OBEX server.
- * After instantiation user can call startServer(const QString&)
- * to start the server. From the serviceName argument user can
- * specify the name of the OBEX service which is how the service will
- * be identified by other devices. By default the name is MyOBEX.
- *
- * If sever started successfully and is ready to use then serverStarted() signal is emitted.
- * At destruction time or if user calls stopServer(),terminates the service transmittion
- * and disconnects from any device connected and serverStopped() signal is emitted.
- *
- * All the remaining signals are only for feedback in case any action that is done.
- */
- class DLL_EXPORT QBtObjectExchangeServer : public QObject
- {
- Q_OBJECT
- public:
- enum ErrorCode{
- QObexServerUndefined,
- QObexServerFailedToInitialize,
- QObexServerInUse,
- QObexServerClientAbortedTransfer,
- QObexServerAbortedTransmission,
- QObexServerSessionError,
- QObexServerSessionPutRequestProblem,
- QObexServerSessionCopyFileError
- };
- public:
- QBtObjectExchangeServer(QObject* parent);
- ~QBtObjectExchangeServer();
- /**
- * Returns true if the server is connected.
- */
- bool isConnected();
- /**
- * If startServer() function is already called then using this function
- * the user can acquire the information of the transmitting service that
- * represents this server to the outside world.
- */
- QBtService& getTransmittingServiceInfo();
- protected:
- void setTransmittingService(const QBtService& service);
- /**
- * Initializes a new advertiser and starts the transmitting of the
- * service passed as argument.
- */
- void startAdvertisingService(const QBtService& service);
- /**
- * Stops the transmittion of the service (if any)
- */
- void stopAdvertisingService();
- public slots:
- /**
- *
- * Starts OBEX server by initializing the components needed
- * and by advertising the service by which the server will
- * be identified by other devices.
- */
- void startServer (const QBtUuid & serviceId, const QString& serviceName = "My OBEX Service");
- /**
- * Stops the server, terminates the service transmittion and disconnects
- * from any device connected
- */
- void stopServer();
- signals:
- /**
- * Emitted when server is successfully started and ready to use.
- */
- void serverStarted();
- /**
- * Emitted when server is disconnected and stopped
- */
- void serverStopped();
- /**
- * Emitted in case of error
- */
- void error(ErrorCode code);
- /**
- * Emitted as a feedback of the running receive status of
- * any data (file or byte buffer)
- */
- void receivingObjectInfo(int overalDataSize, int bytesSent);
- /**
- * Emitted when the transmittion of a file or byte buffer is started from a remote client
- * to the local device.
- */
- void receivingStarted();
- /**
- * Emitted when a receiving of a file or byte buffer is stopped,
- * being successfull or not.
- *
- * @param receivedFileName
- */
- void receivingStopped (const QString & receivedFileName);
- /**
- * If the server (local device) sends a request to start a transmittion to the remote client
- * connected, the client reserves the right to deny the transmittion before it begins.
- * In that case transmittingRejected() is emitted.
- */
- void transmittingRejected();
- /**
- * Emitted as a feedback of the running transmittion status of
- * any data (file or byte buffer) *
- */
- void transmittingObjectInfo(int overalDataSize, int byteSent);
- /**
- * Emitted when a transmittion is started from the local device to a remote device.
- */
- void transmittingStarted (const QString & transmittingfileName);
- /**
- * Emitted upon successfull or not end of transmittion from
- * the local device to a remote client.
- */
- void transmittingStopped (const QString & transmittingfileName);
- /**
- * Emitted if during a transmittion the client aborts it.
- */
- void clientAbortedTransmittion();
- private:
- QBtServiceAdvertiser* _advertiser;
- QBtService* _service;
- QBtObjectExchangeServerPrivate* _implPtr;
- bool _isConnected;
-
- friend class QBtObjectExchangeServerPrivate;
- };
- QBT_NAMESPACE_END
- //Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtObjectExchangeServer))
- #endif /* QBTOBJECTEXCHANGESERVER_H_ */
|