~phablet-team/telephony-service/trunk

« back to all changes in this revision

Viewing changes to handler/tests/mock/mockconnectiondbus.cpp

  • Committer: Michael Terry
  • Date: 2014-01-29 15:16:16 UTC
  • mfrom: (766 trunk)
  • mto: This revision was merged to the branch mainline in revision 769.
  • Revision ID: michael.terry@canonical.com-20140129151616-63986zad796m4gtl
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
 
6
 *
 
7
 * This file is part of history-service.
 
8
 *
 
9
 * history-service is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; version 3.
 
12
 *
 
13
 * history-service is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#include "connection.h"
 
23
#include "mockconnectiondbus.h"
 
24
#include "mockconnectionadaptor.h"
 
25
 
 
26
Q_DECLARE_METATYPE(QList< QVariantMap >)
 
27
 
 
28
MockConnectionDBus::MockConnectionDBus(MockConnection *parent) :
 
29
    QObject(parent), mAdaptor(0), mConnection(parent)
 
30
{
 
31
 
 
32
    connect(mConnection,
 
33
            SIGNAL(messageSent(QString,QVariantMap)),
 
34
            SIGNAL(MessageSent(QString,QVariantMap)));
 
35
    connect(mConnection,
 
36
            SIGNAL(callReceived(QString)),
 
37
            SIGNAL(CallReceived(QString)));
 
38
    connect(mConnection,
 
39
            SIGNAL(callEnded(QString)),
 
40
            SIGNAL(CallEnded(QString)));
 
41
    connect(mConnection,
 
42
            SIGNAL(callStateChanged(QString,QString,QString)),
 
43
            SIGNAL(CallStateChanged(QString,QString,QString)));
 
44
    qDBusRegisterMetaType<QList<QVariantMap> >();
 
45
    connectToBus();
 
46
}
 
47
 
 
48
bool MockConnectionDBus::connectToBus()
 
49
{
 
50
    bool ok = QDBusConnection::sessionBus().registerService("com.canonical.MockConnection");
 
51
    if (!ok) {
 
52
        return false;
 
53
    }
 
54
 
 
55
    if (!mAdaptor) {
 
56
        mAdaptor = new MockConnectionAdaptor(this);
 
57
    }
 
58
 
 
59
    return QDBusConnection::sessionBus().registerObject("/com/canonical/MockConnection", this);
 
60
}
 
61
 
 
62
void MockConnectionDBus::PlaceIncomingMessage(const QString &message, const QVariantMap &properties)
 
63
{
 
64
    mConnection->placeIncomingMessage(message, properties);
 
65
}
 
66
 
 
67
void MockConnectionDBus::PlaceCall(const QVariantMap &properties)
 
68
{
 
69
    mConnection->placeCall(properties);
 
70
}
 
71
 
 
72
void MockConnectionDBus::HangupCall(const QString &callerId)
 
73
{
 
74
    mConnection->hangupCall(callerId);
 
75
}
 
76
 
 
77
void MockConnectionDBus::SetCallState(const QString &phoneNumber, const QString &state)
 
78
{
 
79
    mConnection->setCallState(phoneNumber, state);
 
80
}