~artmello/messaging-app/messaging-app-snap

« back to all changes in this revision

Viewing changes to src/messagingappdbus.cpp

  • Committer: Tiago Salem Herrmann
  • Date: 2013-07-15 20:33:33 UTC
  • Revision ID: tiago.herrmann@canonical.com-20130715203333-5ei33sqegv7yxmwc
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012-2013 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Ugo Riboni <ugo.riboni@canonical.com>
 
6
 *
 
7
 * This file is part of messaging-app.
 
8
 *
 
9
 * messaging-app 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
 * messaging-app 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 "messagingappdbus.h"
 
23
#include "messagingappadaptor.h"
 
24
 
 
25
// Qt
 
26
#include <QtDBus/QDBusConnection>
 
27
 
 
28
static const char* DBUS_SERVICE = "com.canonical.MessagingApp";
 
29
static const char* DBUS_OBJECT_PATH = "/com/canonical/MessagingApp";
 
30
 
 
31
MessagingAppDBus::MessagingAppDBus(QObject* parent) : QObject(parent)
 
32
{
 
33
}
 
34
 
 
35
MessagingAppDBus::~MessagingAppDBus()
 
36
{
 
37
}
 
38
 
 
39
bool
 
40
MessagingAppDBus::connectToBus()
 
41
{
 
42
    bool ok = QDBusConnection::sessionBus().registerService(DBUS_SERVICE);
 
43
    if (!ok) {
 
44
        return false;
 
45
    }
 
46
    new MessagingAppAdaptor(this);
 
47
    QDBusConnection::sessionBus().registerObject(DBUS_OBJECT_PATH, this);
 
48
 
 
49
    return true;
 
50
}
 
51
 
 
52
void
 
53
MessagingAppDBus::ShowMessages(const QString &number)
 
54
{
 
55
    Q_EMIT request(QString("message://%1").arg(number));
 
56
}
 
57
 
 
58
void MessagingAppDBus::ShowMessage(const QString &messageId)
 
59
{
 
60
    Q_EMIT request(QString("messageId://%1").arg(messageId));
 
61
}
 
62
 
 
63
void MessagingAppDBus::NewMessage()
 
64
{
 
65
    Q_EMIT request(QString("message://"));
 
66
}
 
67
 
 
68
void MessagingAppDBus::SendMessage(const QString &number, const QString &message)
 
69
{
 
70
    Q_EMIT messageSendRequested(number, message);
 
71
}
 
72
 
 
73
void MessagingAppDBus::SendAppMessage(const QString &message)
 
74
{
 
75
    Q_EMIT request(message);
 
76
}