HarmattanSyncApplications
serverplugins/syncmlserver/BTConnection.h
1/*
2* This file is part of buteo-sync-plugins package
3*
4* Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
5*
6* Author: Sateesh Kavuri <sateesh.kavuri@gmail.com>
7*
8* This library is free software; you can redistribute it and/or
9* modify it under the terms of the GNU Lesser General Public License
10* version 2.1 as published by the Free Software Foundation.
11*
12* This library is distributed in the hope that it will be useful, but
13* WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* Lesser General Public License for more details.
16*
17* You should have received a copy of the GNU Lesser General Public
18* License along with this library; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20* 02110-1301 USA
21*/
22
23#ifndef BTCONNECTION_H
24#define BTCONNECTION_H
25
26#include <QObject>
27#include <QMutex>
28#include <QtDBus>
29#include <QSocketNotifier>
30
31#include <buteosyncml5/OBEXConnection.h>
32
33class BTConnection : public QObject, public DataSync::OBEXConnection
34{
35 Q_OBJECT
36public:
37
38 BTConnection ();
39
40 virtual ~BTConnection ();
41
45 virtual int connect ();
46
50 virtual bool isConnected () const;
51
55 virtual void disconnect ();
56
57 void handleSyncFinished (bool isSyncInError);
58
62 bool init ();
63
67 void uninit ();
68
69signals:
70
71 void btConnected (int fd, QString btAddr);
72
73protected slots:
74
75 void handleIncomingBTConnection (int fd);
76
77 void handleBTError (int fd);
78
79private:
80 // Functions
81
85 int openBTSocket (const int channelNumber);
86
90 void closeBTSocket (int &fd);
91
95 void addFdListener (const int channelNumber, int fd);
96
100 void removeFdListener (const int channelNumber);
101
105 bool addServiceRecord (const QByteArray& sdp, quint32& recordId);
106
110 bool removeServiceRecords ();
111
115 bool readSRFromFile (const QString filename, QByteArray& record);
116
117 const QString clientServiceRecordDef () const;
118
119 const QString serverServiceRecordDef () const;
120
121private:
122
123 int mServerFd;
124
125 int mClientFd;
126
127 int mPeerSocket;
128
129 QMutex mMutex;
130
131 bool mDisconnected;
132
133 quint32 mClientServiceRecordId;
134
135 quint32 mServerServiceRecordId;
136
137 QSocketNotifier *mServerReadNotifier;
138
139 QSocketNotifier *mServerWriteNotifier;
140
141 QSocketNotifier *mServerExceptionNotifier;
142
143 QSocketNotifier *mClientReadNotifier;
144
145 QSocketNotifier *mClientWriteNotifier;
146
147 QSocketNotifier *mClientExceptionNotifier;
148
149 bool mServerFdWatching;
150
151 bool mClientFdWatching;
152
153};
154
155#endif // BTCONNECTION_H
Class for creating a connection to another device over Bluetooth for libmeegosyncml.
Definition clientplugins/syncmlclient/BTConnection.h:45
virtual bool isConnected() const
virtual void disconnect()
void uninit()
BT uninitialization method.
virtual ~BTConnection()
Destructor.
virtual int connect()
BTConnection()
Constructor.
bool init()
BT initialization method.