89
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
92
|
14 |
* Description:
|
89
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "hbactivityplugin.h"
|
|
19 |
|
|
20 |
#include <qservicemanager.h>
|
|
21 |
|
|
22 |
QTM_USE_NAMESPACE
|
|
23 |
|
95
|
24 |
HbActivityPlugin::HbActivityPlugin(QObject *parent) : QObject(parent), mActivityClient(0)
|
89
|
25 |
{
|
|
26 |
QServiceManager serviceManager;
|
92
|
27 |
|
89
|
28 |
if (serviceManager.findInterfaces("ActivityService").isEmpty()) {
|
|
29 |
// clean old entries
|
|
30 |
serviceManager.removeService("ActivityService");
|
107
|
31 |
bool servicesAdded = serviceManager.addService(":/afservice.xml");
|
89
|
32 |
if (!servicesAdded) {
|
|
33 |
qWarning("addService for ActivityService returned false, error %d", serviceManager.error());
|
|
34 |
}
|
|
35 |
}
|
|
36 |
|
92
|
37 |
mActivityClient = serviceManager.loadInterface("com.nokia.qt.activities.ActivityClient");
|
89
|
38 |
if (!mActivityClient) {
|
|
39 |
qWarning("Cannot initialize critical com.nokia.qt.activities.ActivityClient service.");
|
|
40 |
}
|
92
|
41 |
|
89
|
42 |
connect(mActivityClient, SIGNAL(activityRequested(QString)), this, SIGNAL(activityRequested(QString)));
|
|
43 |
}
|
|
44 |
|
|
45 |
HbActivityPlugin::~HbActivityPlugin()
|
|
46 |
{
|
|
47 |
delete mActivityClient;
|
|
48 |
}
|
|
49 |
|
|
50 |
bool HbActivityPlugin::addActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
|
|
51 |
{
|
|
52 |
bool retVal(false);
|
92
|
53 |
QMetaObject::invokeMethod(mActivityClient,
|
|
54 |
"addActivity",
|
|
55 |
Q_RETURN_ARG(bool, retVal),
|
|
56 |
Q_ARG(QString, activityId),
|
|
57 |
Q_ARG(QVariant, data),
|
89
|
58 |
Q_ARG(QVariantHash, parameters));
|
|
59 |
return retVal;
|
|
60 |
}
|
|
61 |
|
|
62 |
bool HbActivityPlugin::removeActivity(const QString &activityId)
|
|
63 |
{
|
|
64 |
bool retVal(false);
|
92
|
65 |
QMetaObject::invokeMethod(mActivityClient,
|
|
66 |
"removeActivity",
|
|
67 |
Q_RETURN_ARG(bool, retVal),
|
89
|
68 |
Q_ARG(QString, activityId));
|
|
69 |
return retVal;
|
|
70 |
}
|
|
71 |
|
|
72 |
bool HbActivityPlugin::updateActivity(const QString &activityId, const QVariant &data, const QVariantHash ¶meters)
|
|
73 |
{
|
|
74 |
bool retVal(false);
|
92
|
75 |
QMetaObject::invokeMethod(mActivityClient,
|
|
76 |
"updateActivity",
|
|
77 |
Q_RETURN_ARG(bool, retVal),
|
89
|
78 |
Q_ARG(QString, activityId),
|
|
79 |
Q_ARG(QVariant, data),
|
|
80 |
Q_ARG(QVariantHash, parameters));
|
|
81 |
return retVal;
|
|
82 |
}
|
|
83 |
QList<QVariantHash> HbActivityPlugin::activities()
|
|
84 |
{
|
|
85 |
QList<QVariantHash> data;
|
92
|
86 |
QMetaObject::invokeMethod(mActivityClient,
|
|
87 |
"activities",
|
89
|
88 |
Q_RETURN_ARG(QList<QVariantHash>, data));
|
|
89 |
return data;
|
|
90 |
}
|
|
91 |
|
|
92 |
QVariant HbActivityPlugin::activityData(const QString &activityId)
|
|
93 |
{
|
|
94 |
QVariant data;
|
92
|
95 |
QMetaObject::invokeMethod(mActivityClient,
|
|
96 |
"activityData",
|
89
|
97 |
Q_RETURN_ARG(QVariant, data),
|
|
98 |
Q_ARG(QString, activityId));
|
|
99 |
return data;
|
|
100 |
}
|
|
101 |
|
|
102 |
bool HbActivityPlugin::waitActivity()
|
|
103 |
{
|
|
104 |
bool retVal(false);
|
92
|
105 |
QMetaObject::invokeMethod(mActivityClient,
|
|
106 |
"waitActivity",
|
89
|
107 |
Q_RETURN_ARG(bool, retVal));
|
|
108 |
return retVal;
|
|
109 |
}
|
|
110 |
|
92
|
111 |
QVariantHash HbActivityPlugin::parseCommandLine(const QStringList &commandLineParams)
|
|
112 |
{
|
|
113 |
QVariantHash retVal;
|
|
114 |
QMetaObject::invokeMethod(mActivityClient,
|
|
115 |
"parseCommandLine",
|
|
116 |
Q_RETURN_ARG(QVariantHash, retVal),
|
|
117 |
Q_ARG(QStringList, commandLineParams));
|
|
118 |
return retVal;
|
|
119 |
}
|
|
120 |
|
|
121 |
Q_EXPORT_PLUGIN2(hbactivityplugin, HbActivityPlugin)
|