Merge lp:~diegosarmentero/ubuntu-purchase-service/purchase-client-plugin into lp:ubuntu-purchase-service

Proposed by Diego Sarmentero
Status: Merged
Approved by: dobey
Approved revision: 10
Merged at revision: 3
Proposed branch: lp:~diegosarmentero/ubuntu-purchase-service/purchase-client-plugin
Merge into: lp:ubuntu-purchase-service
Prerequisite: lp:~diegosarmentero/ubuntu-purchase-service/launch-purchase-plugin
Diff against target: 167 lines (+117/-2)
5 files modified
purchaseservice.pro (+4/-2)
service/generate_adaptors.sh (+3/-0)
src/purchaseclient.cpp (+53/-0)
src/purchaseclient.h (+55/-0)
src/purchaseservice_plugin.cpp (+2/-0)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-purchase-service/purchase-client-plugin
Reviewer Review Type Date Requested Status
dobey (community) Approve
Review via email: mp+198156@code.launchpad.net

Commit message

- Add purchase client plugin, to communicate and listen to signals from the purchase dbus service

To post a comment you must log in.
5. By Diego Sarmentero

moving into source folder

6. By Diego Sarmentero

fixing .pro identation

7. By Diego Sarmentero

merge

8. By Diego Sarmentero

merge

9. By Diego Sarmentero

merge

10. By Diego Sarmentero

fixing .pro and merge

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchaseservice.pro'
2--- purchaseservice.pro 2013-12-10 13:51:11 +0000
3+++ purchaseservice.pro 2013-12-10 13:51:11 +0000
4@@ -9,11 +9,13 @@
5 # Input
6 SOURCES += \
7 src/purchaseservice_plugin.cpp \
8- src/ubuntupurchase.cpp
9+ src/ubuntupurchase.cpp \
10+ src/purchaseclient.cpp
11
12 HEADERS += \
13 src/purchaseservice_plugin.h \
14- src/ubuntupurchase.h
15+ src/ubuntupurchase.h \
16+ src/purchaseclient.h
17
18 system("cd service && ./generate_adaptors.sh")
19
20
21=== modified file 'service/generate_adaptors.sh'
22--- service/generate_adaptors.sh 2013-12-10 13:51:11 +0000
23+++ service/generate_adaptors.sh 2013-12-10 13:51:11 +0000
24@@ -1,4 +1,7 @@
25 echo "Generating adaptors from DBus xml definitions:"
26+echo "PurchaseServiceClient..."
27+qdbusxml2cpp -v -c PurchaseServiceClient -p purchase_service_client.h:purchase_service_client.cpp com.canonical.Purchase.xml
28+echo "generated"
29
30 echo "PurchaseServiceAdaptor..."
31 qdbusxml2cpp -c PurchaseServiceAdaptor -a purchase_service_adaptor.h:purchase_service_adaptor.cpp com.canonical.Purchase.xml
32
33=== added file 'src/purchaseclient.cpp'
34--- src/purchaseclient.cpp 1970-01-01 00:00:00 +0000
35+++ src/purchaseclient.cpp 2013-12-10 13:51:11 +0000
36@@ -0,0 +1,53 @@
37+/*
38+ * Copyright 2013 Canonical Ltd.
39+ *
40+ * This library is free software; you can redistribute it and/or
41+ * modify it under the terms of version 3 of the GNU Lesser General Public
42+ * License as published by the Free Software Foundation.
43+ *
44+ * This program is distributed in the hope that it will be useful,
45+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
46+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
47+ * General Public License for more details.
48+ *
49+ * You should have received a copy of the GNU Lesser General Public
50+ * License along with this library; if not, write to the
51+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
52+ * Boston, MA 02110-1301, USA.
53+ */
54+
55+#include "purchaseclient.h"
56+#include <QDebug>
57+
58+namespace UbuntuPurchases {
59+
60+PurchaseClient::PurchaseClient(QQuickItem *parent) :
61+ QQuickItem(parent)
62+{
63+ this->m_client = new PurchaseServiceClient("com.canonical.Purchase", "/", QDBusConnection::sessionBus(), 0);
64+
65+ QObject::connect(this->m_client, &PurchaseServiceClient::failure, this, &PurchaseClient::purchaseFailed);
66+ QObject::connect(this->m_client, &PurchaseServiceClient::success, this, &PurchaseClient::purchaseSucceeded);
67+}
68+
69+PurchaseClient::~PurchaseClient()
70+{
71+ delete this->m_client;
72+}
73+
74+void PurchaseClient::purchaseItem(const QVariantMap id)
75+{
76+ this->m_client->purchase(id);
77+}
78+
79+void PurchaseClient::purchaseFailed(const QString &packageName)
80+{
81+ Q_EMIT this->failed(packageName);
82+}
83+
84+void PurchaseClient::purchaseSucceeded(const QString &packageName)
85+{
86+ Q_EMIT this->succeeded(packageName);
87+}
88+
89+}
90
91=== added file 'src/purchaseclient.h'
92--- src/purchaseclient.h 1970-01-01 00:00:00 +0000
93+++ src/purchaseclient.h 2013-12-10 13:51:11 +0000
94@@ -0,0 +1,55 @@
95+/*
96+ * Copyright 2013 Canonical Ltd.
97+ *
98+ * This library is free software; you can redistribute it and/or
99+ * modify it under the terms of version 3 of the GNU Lesser General Public
100+ * License as published by the Free Software Foundation.
101+ *
102+ * This program is distributed in the hope that it will be useful,
103+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
104+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
105+ * General Public License for more details.
106+ *
107+ * You should have received a copy of the GNU Lesser General Public
108+ * License along with this library; if not, write to the
109+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
110+ * Boston, MA 02110-1301, USA.
111+ */
112+
113+#ifndef PURCHASECLIENT_H
114+#define PURCHASECLIENT_H
115+
116+#include <QQuickItem>
117+#include <QVariant>
118+#include "service/purchase_service_client.h"
119+
120+namespace UbuntuPurchases {
121+
122+class PurchaseClient : public QQuickItem
123+{
124+ Q_OBJECT
125+
126+public:
127+ PurchaseClient(QQuickItem *parent = 0);
128+ ~PurchaseClient();
129+
130+ Q_INVOKABLE void purchaseItem(const QVariantMap id);
131+
132+Q_SIGNALS:
133+ void failed(QString packageName);
134+ void succeeded(QString packageName);
135+
136+private Q_SLOTS:
137+ void purchaseFailed(const QString &packageName);
138+ void purchaseSucceeded(const QString &packageName);
139+
140+private:
141+ PurchaseServiceClient* m_client;
142+
143+};
144+
145+}
146+
147+QML_DECLARE_TYPE(UbuntuPurchases::PurchaseClient)
148+
149+#endif // PURCHASECLIENT_H
150
151=== modified file 'src/purchaseservice_plugin.cpp'
152--- src/purchaseservice_plugin.cpp 2013-12-10 13:51:11 +0000
153+++ src/purchaseservice_plugin.cpp 2013-12-10 13:51:11 +0000
154@@ -18,6 +18,7 @@
155
156 #include "purchaseservice_plugin.h"
157 #include "ubuntupurchase.h"
158+#include "purchaseclient.h"
159
160 #include <qqml.h>
161
162@@ -27,6 +28,7 @@
163 {
164 // @uri Ubuntu.Purchase
165 qmlRegisterType<UbuntuPurchase>(uri, 0, 1, "UbuntuPurchase");
166+ qmlRegisterType<PurchaseClient>(uri, 0, 1, "PurchaseClient");
167 }
168
169

Subscribers

People subscribed via source and target branches