Skip to content

Commit

Permalink
Merge pull request #14 from special/master
Browse files Browse the repository at this point in the history
Replace notification context properties with a DBus service
  • Loading branch information
special committed Jul 23, 2013
2 parents fca32af + e189626 commit b9b7057
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 211 deletions.
1 change: 0 additions & 1 deletion rpm/commhistory-daemon.spec
Expand Up @@ -12,7 +12,6 @@ BuildRequires: pkgconfig(Qt5Contacts)
BuildRequires: pkgconfig(Qt5Versit)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(commhistory-qt5)
BuildRequires: pkgconfig(contextkit-statefs)
BuildRequires: pkgconfig(TelepathyQt5)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(mlocale5)
Expand Down
15 changes: 14 additions & 1 deletion src/CommHistoryIf.xml
@@ -1,9 +1,22 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="com.nokia.CommHistoryIf">
<interface name="org.nemomobile.CommHistoryIf">
<method name="activateNotification">
<arg name="groupId" type="i" direction="in"/>
<arg name="remoteActionString" type="s" direction="in"/>
</method>
<method name="setInboxObserved">
<arg name="observed" type="b"/>
</method>
<method name="setInboxObserved">
<arg name="observed" type="b"/>
<arg name="filterAccount" type="s"/>
</method>
<method name="setObservedConversations">
<arg name="conversations" type="av"/>
</method>
<method name="setCallHistoryObserved">
<arg name="observed" type="b"/>
</method>
</interface>
</node>
71 changes: 25 additions & 46 deletions src/commhistoryifadaptor.cpp
@@ -1,30 +1,8 @@
/******************************************************************************
**
** This file is part of commhistory-daemon.
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Reto Zingg <reto.zingg@nokia.com>
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the GNU Lesser General Public License version 2.1 as
** published by the Free Software Foundation.
**
** This library is distributed in the hope that it will be useful, but
** WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
** License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this library; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
******************************************************************************/

/*
* This file was generated by qdbusxml2cpp version 0.7
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -c CommHistoryIfAdaptor -a commhistoryifadaptor CommHistoryIf.xml
*
* qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
Expand All @@ -46,9 +24,6 @@
CommHistoryIfAdaptor::CommHistoryIfAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
if(!parent){
qCritical() << "CommHistoryIfAdaptor - parent is null";
}
// constructor
setAutoRelaySignals(true);
}
Expand All @@ -60,27 +35,31 @@ CommHistoryIfAdaptor::~CommHistoryIfAdaptor()

void CommHistoryIfAdaptor::activateNotification(int groupId, const QString &remoteActionString)
{
// handle method call com.nokia.CommHistoryIf.activateNotification
QMetaObject::invokeMethod(parent(),
"activateNotification",
Q_ARG(int, groupId),
Q_ARG(QString, remoteActionString));
// handle method call org.nemomobile.CommHistoryIf.activateNotification
QMetaObject::invokeMethod(parent(), "activateNotification", Q_ARG(int, groupId), Q_ARG(QString, remoteActionString));
}

void CommHistoryIfAdaptor::setCallHistoryObserved(bool observed)
{
// handle method call org.nemomobile.CommHistoryIf.setCallHistoryObserved
QMetaObject::invokeMethod(parent(), "setCallHistoryObserved", Q_ARG(bool, observed));
}

void CommHistoryIfAdaptor::setInboxObserved(bool observed, const QString &filterAccount)
{
// handle method call org.nemomobile.CommHistoryIf.setInboxObserved
QMetaObject::invokeMethod(parent(), "setInboxObserved", Q_ARG(bool, observed), Q_ARG(QString, filterAccount));
}

void CommHistoryIfAdaptor::setInboxObserved(bool observed)
{
// handle method call org.nemomobile.CommHistoryIf.setInboxObserved
QMetaObject::invokeMethod(parent(), "setInboxObserved", Q_ARG(bool, observed));
}

void CommHistoryIfAdaptor::activateAuthorization(const QString& contactId,
const QString& accountPath,
const QString& filename,
const QString& message,
const QString& transactionId,
const QString& accountUniqueIdentifier)
void CommHistoryIfAdaptor::setObservedConversations(const QVariantList &conversations)
{
QMetaObject::invokeMethod(parent(),
"activateAuthorization",
Q_ARG(QString, contactId),
Q_ARG(QString, accountPath),
Q_ARG(QString, filename),
Q_ARG(QString, message),
Q_ARG(QString, transactionId),
Q_ARG(QString, accountUniqueIdentifier));
// handle method call org.nemomobile.CommHistoryIf.setObservedConversations
QMetaObject::invokeMethod(parent(), "setObservedConversations", Q_ARG(QVariantList, conversations));
}

72 changes: 36 additions & 36 deletions src/commhistoryifadaptor.h
@@ -1,68 +1,68 @@
/******************************************************************************
**
** This file is part of commhistory-daemon.
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Reto Zingg <reto.zingg@nokia.com>
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the GNU Lesser General Public License version 2.1 as
** published by the Free Software Foundation.
**
** This library is distributed in the hope that it will be useful, but
** WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
** or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
** License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this library; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
******************************************************************************/

/*
* This file was generated by qdbusxml2cpp version 0.7
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -c CommHistoryIfAdaptor -a commhistoryifadaptor CommHistoryIf.xml
*
* qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments before re-generating it.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/

#ifndef COMMHISTORYIFADAPTOR_H_1272020919
#define COMMHISTORYIFADAPTOR_H_1272020919
#ifndef COMMHISTORYIFADAPTOR_H_1374205692
#define COMMHISTORYIFADAPTOR_H_1374205692

#include <QtCore/QObject>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

/*
* Adaptor class for interface com.nokia.CommHistoryIf
* Adaptor class for interface org.nemomobile.CommHistoryIf
*/
class CommHistoryIfAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.nokia.CommHistoryIf")

Q_CLASSINFO("D-Bus Interface", "org.nemomobile.CommHistoryIf")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"org.nemomobile.CommHistoryIf\">\n"
" <method name=\"activateNotification\">\n"
" <arg direction=\"in\" type=\"i\" name=\"groupId\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"remoteActionString\"/>\n"
" </method>\n"
" <method name=\"setInboxObserved\">\n"
" <arg type=\"b\" name=\"observed\"/>\n"
" </method>\n"
" <method name=\"setInboxObserved\">\n"
" <arg type=\"b\" name=\"observed\"/>\n"
" <arg type=\"s\" name=\"filterAccount\"/>\n"
" </method>\n"
" <method name=\"setObservedConversations\">\n"
" <arg type=\"av\" name=\"conversations\"/>\n"
" </method>\n"
" <method name=\"setCallHistoryObserved\">\n"
" <arg type=\"b\" name=\"observed\"/>\n"
" </method>\n"
" </interface>\n"
"")
public:
CommHistoryIfAdaptor(QObject *parent);
virtual ~CommHistoryIfAdaptor();

public: // PROPERTIES
public Q_SLOTS: // METHODS
void activateNotification(int groupId, const QString &remoteActionString);
void activateAuthorization(const QString& contactId,
const QString& accountPath,
const QString& filename,
const QString& message,
const QString& transactionId,
const QString& accountUniqueIdentifier);
void setCallHistoryObserved(bool observed);
void setInboxObserved(bool observed, const QString &filterAccount);
void setInboxObserved(bool observed);
void setObservedConversations(const QVariantList &conversations);
Q_SIGNALS: // SIGNALS
};

#endif
50 changes: 49 additions & 1 deletion src/commhistoryservice.cpp
Expand Up @@ -21,12 +21,23 @@
******************************************************************************/

#include <QtDBus>
#include <QCoreApplication>
#include "commhistoryservice.h"
#include "constants.h"

CommHistoryService *CommHistoryService::instance()
{
static CommHistoryService *obj = 0;
if (!obj)
obj = new CommHistoryService(qApp);
return obj;
}

CommHistoryService::CommHistoryService( QObject* parent )
: QObject(parent),
m_IsRegistered(false)
m_IsRegistered(false),
m_callHistoryObserved(false),
m_inboxObserved(false)
{
if (!QDBusConnection::sessionBus().isConnected()) {
qCritical() << "ERROR: No DBus session bus found!";
Expand Down Expand Up @@ -64,6 +75,43 @@ void CommHistoryService::activateAuthorization(const QString& contactId,
transactionId, accountUniqueIdentifier);
}

void CommHistoryService::setCallHistoryObserved(bool observed)
{
if (observed != m_callHistoryObserved) {
m_callHistoryObserved = observed;
emit callHistoryObservedChanged(observed);
}
}

void CommHistoryService::setInboxObserved(bool observed, const QString &filterAccount)
{
if (observed != m_inboxObserved || filterAccount != m_inboxFilterAccount) {
m_inboxObserved = observed;
m_inboxFilterAccount = filterAccount;
emit inboxObservedChanged(observed, filterAccount);
}
}

void CommHistoryService::setObservedConversations(const QVariantList &arg)
{
QVariantList conversations;
foreach (const QVariant &v1, arg) {
const QDBusArgument arg2 = v1.value<QDBusArgument>();
arg2.beginArray();
QVariantList values;
while (!arg2.atEnd()) {
QVariant v2;
arg2 >> v2;
values.append(v2);
}
arg2.endArray();
conversations << QVariant(values);
}

m_observedConversations = conversations;
emit observedConversationsChanged(conversations);
}

bool CommHistoryService::isRegistered()
{
return m_IsRegistered;
Expand Down
25 changes: 22 additions & 3 deletions src/commhistoryservice.h
Expand Up @@ -24,23 +24,33 @@
#define COMMHISTORYSERVICE_H

#include <QObject>
#include <QVariantList>

class CommHistoryService : public QObject
{
Q_OBJECT

public:
CommHistoryService( QObject* parent = 0 );
~CommHistoryService();

static CommHistoryService *instance();

bool isRegistered();

bool callHistoryObserved() const { return m_callHistoryObserved; }
bool inboxObserved() const { return m_inboxObserved; }
QString inboxFilterAccount() const { return m_inboxFilterAccount; }
QVariantList observedConversations() const { return m_observedConversations; }

public Q_SLOTS:
/*! \brief emits signal that authorisation dialog should be shown for contact */
void activateAuthorization(const QString& contactId, const QString& accountPath,
const QString& filename, const QString& message,
const QString& transactionId,
const QString& accountUniqueIdentifier);

bool isRegistered();
void setCallHistoryObserved(bool observed);
void setInboxObserved(bool observed, const QString &filterAccount = QString());
void setObservedConversations(const QVariantList &conversations);

Q_SIGNALS:
void showAuthorizationDialog(const QString& contactId,
Expand All @@ -49,9 +59,18 @@ public Q_SLOTS:
const QString& message,
const QString& transactionId,
const QString& accountUniqueIdentifier);
void callHistoryObservedChanged(bool observed);
void inboxObservedChanged(bool observed, const QString &filterAccount);
void observedConversationsChanged(const QVariantList &conversations);

private:
bool m_IsRegistered;
bool m_callHistoryObserved;
bool m_inboxObserved;
QString m_inboxFilterAccount;
QVariantList m_observedConversations;

CommHistoryService( QObject* parent = 0 );
};

#endif // COMMHISTORYSERVICE_H
11 changes: 3 additions & 8 deletions src/constants.h
Expand Up @@ -27,17 +27,12 @@

namespace RTComLogger {

#define OBSERVED_CONVERSATION_KEY QLatin1String("Messaging.ObservedConversation")
#define OBSERVED_INBOX_KEY QLatin1String("Messaging.ObservedInbox")
#define FILTERED_INBOX_KEY QLatin1String("Messaging.FilteredInbox")
#define CALL_HISTORY_KEY QLatin1String("CallHistory.Inbox")

// Used to generate duiremoteaction strings
#define OBJECT_PATH QLatin1String("/")

#define COMM_HISTORY_SERVICE_NAME QLatin1String("com.nokia.CommHistory")
#define COMM_HISTORY_OBJECT_PATH QLatin1String("/com/nokia/CommHistory")
#define COMM_HISTORY_INTERFACE QLatin1String("com.nokia.CommHistoryIf")
#define COMM_HISTORY_SERVICE_NAME QLatin1String("org.nemomobile.CommHistory")
#define COMM_HISTORY_OBJECT_PATH QLatin1String("/org/nemomobile/CommHistory")
#define COMM_HISTORY_INTERFACE QLatin1String("org.nemomobile.CommHistoryIf")

#define ACCOUNT_PRESENCE_SERVICE_NAME QLatin1String("org.nemomobile.AccountPresence")
#define ACCOUNT_PRESENCE_OBJECT_PATH QLatin1String("/org/nemomobile/AccountPresence")
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -147,7 +147,7 @@ int main(int argc, char **argv)

qDebug() << "Translation catalogs loaded";

CommHistoryService *chService = new CommHistoryService(&app);
CommHistoryService *chService = CommHistoryService::instance();
if (!chService->isRegistered()) {
qCritical() << "CommHistoryService registration failed (already running or DBus not found), exiting";
_exit(1);
Expand Down

0 comments on commit b9b7057

Please sign in to comment.