QBluetoothZero  2.0
QBtSerialPortClient.h
Go to the documentation of this file.
00001 /*
00002  * QBtSerialPortClient.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 QBTSERIALPORTCLIENT_H_
00021 #define QBTSERIALPORTCLIENT_H_
00022 
00023 #include <QBtGlobal.h>
00024 #include <QBtTypes.h>
00025 #include <QtCore/QObject>
00026 #include <QtCore/QByteArray>
00027 
00028 QBT_NAMESPACE_BEGIN
00029 
00030 //forward declaration
00031 class QBtSerialPortClientPrivate;
00032 
00059 class DLL_EXPORT QBtSerialPortClient : public QObject
00060 {
00061     Q_OBJECT
00062 
00063 public:    
00064     enum ErrorCode
00065     {
00066         ErrorAlreadyInUse,
00067         ErrorNotSupported,
00068         ErrorUnavailable,
00069         ErrorOpeningConnection,
00070         ErrorAlreadyConnected,
00071         ErrorUndefinedError,
00072         ErrorUnableToInitializePort,
00073         ErrorNoDeviceSelected,
00074         ErrorNoServiceSelected,
00075         ErrorConnectionError,
00076         ErrorConnectionTimeout,
00077         ErrorOnDisconnecting
00078     };
00079 
00080 public:
00086     QBtSerialPortClient(QObject* parent);
00087 
00093     ~QBtSerialPortClient();
00094 
00100     bool isConnected();
00101 
00102 public slots:
00109     void connect(const QBtDevice& remoteDevice, const QBtService& remoteService);
00110 
00115     void disconnect();
00116 
00123     void sendData(const QString& data);
00124     
00129     void sendData (const QByteArray & data);
00130 
00131 signals:
00135     void disconnectedFromServer();
00136     
00140     void connectionResetByPeer ();    
00141 
00145     void connectedToServer();
00146 
00151     void dataSent();
00152 
00156     void dataReceived(const QString & data);
00157 
00162     void dataReceived(const QByteArray & data);
00163 
00167     void error(QBtSerialPortClient::ErrorCode error);
00168 
00169 private:
00170     friend class QBtSerialPortClientPrivate;
00171     QBtSerialPortClientPrivate* _implPtr;
00172 };
00173 
00174 QBT_NAMESPACE_END
00175 
00176 //Q_DECLARE_METATYPE(QBT_PREPEND_NAMESPACE(QBtSerialPortClient))
00177 
00178 #endif /* QBTSERIALPORTCLIENT_H_ */