diff options
author | Javier <maemo@javispedro.com> | 2014-06-15 18:07:26 +0200 |
---|---|---|
committer | Javier <maemo@javispedro.com> | 2014-06-15 18:07:26 +0200 |
commit | cc29d7e1d1014b05d5b78a5e5531896b92ea6e49 (patch) | |
tree | 04964e3f7ac64974ab1517e6ba8252884f1be728 | |
parent | 716e886d437386fc0bc9d0d61f178a23587c6e1f (diff) | |
download | libgato-cc29d7e1d1014b05d5b78a5e5531896b92ea6e49.tar.gz libgato-cc29d7e1d1014b05d5b78a5e5531896b92ea6e49.zip |
small cleanup, preparing error signals
-rw-r--r-- | gatosocket.cpp | 3 | ||||
-rw-r--r-- | gatosocket.h | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gatosocket.cpp b/gatosocket.cpp index e46a811..c29b154 100644 --- a/gatosocket.cpp +++ b/gatosocket.cpp @@ -90,6 +90,7 @@ bool GatoSocket::connectTo(const GatoAddress &addr, unsigned short cid) void GatoSocket::close() { if (s != StateDisconnected) { + // TODO We do not flush the writeQueue, but rather drop all data. delete readNotifier; delete writeNotifier; readQueue.clear(); @@ -144,7 +145,7 @@ void GatoSocket::readNotify() int read = ::read(fd, buf.data(), buf.size()); if (read < 0) { - qErrnoWarning("Could not read to L2 socket"); + qErrnoWarning("Could not read from L2 socket"); close(); return; } else if (read == 0) { diff --git a/gatosocket.h b/gatosocket.h index 6bb6998..4b4afbf 100644 --- a/gatosocket.h +++ b/gatosocket.h @@ -7,6 +7,7 @@ #include "gatoaddress.h" +/** This class encapsulates a message-oriented bluetooth L2CAP socket. */ class GatoSocket : public QObject { Q_OBJECT @@ -22,17 +23,26 @@ public: StateConnected }; + enum Error { + TimeoutError, + UnknownError + }; + State state() const; bool connectTo(const GatoAddress &addr, unsigned short cid); void close(); + /** Dequeues a pending message from the rx queue. + * Doesn't block: if there are no pending messages, returns null QByteArray. */ QByteArray receive(); + /** Adds a message to the tx queue. */ void send(const QByteArray &pkt); signals: void connected(); void disconnected(); + void error(Error error); void readyRead(); private: |