ea214f4fb6af7a59808236c5d728ae778b2d6ff4
[vicar] / src / vicar-telepathy / src / connection.h
1 /*
2 @version: 0.5
3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
5
6 Based on Telepathy-SNOM with copyright notice below.
7 */
8
9 /*
10  * Telepathy SNOM VoIP phone connection manager
11  * Copyright (C) 2006 by basyskom GmbH
12  *  @author Tobias Hunger <info@basyskom.de>
13  *
14  * This library is free software; you can redisQObject::tribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License version 2.1 as published by the Free Software Foundation.
17  *
18  * This library is disQObject::tributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the
25  * Free Software Foundation, Inc.,
26  * 51 Franklin SQObject::treet, Fifth Floor, Boston, MA  02110-1301  USA
27  */
28
29 #ifndef _VICAR_CONNECTION_H_
30 #define _VICAR_CONNECTION_H_
31
32 #include "connectiontypes.h"
33 #include "connectioninterfacerequeststypes.h"
34 #include "connectioninterfacecapabilitiestypes.h"
35
36 #include <QtDBus/QDBusContext>
37 #include <QtDBus/QtDBus>
38
39 class ConnectionPrivate;
40
41 class Connection : public QObject, protected QDBusContext
42 {
43     Q_OBJECT
44
45 public:
46     explicit Connection(const QString & account,
47                         QObject * parent = 0);
48     ~Connection();
49
50     QString name() const;
51     QString serviceName() const;
52     QDBusObjectPath objectPath() const;
53
54     bool registerObject();
55     void unregisterObject();
56
57     enum Status
58     {
59         Connected = 0,
60         Connecting = 1,
61         Disconnected = 2
62     };
63
64     enum Reason
65     {
66         ReasonNone = 0,
67         ReasonRequested = 1,
68         ReasonNetworkError = 2,
69         ReasonAuthenticationFailed = 3,
70         ReasonEncryptionError = 4,
71         ReasonNameInUse = 5,
72         ReasonCertNotProvided = 6,
73         ReasonCertUntrusted = 7,
74         ReasonCertExpired = 8,
75         ReasonCertNotActivated = 9,
76         ReasonCertHostnameMismatch = 10,
77         ReasonCertFingerprintMismatch = 11,
78         ReasonCertSelfSigned = 12,
79         ReasonCertOtherError = 13
80     };
81
82     enum Handle
83     {
84         HandleNone = 0,
85         HandleContact = 1,
86         HandleRoom = 2,
87         HandleRoomList = 3,
88         HandleGroup = 4
89     };
90
91 public slots:
92     //org.freedesktop.Telepathy.Connection
93     void Connect();
94     void Disconnect();
95
96     QStringList GetInterfaces();
97     QString GetProtocol();
98     uint GetStatus();
99
100     uint GetSelfHandle();
101     QList<uint> RequestHandles(const uint handle_type, const QStringList &names);
102     void HoldHandles(const uint handle_type, const QList<uint> &handles);
103     QStringList InspectHandles(const uint handle_type, const QList<uint> &handles);
104     void ReleaseHandles(const uint handle_type, const QList<uint> &handles);
105
106     org::freedesktop::Telepathy::ChannelInfoList ListChannels();
107     QDBusObjectPath RequestChannel(const QString &type,
108                                    uint handle_type, uint handle,
109                                    bool suppress_handler);
110
111     //org.freedesktop.Telepathy.Connection.Interface.Requests
112     QDBusObjectPath CreateChannel(const QVariantMap &request,
113                                   QVariantMap &channel_properties);
114
115     bool EnsureChannel(const QVariantMap &request,
116                        QDBusObjectPath &channel_object,
117                        QVariantMap &channel_properties);
118     //org.freedesktop.Telepathy.Connection.Interface.Capabilities
119     org::freedesktop::Telepathy::CapabilityPairList AdvertiseCapabilities(org::freedesktop::Telepathy::CapabilityPairList Add,
120                                                                           const QStringList &Remove);
121     org::freedesktop::Telepathy::ContactCapabilitiesList GetCapabilities(const QList<uint> &Handles);
122
123 protected slots:
124     QDBusObjectPath processChannel(const QVariantMap &request);
125
126 signals:
127     void NewChannel(const QDBusObjectPath & object_path,
128                     const QString & channel_type,
129                     uint handle_type, uint handle,
130                     bool suppress_handler);
131     void StatusChanged(uint status, uint reason);
132
133     //org.freedesktop.Telepathy.Connection.Interface.Requests
134     void ChannelClosed(const QDBusObjectPath &removed_channel_object);
135     void NewChannels(org::freedesktop::Telepathy::ChannelDetailsList new_channels);
136
137     //org.freedesktop.Telepathy.Connection.Interface.Capabilities
138     void CapabilitiesChanged(org::freedesktop::Telepathy::CapabilityChangeList changes);
139
140 private:
141     Connection(const Connection &); // no impl.
142     ConnectionPrivate * const d;
143 };
144
145 #endif