2014-11-30 01:52:43 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2014 Alexandr Akulich <akulichalexander@gmail.com>
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONNECTCM_PROTOCOL_H
|
|
|
|
#define CONNECTCM_PROTOCOL_H
|
|
|
|
|
|
|
|
#include <TelepathyQt/BaseProtocol>
|
|
|
|
|
|
|
|
class ConnectConnection;
|
|
|
|
|
2016-06-16 09:16:35 +01:00
|
|
|
class KDEConnectTelepathyProtocol : public Tp::BaseProtocol
|
2014-11-30 01:52:43 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_DISABLE_COPY(KDEConnectTelepathyProtocol)
|
2016-06-16 09:16:35 +01:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Telepathy.ConnectionManager.kdeconnect")
|
2014-11-30 01:52:43 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
KDEConnectTelepathyProtocol(const QDBusConnection &dbusConnection, const QString &name);
|
2016-06-20 08:05:02 +01:00
|
|
|
~KDEConnectTelepathyProtocol() override;
|
2014-11-30 01:52:43 +00:00
|
|
|
|
|
|
|
QString connectionManagerName() const;
|
|
|
|
void setConnectionManagerName(const QString &newName);
|
|
|
|
|
2016-06-21 19:19:14 +01:00
|
|
|
public Q_SLOTS:
|
2016-06-22 11:19:24 +01:00
|
|
|
bool sendMessage(QString sender, QString senderName, QString message);
|
2014-11-30 01:52:43 +00:00
|
|
|
void setContactList(QStringList list);
|
|
|
|
|
2016-06-21 19:19:14 +01:00
|
|
|
Q_SIGNALS:
|
2014-11-30 01:52:43 +00:00
|
|
|
void contactsListChanged(QStringList);
|
|
|
|
void messageReceived(QString sender, QString message);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Tp::BaseConnectionPtr createConnection(const QVariantMap ¶meters, Tp::DBusError *error);
|
|
|
|
QString identifyAccount(const QVariantMap ¶meters, Tp::DBusError *error);
|
|
|
|
QString normalizeContact(const QString &contactId, Tp::DBusError *error);
|
|
|
|
|
|
|
|
// Proto.I.Addressing
|
|
|
|
QString normalizeVCardAddress(const QString &vCardField, const QString vCardAddress,
|
|
|
|
Tp::DBusError *error);
|
|
|
|
QString normalizeContactUri(const QString &uri, Tp::DBusError *error);
|
|
|
|
|
|
|
|
Tp::BaseProtocolAddressingInterfacePtr addrIface;
|
|
|
|
Tp::BaseProtocolAvatarsInterfacePtr avatarsIface;
|
|
|
|
|
|
|
|
QString m_connectionManagerName;
|
|
|
|
|
|
|
|
//normally keeping the connection in the protocol would be really weird
|
|
|
|
//however we want to proxy the messages to the active connection and want a single entry point
|
|
|
|
Tp::SharedPtr<ConnectConnection> m_connection;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline QString KDEConnectTelepathyProtocol::connectionManagerName() const
|
|
|
|
{
|
|
|
|
return m_connectionManagerName;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CONNECTCM_PROTOCOL_H
|