kdeconnect-kde/telepathy-cm/protocol.h
David Edmundson e4cbf22519 Telepathy integration
This sends recieved text messages to any Telepathy client and allows the
user to respond from there.
This should work with both our clients and Empathy.

An account on telepathy is created on activation.

As Telepathy clients expect backends to be always running, this is
started by the daemon to
suppress client errors. The plugin system then talks to the same CM via
use of a singleton accessor.

Based on work by Alexandr Akulich then tidied up and rebased.
2015-09-10 20:36:46 +02:00

68 lines
2.3 KiB
C++

/*
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 "connectcm_export.h"
#include <TelepathyQt/BaseProtocol>
class ConnectConnection;
class CONNECTCM_EXPORT KDEConnectTelepathyProtocol : public Tp::BaseProtocol
{
Q_OBJECT
Q_DISABLE_COPY(KDEConnectTelepathyProtocol)
public:
KDEConnectTelepathyProtocol(const QDBusConnection &dbusConnection, const QString &name);
virtual ~KDEConnectTelepathyProtocol();
QString connectionManagerName() const;
void setConnectionManagerName(const QString &newName);
public slots:
bool sendMessage(QString sender, QString message);
void setContactList(QStringList list);
signals:
void contactsListChanged(QStringList);
void messageReceived(QString sender, QString message);
private:
Tp::BaseConnectionPtr createConnection(const QVariantMap &parameters, Tp::DBusError *error);
QString identifyAccount(const QVariantMap &parameters, 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