|
1 /* |
|
2 * Copyright (c) 2010 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 * |
|
14 * Description: Example of home screen content publishing client |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <qservicefilter.h> |
|
19 #include <qserviceinterfacedescriptor.h> |
|
20 |
|
21 #include <QMetaObject> |
|
22 #include <QMetaMethod> |
|
23 |
|
24 #include "contentpublishclient.h" |
|
25 |
|
26 /*! |
|
27 \ingroup group_content_publish_client |
|
28 \class ContentPublishClient |
|
29 \brief Example implementation for home screen content publish client. |
|
30 |
|
31 ContentPublishClient is derived from QObject and implements |
|
32 needed functions for the home screen content publish client. |
|
33 */ |
|
34 |
|
35 /*! |
|
36 Constructor. |
|
37 */ |
|
38 ContentPublishClient::ContentPublishClient(QServiceManager &manager, QObject *parent) |
|
39 : QObject(parent), |
|
40 mManager(&manager) |
|
41 { |
|
42 } |
|
43 |
|
44 /*! |
|
45 Destructor |
|
46 */ |
|
47 ContentPublishClient::~ContentPublishClient() |
|
48 { |
|
49 } |
|
50 |
|
51 /*! |
|
52 Loads service interface |
|
53 */ |
|
54 bool ContentPublishClient::load() |
|
55 { |
|
56 QServiceFilter filter("com.nokia.symbian.IHomeScreenClient"); |
|
57 filter.setServiceName("hshomescreenclientplugin"); |
|
58 QList<QServiceInterfaceDescriptor> interfaces = mManager->findInterfaces(filter); |
|
59 |
|
60 if(interfaces.isEmpty()) { |
|
61 QServiceManager::Error error = mManager->error(); |
|
62 return false; |
|
63 } |
|
64 qDebug() << interfaces.first().interfaceName() |
|
65 << interfaces.first().serviceName() |
|
66 << interfaces.first().isValid(); |
|
67 |
|
68 mService = mManager->loadInterface(interfaces.first()); |
|
69 |
|
70 return (mService); |
|
71 } |
|
72 |
|
73 /*! |
|
74 Adds widget utilizing service interface and invoke call |
|
75 */ |
|
76 void ContentPublishClient::addWidget() |
|
77 { |
|
78 QByteArray signature = QMetaObject::normalizedSignature("addWidget(QString,QVariantHash)"); |
|
79 int methodIndex = mService->metaObject()->indexOfMethod(signature); |
|
80 QMetaMethod method = mService->metaObject()->method(methodIndex); |
|
81 bool retVal(false); |
|
82 |
|
83 QString widget = "hsclockwidgetplugin"; |
|
84 |
|
85 bool ret = method.invoke( mService, |
|
86 Qt::DirectConnection, |
|
87 Q_RETURN_ARG(bool, retVal), |
|
88 Q_ARG(QString,widget), |
|
89 Q_ARG(QVariantHash,QVariantHash())); |
|
90 |
|
91 if(!ret){ |
|
92 qDebug()<< "method invoke failed!"; |
|
93 } |
|
94 if(!retVal){ |
|
95 qDebug() << "addWidget() failed!!"; |
|
96 } |
|
97 } |