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 * |
|
14 * Description: Content publishing implementation |
|
15 * |
|
16 */ |
|
17 #include <QDebug> |
|
18 #include "hshomescreenclient.h" |
|
19 #include "hsipcchannelclient.h" |
|
20 |
|
21 const char SERVERNAME[] = "hs_content_publish"; |
|
22 |
|
23 HsContentPublish::HsContentPublish(QObject *parent) |
|
24 :QObject(parent),mChannel(new HsIpcChannelClient()) |
|
25 { |
|
26 mChannel->setParent(this); |
|
27 |
|
28 } |
|
29 HsContentPublish::~HsContentPublish() |
|
30 { |
|
31 |
|
32 } |
|
33 |
|
34 bool HsContentPublish::open() |
|
35 { |
|
36 if(!mChannel->isConnected() && !mChannel->waitForOpenConnection(SERVERNAME)){ |
|
37 return false; |
|
38 } |
|
39 return true; |
|
40 } |
|
41 |
|
42 bool HsContentPublish::close() |
|
43 { |
|
44 if( mChannel->isConnected() && !mChannel->waitForCloseConnection()){ |
|
45 qDebug()<< "HsContentPublish connection failed"; |
|
46 return false; |
|
47 } |
|
48 return true; |
|
49 } |
|
50 |
|
51 bool HsContentPublish::addWidgetToHomescreen( |
|
52 const QString &uri, |
|
53 const QVariantMap &preferences) |
|
54 { |
|
55 if(!open()){ |
|
56 return false; |
|
57 } |
|
58 // format message |
|
59 QVariantMap message; |
|
60 message.insert("messageType",QString("addWidget")); |
|
61 message.insert("uri",uri); |
|
62 message.insert("preferences",preferences); |
|
63 if(!mChannel->waitForSendMessage(message)){ |
|
64 qDebug()<< "HsContentPublish sendMessageWait failed"; |
|
65 return false; |
|
66 } |
|
67 // get reply |
|
68 QVariantMap reply; |
|
69 if(!mChannel->waitForReadMessage(reply)){ |
|
70 qDebug()<< "HsContentPublish reply wait failed"; |
|
71 return false; |
|
72 } |
|
73 QString replyResult = reply.value("result").toString(); |
|
74 if( replyResult != QLatin1String("true")){ |
|
75 qDebug()<< "HsContentPublish reply result: " << replyResult; |
|
76 return false; |
|
77 } |
|
78 |
|
79 return true; |
|
80 } |
|
81 |
|