serverplugins/syncmlserver/BTConnection.h
/*
* This file is part of buteo-sync-plugins package
*
* Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
*
* Author: Sateesh Kavuri <sateesh.kavuri@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef BTCONNECTION_H
#define BTCONNECTION_H
#include <QObject>
#include <QMutex>
#include <QtDBus>
#include <QSocketNotifier>
#include <buteosyncml5/OBEXConnection.h>
class BTConnection : public QObject, public DataSync::OBEXConnection
{
Q_OBJECT
public:
BTConnection ();
virtual ~BTConnection ();
virtual int connect ();
virtual bool isConnected () const;
virtual void disconnect ();
void handleSyncFinished (bool isSyncInError);
bool init ();
void uninit ();
signals:
void btConnected (int fd, QString btAddr);
protected slots:
void handleIncomingBTConnection (int fd);
void handleBTError (int fd);
private:
// Functions
int openBTSocket (const int channelNumber);
void closeBTSocket (int &fd);
void addFdListener (const int channelNumber, int fd);
void removeFdListener (const int channelNumber);
bool addServiceRecord (const QByteArray& sdp, quint32& recordId);
bool removeServiceRecords ();
bool readSRFromFile (const QString filename, QByteArray& record);
const QString clientServiceRecordDef () const;
const QString serverServiceRecordDef () const;
private:
int mServerFd;
int mClientFd;
int mPeerSocket;
QMutex mMutex;
bool mDisconnected;
quint32 mClientServiceRecordId;
quint32 mServerServiceRecordId;
QSocketNotifier *mServerReadNotifier;
QSocketNotifier *mServerWriteNotifier;
QSocketNotifier *mServerExceptionNotifier;
QSocketNotifier *mClientReadNotifier;
QSocketNotifier *mClientWriteNotifier;
QSocketNotifier *mClientExceptionNotifier;
bool mServerFdWatching;
bool mClientFdWatching;
};
#endif // BTCONNECTION_H
BTConnection
Class for creating a connection to another device over Bluetooth for libmeegosyncml.
Definition clientplugins/syncmlclient/BTConnection.h:45
BTConnection::isConnected
virtual bool isConnected() const
BTConnection::disconnect
virtual void disconnect()
BTConnection::uninit
void uninit()
BT uninitialization method.
BTConnection::~BTConnection
virtual ~BTConnection()
Destructor.
BTConnection::connect
virtual int connect()
BTConnection::BTConnection
BTConnection()
Constructor.
BTConnection::init
bool init()
BT initialization method.