2
* Copyright (C) 2013 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
17
* Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
20
#ifndef MOCKCONNECTION_H
21
#define MOCKCONNECTION_H
27
#include <TelepathyQt/BaseConnection>
28
#include <TelepathyQt/BaseChannel>
29
#include <TelepathyQt/BaseCall>
30
#include <TelepathyQt/AbstractAdaptor>
31
#include <TelepathyQt/DBusError>
34
#include "textchannel.h"
35
#include "callchannel.h"
36
#include "dbustypes.h"
38
class MockTextChannel;
39
class MockCallChannel;
40
class MockConnectionDBus;
42
class MockConnection : public Tp::BaseConnection
45
Q_DISABLE_COPY(MockConnection)
47
MockConnection(const QDBusConnection &dbusConnection,
48
const QString &cmName,
49
const QString &protocolName,
50
const QVariantMap ¶meters);
52
QStringList inspectHandles(uint handleType, const Tp::UIntList& handles, Tp::DBusError *error);
53
Tp::UIntList requestHandles(uint handleType, const QStringList& identifiers, Tp::DBusError* error);
54
Tp::BaseChannelPtr createChannel(const QString& channelType, uint targetHandleType,
55
uint targetHandle, Tp::DBusError *error);
56
Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);
57
uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);
58
void connect(Tp::DBusError *error);
59
void setOnline(bool online);
61
Tp::BaseConnectionRequestsInterfacePtr requestsIface;
62
Tp::BaseConnectionSimplePresenceInterfacePtr simplePresenceIface;
63
Tp::BaseConnectionContactsInterfacePtr contactsIface;
64
uint newHandle(const QString &identifier);
66
uint ensureHandle(const QString &id);
67
Tp::BaseChannelPtr createTextChannel(uint targetHandleType,
68
uint targetHandle, Tp::DBusError *error);
69
Tp::BaseChannelPtr createCallChannel(uint targetHandleType,
70
uint targetHandle, Tp::DBusError *error);
74
QString placeCall(const QVariantMap &properties);
76
void messageSent(const QString &message, const QVariantMap &info);
77
void callReceived(const QString &callerId);
78
void callEnded(const QString &callerId);
79
void callStateChanged(const QString &callerId, const QString &objectPath, const QString &state);
82
void placeIncomingMessage(const QString &message, const QVariantMap &info);
83
void hangupCall(const QString &callerId);
84
void setCallState(const QString &phoneNumber, const QString &state);
85
void onTextChannelClosed();
86
void onCallChannelClosed();
87
void onCallStateChanged(MockCallChannel *channel, const QString &state);
88
void onMessageRead(const QString &id);
91
void addMMSToService(const QString &path, const QVariantMap &properties, const QString &servicePath);
92
QMap<uint, QString> mHandles;
94
QMap<QString, MockTextChannel*> mTextChannels;
95
QMap<QString, MockCallChannel*> mCallChannels;
96
QMap<QString, QString> mInitialCallStatus;
100
Tp::SimplePresence mSelfPresence;
101
Tp::SimplePresence mRequestedSelfPresence;
103
MockConnectionDBus *mDBus;
104
QStringList mIncomingCalls;