Merge lp:~robert-ancell/snapd-glib/qt into lp:~snapd-glib-team/snapd-glib/trunk

Proposed by Robert Ancell on 2016-11-08
Status: Merged
Merged at revision: 181
Proposed branch: lp:~robert-ancell/snapd-glib/qt
Merge into: lp:~snapd-glib-team/snapd-glib/trunk
Diff against target: 2910 lines (+2668/-1)
42 files modified
.bzrignore (+4/-0)
Makefile.am (+1/-1)
configure.ac (+47/-0)
snapd-qt/Makefile.am (+52/-0)
snapd-qt/Snapd/App (+1/-0)
snapd-qt/Snapd/AuthData (+1/-0)
snapd-qt/Snapd/Client (+1/-0)
snapd-qt/Snapd/Connection (+1/-0)
snapd-qt/Snapd/Icon (+1/-0)
snapd-qt/Snapd/Price (+1/-0)
snapd-qt/Snapd/Request (+1/-0)
snapd-qt/Snapd/Snap (+1/-0)
snapd-qt/Snapd/SystemInformation (+1/-0)
snapd-qt/Snapd/Task (+1/-0)
snapd-qt/Snapd/WrappedObject (+1/-0)
snapd-qt/Snapd/app.h (+28/-0)
snapd-qt/Snapd/auth-data.h (+32/-0)
snapd-qt/Snapd/client.h (+358/-0)
snapd-qt/Snapd/connection.h (+30/-0)
snapd-qt/Snapd/icon.h (+30/-0)
snapd-qt/Snapd/price.h (+30/-0)
snapd-qt/Snapd/request.h (+76/-0)
snapd-qt/Snapd/snap.h (+95/-0)
snapd-qt/Snapd/system-information.h (+34/-0)
snapd-qt/Snapd/task.h (+45/-0)
snapd-qt/Snapd/wrapped-object.h (+33/-0)
snapd-qt/SnapdConfig.cmake.in (+5/-0)
snapd-qt/SnapdConfigVersion.cmake.in (+10/-0)
snapd-qt/app.cpp (+19/-0)
snapd-qt/auth-data.cpp (+40/-0)
snapd-qt/client.cpp (+1066/-0)
snapd-qt/connection.cpp (+24/-0)
snapd-qt/icon.cpp (+27/-0)
snapd-qt/price.cpp (+24/-0)
snapd-qt/qml-plugin.cpp (+41/-0)
snapd-qt/qml-plugin.h (+24/-0)
snapd-qt/qmldir (+2/-0)
snapd-qt/request.cpp (+176/-0)
snapd-qt/snap.cpp (+188/-0)
snapd-qt/snapd-qt.pc.in (+11/-0)
snapd-qt/system-information.cpp (+34/-0)
snapd-qt/task.cpp (+71/-0)
To merge this branch: bzr merge lp:~robert-ancell/snapd-glib/qt
Reviewer Review Type Date Requested Status
Alexis Lopez Zubieta (community) Needs Fixing on 2017-01-12
Rodney Dawes (community) 2016-11-08 Abstain on 2016-12-22
Ted Gould 2016-11-08 Pending
Michael Zanetti 2016-11-08 Pending
snapd-glib development team 2016-11-08 Pending
Review via email: mp+310247@code.launchpad.net

Commit Message

Add Qt/QML bindings

To post a comment you must log in.
Robert Ancell (robert-ancell) wrote :

An example showing how to use this code with QML:

import QtQuick 2.0
import Ubuntu.Components 1.3
import Snapd 1.0

MainView {
    SnapdClient {
        id: snapdClient
    }
    Page {
        id: page
        property var findRequest

        TextField {
            iconName: "input-search"
            placeholderText: "Search..."
            onTextChanged: {
                // Ensure we are connected
                var connectRequest = snapdClient.connect ()
                connectRequest.runSync ()

                // Test code
                var infoRequest = snapdClient.getSystemInformation ()
                infoRequest.runSync ()
                var info = infoRequest.systemInformation
                console.log (info.osId + " " + info.osVersion + " " + info.series + " " + info.version)

                var listRequest = snapdClient.list ()
                listRequest.runSync ()
                console.log ("Installed:")
                for (var i = 0; i < listRequest.snapCount; i++) {
                    var snap = listRequest.snap (i)
                    console.log (snap.name, snap.installDate)
                }

                // Cancel existing find
                if (page.findRequest != undefined) {
                    console.log ("CANCEL " + page.findRequest)
                    page.findRequest.cancel ()
                }
                page.findRequest = snapdClient.find (SnapdClient.None, text)
                console.log ("FIND '" + text + "' " + page.findRequest)

                function find_complete ()
                {
                    console.log ("COMPLETE " + page.findRequest)
                    if (page.findRequest.error != SnapdRequest.NoError) {
                        console.log (page.findRequest.errorString)
                        return
                    }

                    console.log (page.findRequest.snapCount + " RESULTS")
                    for (var i = 0; i < page.findRequest.snapCount; i++) {
                        var snap = page.findRequest.snap (i)
                        console.log (snap.name + " " + snap.version)
                    }
                }
                page.findRequest.complete.connect (find_complete)
                page.findRequest.runAsync ()
                console.log ("Waiting...")
            }
        }
        Flickable {
            ListView {
            }
        }
    }
}

Robert Ancell (robert-ancell) wrote :

It was discussed about making this code more QML friendly, which I think is mostly about making models for the data so you can more easily connect to a display?

I think this is best achieved by making a new class "SnapdStore" that wraps the details of the requests. This can be done for all the bindings and added at a later date.

Robert Ancell (robert-ancell) wrote :

I've added a bunch of people who might be able to review this and tell me if it is correct Qt/QML or not... If you know someone else who would be worth looking over it please add them.

Robert Ancell (robert-ancell) wrote :

The bit I think came out worst is the enums, though I can't work out if this it can actually be done better with the current state of C++/Qt.

Rodney Dawes (dobey) wrote :

With a quick skim through, the basic idea looks OK to me. However, it's been decided that the store app on the phone will be a webview of the snapweb store interface, so I'm not sure if any of this is useful there any more. I'm also not working on that, so I'll set my review to abstain.

review: Abstain
Alexis Lopez Zubieta (azubieta90) wrote :

QSnapdClient::buy is not implemented.

review: Needs Fixing
lp:~robert-ancell/snapd-glib/qt updated on 2017-01-24
189. By Robert Ancell on 2017-01-16

Merge with trunk

190. By Robert Ancell on 2017-01-16

Implement QSnapdClient::buy

191. By Robert Ancell on 2017-01-24

Merge with trunk

Robert Ancell (robert-ancell) wrote :

I'm going to take the feedback as close enough to a positive review and land it now :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2016-09-01 10:55:57 +0000
3+++ .bzrignore 2017-01-24 04:26:53 +0000
4@@ -46,3 +46,7 @@
5 snapd-login-service/snapd-login-service
6 snapd-login-service/io.snapcraft.SnapdLoginService.policy
7 snapd-login-service/io.snapcraft.SnapdLoginService.service
8+snapd-qt/SnapdConfig.cmake
9+snapd-qt/SnapdConfigVersion.cmake
10+snapd-qt/snapd-qt.pc
11+snapd-qt/*_moc.cpp
12
13=== modified file 'Makefile.am'
14--- Makefile.am 2016-09-01 10:55:57 +0000
15+++ Makefile.am 2017-01-24 04:26:53 +0000
16@@ -1,3 +1,3 @@
17-SUBDIRS = snapd-glib snapd-login-service po doc
18+SUBDIRS = snapd-glib snapd-login-service snapd-qt po doc
19
20 EXTRA_DIST = COPYING.LGPL2 COPYING.LGPL3
21
22=== modified file 'configure.ac'
23--- configure.ac 2017-01-13 01:10:50 +0000
24+++ configure.ac 2017-01-24 04:26:53 +0000
25@@ -12,6 +12,7 @@
26 AM_SILENT_RULES([yes])
27 AM_PATH_GLIB_2_0
28 AM_PROG_CC_C_O
29+AC_PROG_CXX
30
31 WARN_CFLAGS="-Wall"
32 AC_SUBST(WARN_CFLAGS)
33@@ -27,6 +28,47 @@
34 PKG_CHECK_MODULES(SNAPD, [gobject-2.0 gio-2.0 gio-unix-2.0 libsoup-2.4 json-glib-1.0])
35 PKG_CHECK_MODULES(SNAPD_LOGIN_SERVICE, [gio-2.0 gio-unix-2.0 polkit-gobject-1])
36
37+dnl === snapd-qt ==============================================================
38+
39+AC_ARG_ENABLE(snapd-qt,
40+ AS_HELP_STRING([--enable-snapd-qt],[Enable snapd-qt [[default=auto]]]),
41+ [enable_snapd_qt=$enableval],
42+ [enable_snapd_qt="auto"])
43+compile_snapd_qt=no
44+if test x"$enable_snapd_qt" != "xno"; then
45+ PKG_CHECK_MODULES(SNAPD_QT, [Qt5Core],
46+ [compile_snapd_qt=yes
47+ AC_CHECK_TOOLS(MOC5, [moc])
48+ if test x"$(readlink $(which $MOC5))" = xqtchooser; then
49+ MOC5="$MOC5 --qt=qt5"
50+ fi
51+ ],
52+ [if test "x$enable_snapd_qt" != xauto; then
53+ AC_MSG_FAILURE(
54+ [--enable-snapd-qt was given, but test for Qt5 failed])
55+ fi
56+ ])
57+fi
58+AM_CONDITIONAL(COMPILE_SNAPD_QT, test x"$compile_snapd_qt" != "xno")
59+
60+AC_ARG_ENABLE(qml-module,
61+ AS_HELP_STRING([--enable-qml-module],[Enable QML module [[default=auto]]]),
62+ [enable_qml_module=$enableval],
63+ [enable_qml_module="auto"])
64+compile_qml_module=no
65+if test x"$enable_qml_module" != "xno"; then
66+ PKG_CHECK_MODULES(QML_MODULE, [
67+ Qt5Qml
68+ ],
69+ [compile_qml_module=yes],
70+ [if test "x$enable_qml_module" != xauto; then
71+ AC_MSG_FAILURE(
72+ [--enable-qml-module was given, but test for QML failed])
73+ fi
74+ ])
75+fi
76+AM_CONDITIONAL(COMPILE_QML_MODULE, test x"$compile_qml_module" != "xno")
77+
78 dnl === Translations ==========================================================
79
80 AC_PROG_INTLTOOL()
81@@ -55,6 +97,9 @@
82 po/Makefile.in
83 snapd-glib/Makefile
84 snapd-glib/snapd-glib.pc
85+ snapd-qt/Makefile
86+ snapd-qt/SnapdConfigVersion.cmake
87+ snapd-qt/snapd-qt.pc
88 snapd-login-service/Makefile
89 ])
90
91@@ -73,4 +118,6 @@
92 echo " • API reference: ${enable_gtk_doc}"
93 echo " • GObject introspection: ${enable_introspection}"
94 echo " • Vala bindings: ${enable_vala}"
95+echo " • snapd-qt: ${compile_snapd_qt}"
96+echo " • QML module: ${compile_qml_module}"
97 echo ""
98
99=== added directory 'snapd-qt'
100=== added file 'snapd-qt/Makefile.am'
101--- snapd-qt/Makefile.am 1970-01-01 00:00:00 +0000
102+++ snapd-qt/Makefile.am 2017-01-24 04:26:53 +0000
103@@ -0,0 +1,52 @@
104+pkgconfig_DATA = snapd-qt.pc
105+pkgconfigdir = $(libdir)/pkgconfig
106+
107+source_cpp = app.cpp auth-data.cpp client.cpp connection.cpp icon.cpp price.cpp request.cpp snap.cpp system-information.cpp task.cpp
108+source_h = Snapd/App Snapd/app.h \
109+ Snapd/AuthData Snapd/auth-data.h \
110+ Snapd/Client Snapd/client.h \
111+ Snapd/Connection Snapd/connection.h \
112+ Snapd/Icon Snapd/icon.h \
113+ Snapd/Price Snapd/price.h \
114+ Snapd/Request Snapd/request.h \
115+ Snapd/Snap Snapd/snap.h \
116+ Snapd/SystemInformation Snapd/system-information.h \
117+ Snapd/Task Snapd/task.h \
118+ Snapd/WrappedObject Snapd/wrapped-object.h
119+source_moc = $(source_cpp:.cpp=_moc.cpp) wrapped-object_moc.cpp
120+
121+%_moc.cpp: Snapd/%.h
122+ $(AM_V_GEN) moc --qt=qt5 $< -o $@
123+
124+libsnapd_qt_la_CPPFLAGS = $(SNAPD_QT_CFLAGS) $(SNAPD_CFLAGS) $(WARN_CFLAGS)
125+libsnapd_qt_la_LIBADD = $(top_srcdir)/snapd-glib/libsnapd-glib.la $(SNAPD_QT_LIBS)
126+libsnapd_qt_la_SOURCES = $(source_cpp) $(source_moc) $(source_h)
127+
128+snapdincludedir = $(includedir)/snapd-qt/Snapd
129+
130+cmakedir = $(libdir)/cmake/Snapd
131+cmake_in_files = SnapdConfig.cmake.in SnapdConfigVersion.cmake.in
132+SnapdConfig.cmake: SnapdConfig.cmake.in Makefile
133+ @sed -e "s|\@libdir\@|$(libdir)|" -e "s|\@includedir\@|$(includedir)|" $< > $@
134+
135+if COMPILE_QML_MODULE
136+qmlmodule_DATA = qmldir
137+qmlmoduledir = $(libdir)/qt5/qml/Snapd
138+qmlmodule_LTLIBRARIES = libSnapd.la
139+libSnapd_la_SOURCES = qml-plugin.cpp qml-plugin.h qml-plugin_moc.cpp
140+libSnapd_la_CXXFLAGS = $(WARN_CXXFLAGS) -fPIC $(QML_MODULE_CFLAGS)
141+libSnapd_la_LIBADD = $(QML_MODULE_LIBS) -lsnapd-qt
142+libSnapd_la_LDFLAGS = -rpath $(qmlmoduledir) -module -avoid-version -no-undefined
143+qml-plugin_moc.cpp: qml-plugin.h
144+ $(AM_V_GEN) moc --qt=qt5 $< -o $@
145+endif
146+
147+EXTRA_DIST = $(cmake_in_files)
148+CLEANFILES = $(source_moc)
149+DISTCLEANFILES = SnapdConfig.cmake
150+
151+#if COMPILE_SNAPD_QT
152+lib_LTLIBRARIES = libsnapd-qt.la
153+snapdinclude_DATA = $(source_h)
154+cmake_DATA = $(cmake_in_files:.cmake.in=.cmake)
155+#endif
156
157=== added directory 'snapd-qt/Snapd'
158=== added file 'snapd-qt/Snapd/App'
159--- snapd-qt/Snapd/App 1970-01-01 00:00:00 +0000
160+++ snapd-qt/Snapd/App 2017-01-24 04:26:53 +0000
161@@ -0,0 +1,1 @@
162+#include <Snapd/app.h>
163
164=== added file 'snapd-qt/Snapd/AuthData'
165--- snapd-qt/Snapd/AuthData 1970-01-01 00:00:00 +0000
166+++ snapd-qt/Snapd/AuthData 2017-01-24 04:26:53 +0000
167@@ -0,0 +1,1 @@
168+#include <Snapd/auth-data.h>
169
170=== added file 'snapd-qt/Snapd/Client'
171--- snapd-qt/Snapd/Client 1970-01-01 00:00:00 +0000
172+++ snapd-qt/Snapd/Client 2017-01-24 04:26:53 +0000
173@@ -0,0 +1,1 @@
174+#include <Snapd/client.h>
175
176=== added file 'snapd-qt/Snapd/Connection'
177--- snapd-qt/Snapd/Connection 1970-01-01 00:00:00 +0000
178+++ snapd-qt/Snapd/Connection 2017-01-24 04:26:53 +0000
179@@ -0,0 +1,1 @@
180+#include <Snapd/connection.h>
181
182=== added file 'snapd-qt/Snapd/Icon'
183--- snapd-qt/Snapd/Icon 1970-01-01 00:00:00 +0000
184+++ snapd-qt/Snapd/Icon 2017-01-24 04:26:53 +0000
185@@ -0,0 +1,1 @@
186+#include <Snapd/icon.h>
187
188=== added file 'snapd-qt/Snapd/Price'
189--- snapd-qt/Snapd/Price 1970-01-01 00:00:00 +0000
190+++ snapd-qt/Snapd/Price 2017-01-24 04:26:53 +0000
191@@ -0,0 +1,1 @@
192+#include <Snapd/price.h>
193
194=== added file 'snapd-qt/Snapd/Request'
195--- snapd-qt/Snapd/Request 1970-01-01 00:00:00 +0000
196+++ snapd-qt/Snapd/Request 2017-01-24 04:26:53 +0000
197@@ -0,0 +1,1 @@
198+#include <Snapd/request.h>
199
200=== added file 'snapd-qt/Snapd/Snap'
201--- snapd-qt/Snapd/Snap 1970-01-01 00:00:00 +0000
202+++ snapd-qt/Snapd/Snap 2017-01-24 04:26:53 +0000
203@@ -0,0 +1,1 @@
204+#include <Snapd/snap.h>
205
206=== added file 'snapd-qt/Snapd/SystemInformation'
207--- snapd-qt/Snapd/SystemInformation 1970-01-01 00:00:00 +0000
208+++ snapd-qt/Snapd/SystemInformation 2017-01-24 04:26:53 +0000
209@@ -0,0 +1,1 @@
210+#include <Snapd/system-information.h>
211
212=== added file 'snapd-qt/Snapd/Task'
213--- snapd-qt/Snapd/Task 1970-01-01 00:00:00 +0000
214+++ snapd-qt/Snapd/Task 2017-01-24 04:26:53 +0000
215@@ -0,0 +1,1 @@
216+#include <Snapd/task.h>
217
218=== added file 'snapd-qt/Snapd/WrappedObject'
219--- snapd-qt/Snapd/WrappedObject 1970-01-01 00:00:00 +0000
220+++ snapd-qt/Snapd/WrappedObject 2017-01-24 04:26:53 +0000
221@@ -0,0 +1,1 @@
222+#include <Snapd/wrapped-object.h>
223
224=== added file 'snapd-qt/Snapd/app.h'
225--- snapd-qt/Snapd/app.h 1970-01-01 00:00:00 +0000
226+++ snapd-qt/Snapd/app.h 2017-01-24 04:26:53 +0000
227@@ -0,0 +1,28 @@
228+/*
229+ * Copyright (C) 2016 Canonical Ltd.
230+ *
231+ * This library is free software; you can redistribute it and/or modify it under
232+ * the terms of the GNU Lesser General Public License as published by the Free
233+ * Software Foundation; either version 2 or version 3 of the License.
234+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
235+ */
236+
237+#ifndef SNAPD_APP_H
238+#define SNAPD_APP_H
239+
240+#include <QtCore/QObject>
241+#include <Snapd/WrappedObject>
242+
243+class Q_DECL_EXPORT QSnapdApp : public QSnapdWrappedObject
244+{
245+ Q_OBJECT
246+
247+ Q_PROPERTY(QString name READ name)
248+
249+public:
250+ explicit QSnapdApp (void* snapd_object, QObject* parent = 0);
251+
252+ QString name () const;
253+};
254+
255+#endif
256
257=== added file 'snapd-qt/Snapd/auth-data.h'
258--- snapd-qt/Snapd/auth-data.h 1970-01-01 00:00:00 +0000
259+++ snapd-qt/Snapd/auth-data.h 2017-01-24 04:26:53 +0000
260@@ -0,0 +1,32 @@
261+/*
262+ * Copyright (C) 2016 Canonical Ltd.
263+ *
264+ * This library is free software; you can redistribute it and/or modify it under
265+ * the terms of the GNU Lesser General Public License as published by the Free
266+ * Software Foundation; either version 2 or version 3 of the License.
267+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
268+ */
269+
270+#ifndef SNAPD_AUTH_DATA_H
271+#define SNAPD_AUTH_DATA_H
272+
273+#include <QtCore/QObject>
274+#include <QStringList>
275+#include <Snapd/WrappedObject>
276+
277+class Q_DECL_EXPORT QSnapdAuthData : public QSnapdWrappedObject
278+{
279+ Q_OBJECT
280+ Q_PROPERTY(QString macaroon READ macaroon)
281+ Q_PROPERTY(QStringList discharges READ discharges)
282+
283+public:
284+ explicit QSnapdAuthData (void *snapd_object, QObject* parent = 0);
285+ explicit QSnapdAuthData (const QString& macaroon, const QStringList& discharges, QObject* parent = 0);
286+ explicit QSnapdAuthData (QObject* parent = 0);
287+
288+ QString macaroon () const;
289+ QStringList discharges () const;
290+};
291+
292+#endif
293
294=== added file 'snapd-qt/Snapd/client.h'
295--- snapd-qt/Snapd/client.h 1970-01-01 00:00:00 +0000
296+++ snapd-qt/Snapd/client.h 2017-01-24 04:26:53 +0000
297@@ -0,0 +1,358 @@
298+/*
299+ * Copyright (C) 2016 Canonical Ltd.
300+ *
301+ * This library is free software; you can redistribute it and/or modify it under
302+ * the terms of the GNU Lesser General Public License as published by the Free
303+ * Software Foundation; either version 2 or version 3 of the License.
304+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
305+ */
306+
307+#ifndef SNAPD_CLIENT_H
308+#define SNAPD_CLIENT_H
309+
310+#include <QtCore/QObject>
311+#include <Snapd/AuthData>
312+#include <Snapd/Connection>
313+#include <Snapd/Icon>
314+#include <Snapd/Request>
315+#include <Snapd/Snap>
316+#include <Snapd/SystemInformation>
317+
318+class QSnapdConnectRequestPrivate;
319+class Q_DECL_EXPORT QSnapdConnectRequest : public QSnapdRequest
320+{
321+ Q_OBJECT
322+
323+public:
324+ explicit QSnapdConnectRequest (void *snapd_client, QObject *parent = 0);
325+ virtual void runSync ();
326+ virtual void runAsync ();
327+ void handleResult (void *, void *);
328+
329+private:
330+ QSnapdConnectRequestPrivate *d_ptr;
331+ Q_DECLARE_PRIVATE(QSnapdConnectRequest)
332+};
333+
334+class QSnapdLoginRequestPrivate;
335+class Q_DECL_EXPORT QSnapdLoginRequest : public QSnapdRequest
336+{
337+ Q_OBJECT
338+
339+public:
340+ explicit QSnapdLoginRequest (void *snapd_client, const QString& username, const QString& password, const QString& otp, QObject *parent = 0);
341+ virtual void runSync ();
342+ virtual void runAsync ();
343+ void handleResult (void *, void *);
344+
345+private:
346+ QSnapdLoginRequestPrivate *d_ptr;
347+ Q_DECLARE_PRIVATE(QSnapdLoginRequest)
348+};
349+
350+class QSnapdGetSystemInformationRequestPrivate;
351+class Q_DECL_EXPORT QSnapdGetSystemInformationRequest : public QSnapdRequest
352+{
353+ Q_OBJECT
354+ Q_PROPERTY(QSnapdSystemInformation* systemInformation READ systemInformation)
355+
356+public:
357+ explicit QSnapdGetSystemInformationRequest (void *snapd_client, QObject *parent = 0);
358+ virtual void runSync ();
359+ virtual void runAsync ();
360+ QSnapdSystemInformation *systemInformation ();
361+ void handleResult (void *, void *);
362+
363+private:
364+ QSnapdGetSystemInformationRequestPrivate *d_ptr;
365+ Q_DECLARE_PRIVATE(QSnapdGetSystemInformationRequest)
366+};
367+
368+class QSnapdListRequestPrivate;
369+class Q_DECL_EXPORT QSnapdListRequest : public QSnapdRequest
370+{
371+ Q_OBJECT
372+ Q_PROPERTY(int snapCount READ snapCount)
373+
374+public:
375+ explicit QSnapdListRequest (void *snapd_client, QObject *parent = 0);
376+
377+ virtual void runSync ();
378+ virtual void runAsync ();
379+ Q_INVOKABLE int snapCount () const;
380+ Q_INVOKABLE QSnapdSnap *snap (int) const;
381+ void handleResult (void *, void *);
382+
383+private:
384+ QSnapdListRequestPrivate *d_ptr;
385+ Q_DECLARE_PRIVATE(QSnapdListRequest)
386+};
387+
388+class QSnapdListOneRequestPrivate;
389+class Q_DECL_EXPORT QSnapdListOneRequest : public QSnapdRequest
390+{
391+ Q_OBJECT
392+
393+public:
394+ explicit QSnapdListOneRequest (const QString& name, void *snapd_client, QObject *parent = 0);
395+
396+ virtual void runSync ();
397+ virtual void runAsync ();
398+ Q_INVOKABLE QSnapdSnap *snap () const;
399+ void handleResult (void *, void *);
400+
401+private:
402+ QSnapdListOneRequestPrivate *d_ptr;
403+ Q_DECLARE_PRIVATE(QSnapdListOneRequest)
404+};
405+
406+class QSnapdGetIconRequestPrivate;
407+class Q_DECL_EXPORT QSnapdGetIconRequest : public QSnapdRequest
408+{
409+ Q_OBJECT
410+
411+public:
412+ explicit QSnapdGetIconRequest (const QString& name, void *snapd_client, QObject *parent = 0);
413+ virtual void runSync ();
414+ virtual void runAsync ();
415+ QSnapdIcon *icon () const;
416+ void handleResult (void *, void *);
417+
418+private:
419+ QSnapdGetIconRequestPrivate *d_ptr;
420+ Q_DECLARE_PRIVATE(QSnapdGetIconRequest)
421+};
422+
423+class QSnapdGetInterfacesRequestPrivate;
424+class Q_DECL_EXPORT QSnapdGetInterfacesRequest : public QSnapdRequest
425+{
426+ Q_OBJECT
427+ Q_PROPERTY(int plugCount READ plugCount)
428+ Q_PROPERTY(int slotCount READ slotCount)
429+
430+public:
431+ explicit QSnapdGetInterfacesRequest (void *snapd_client, QObject *parent = 0);
432+ virtual void runSync ();
433+ virtual void runAsync ();
434+ Q_INVOKABLE int plugCount () const;
435+ Q_INVOKABLE QSnapdConnection *plug (int) const;
436+ Q_INVOKABLE int slotCount () const;
437+ Q_INVOKABLE QSnapdConnection *slot (int) const;
438+ void handleResult (void *, void *);
439+
440+private:
441+ QSnapdGetInterfacesRequestPrivate *d_ptr;
442+ Q_DECLARE_PRIVATE(QSnapdGetInterfacesRequest)
443+};
444+
445+class QSnapdConnectInterfaceRequestPrivate;
446+class Q_DECL_EXPORT QSnapdConnectInterfaceRequest : public QSnapdRequest
447+{
448+ Q_OBJECT
449+
450+public:
451+ explicit QSnapdConnectInterfaceRequest (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name, void *snapd_client, QObject *parent = 0);
452+ virtual void runSync ();
453+ virtual void runAsync ();
454+ void handleResult (void *, void *);
455+
456+private:
457+ QSnapdConnectInterfaceRequestPrivate *d_ptr;
458+ Q_DECLARE_PRIVATE(QSnapdConnectInterfaceRequest)
459+};
460+
461+class QSnapdDisconnectInterfaceRequestPrivate;
462+class Q_DECL_EXPORT QSnapdDisconnectInterfaceRequest : public QSnapdRequest
463+{
464+ Q_OBJECT
465+
466+public:
467+ explicit QSnapdDisconnectInterfaceRequest (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name, void *snapd_client, QObject *parent = 0);
468+ virtual void runSync ();
469+ virtual void runAsync ();
470+ void handleResult (void *, void *);
471+
472+private:
473+ QSnapdDisconnectInterfaceRequestPrivate *d_ptr;
474+ Q_DECLARE_PRIVATE(QSnapdDisconnectInterfaceRequest)
475+};
476+
477+class QSnapdFindRequestPrivate;
478+class Q_DECL_EXPORT QSnapdFindRequest : public QSnapdRequest
479+{
480+ Q_OBJECT
481+ Q_PROPERTY(int snapCount READ snapCount)
482+ Q_PROPERTY(QString suggestedCurrency READ suggestedCurrency)
483+
484+public:
485+ explicit QSnapdFindRequest (int flags, const QString& name, void *snapd_client, QObject *parent = 0);
486+ virtual void runSync ();
487+ virtual void runAsync ();
488+ Q_INVOKABLE int snapCount () const;
489+ Q_INVOKABLE QSnapdSnap *snap (int) const;
490+ const QString suggestedCurrency () const;
491+ void handleResult (void *, void *);
492+
493+private:
494+ QSnapdFindRequestPrivate *d_ptr;
495+ Q_DECLARE_PRIVATE(QSnapdFindRequest)
496+};
497+
498+class QSnapdInstallRequestPrivate;
499+class Q_DECL_EXPORT QSnapdInstallRequest : public QSnapdRequest
500+{
501+ Q_OBJECT
502+
503+public:
504+ explicit QSnapdInstallRequest (const QString& name, const QString& channel, void *snapd_client, QObject *parent = 0);
505+ virtual void runSync ();
506+ virtual void runAsync ();
507+ void handleResult (void *, void *);
508+
509+private:
510+ QSnapdInstallRequestPrivate *d_ptr;
511+ Q_DECLARE_PRIVATE(QSnapdInstallRequest)
512+};
513+
514+class QSnapdRefreshRequestPrivate;
515+class Q_DECL_EXPORT QSnapdRefreshRequest : public QSnapdRequest
516+{
517+ Q_OBJECT
518+
519+public:
520+ explicit QSnapdRefreshRequest (const QString& name, const QString& channel, void *snapd_client, QObject *parent = 0);
521+ virtual void runSync ();
522+ virtual void runAsync ();
523+ void handleResult (void *, void *);
524+
525+private:
526+ QSnapdRefreshRequestPrivate *d_ptr;
527+ Q_DECLARE_PRIVATE(QSnapdRefreshRequest)
528+};
529+
530+class QSnapdRemoveRequestPrivate;
531+class Q_DECL_EXPORT QSnapdRemoveRequest : public QSnapdRequest
532+{
533+ Q_OBJECT
534+
535+public:
536+ explicit QSnapdRemoveRequest (const QString& name, void *snapd_client, QObject *parent = 0);
537+ virtual void runSync ();
538+ virtual void runAsync ();
539+ void handleResult (void *, void *);
540+
541+private:
542+ QSnapdRemoveRequestPrivate *d_ptr;
543+ Q_DECLARE_PRIVATE(QSnapdRemoveRequest)
544+};
545+
546+class QSnapdEnableRequestPrivate;
547+class Q_DECL_EXPORT QSnapdEnableRequest : public QSnapdRequest
548+{
549+ Q_OBJECT
550+
551+public:
552+ explicit QSnapdEnableRequest (const QString& name, void *snapd_client, QObject *parent = 0);
553+ virtual void runSync ();
554+ virtual void runAsync ();
555+ void handleResult (void *, void *);
556+
557+private:
558+ QSnapdEnableRequestPrivate *d_ptr;
559+ Q_DECLARE_PRIVATE(QSnapdEnableRequest)
560+};
561+
562+class QSnapdDisableRequestPrivate;
563+class Q_DECL_EXPORT QSnapdDisableRequest : public QSnapdRequest
564+{
565+ Q_OBJECT
566+
567+public:
568+ explicit QSnapdDisableRequest (const QString& name, void *snapd_client, QObject *parent = 0);
569+ virtual void runSync ();
570+ virtual void runAsync ();
571+ void handleResult (void *, void *);
572+
573+private:
574+ QSnapdDisableRequestPrivate *d_ptr;
575+ Q_DECLARE_PRIVATE(QSnapdDisableRequest)
576+};
577+
578+class QSnapdCheckBuyRequestPrivate;
579+class Q_DECL_EXPORT QSnapdCheckBuyRequest : public QSnapdRequest
580+{
581+ Q_OBJECT
582+ Q_PROPERTY(bool canBuy READ canBuy)
583+
584+public:
585+ explicit QSnapdCheckBuyRequest (void *snapd_client, QObject *parent = 0);
586+ virtual void runSync ();
587+ virtual void runAsync ();
588+ Q_INVOKABLE bool canBuy () const;
589+ void handleResult (void *, void *);
590+
591+private:
592+ QSnapdCheckBuyRequestPrivate *d_ptr;
593+ Q_DECLARE_PRIVATE(QSnapdCheckBuyRequest)
594+};
595+
596+class QSnapdBuyRequestPrivate;
597+class Q_DECL_EXPORT QSnapdBuyRequest : public QSnapdRequest
598+{
599+ Q_OBJECT
600+
601+public:
602+ explicit QSnapdBuyRequest (const QString& id, double amount, const QString& currency, void *snapd_client, QObject *parent = 0);
603+ virtual void runSync ();
604+ virtual void runAsync ();
605+ void handleResult (void *, void *);
606+
607+private:
608+ QSnapdBuyRequestPrivate *d_ptr;
609+ Q_DECLARE_PRIVATE(QSnapdBuyRequest)
610+};
611+
612+Q_INVOKABLE QSnapdLoginRequest *login (const QString& username, const QString& password, const QString& otp);
613+
614+class QSnapdClientPrivate;
615+class Q_DECL_EXPORT QSnapdClient : public QObject
616+{
617+ Q_OBJECT
618+ Q_FLAGS(FindFlags)
619+
620+public:
621+ enum FindFlag
622+ {
623+ None = 0,
624+ MatchName = 1 << 0,
625+ SelectPrivate = 1 << 1,
626+ SelectRefresh = 1 << 2
627+ };
628+ Q_DECLARE_FLAGS(FindFlags, FindFlag);
629+ explicit QSnapdClient (QObject* parent=0);
630+ Q_INVOKABLE QSnapdConnectRequest *connect ();
631+ Q_INVOKABLE QSnapdLoginRequest *login (const QString& username, const QString& password, const QString& otp);
632+ Q_INVOKABLE QSnapdGetSystemInformationRequest *getSystemInformation ();
633+ Q_INVOKABLE QSnapdListRequest *list ();
634+ Q_INVOKABLE QSnapdListOneRequest *listOne (const QString &name);
635+ Q_INVOKABLE QSnapdGetIconRequest *getIcon (const QString &name);
636+ Q_INVOKABLE QSnapdGetInterfacesRequest *getInterfaces ();
637+ Q_INVOKABLE QSnapdConnectInterfaceRequest *connectInterface (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name);
638+ Q_INVOKABLE QSnapdDisconnectInterfaceRequest *disconnectInterface (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name);
639+ Q_INVOKABLE QSnapdFindRequest *find (FindFlags flags, const QString &query);
640+ Q_INVOKABLE QSnapdInstallRequest *install (const QString &name, const QString &channel);
641+ Q_INVOKABLE QSnapdRefreshRequest *refresh (const QString &name, const QString &channel);
642+ Q_INVOKABLE QSnapdRemoveRequest *remove (const QString &name);
643+ Q_INVOKABLE QSnapdEnableRequest *enable (const QString &name);
644+ Q_INVOKABLE QSnapdDisableRequest *disable (const QString &name);
645+ Q_INVOKABLE QSnapdCheckBuyRequest *checkBuy ();
646+ Q_INVOKABLE QSnapdBuyRequest *buy (const QString& id, double amount, const QString& currency);
647+
648+private:
649+ QSnapdClientPrivate *d_ptr;
650+ Q_DECLARE_PRIVATE(QSnapdClient)
651+};
652+
653+Q_DECLARE_OPERATORS_FOR_FLAGS(QSnapdClient::FindFlags)
654+
655+#endif
656
657=== added file 'snapd-qt/Snapd/connection.h'
658--- snapd-qt/Snapd/connection.h 1970-01-01 00:00:00 +0000
659+++ snapd-qt/Snapd/connection.h 2017-01-24 04:26:53 +0000
660@@ -0,0 +1,30 @@
661+/*
662+ * Copyright (C) 2016 Canonical Ltd.
663+ *
664+ * This library is free software; you can redistribute it and/or modify it under
665+ * the terms of the GNU Lesser General Public License as published by the Free
666+ * Software Foundation; either version 2 or version 3 of the License.
667+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
668+ */
669+
670+#ifndef SNAPD_CONNECTION_H
671+#define SNAPD_CONNECTION_H
672+
673+#include <QtCore/QObject>
674+#include <Snapd/WrappedObject>
675+
676+class Q_DECL_EXPORT QSnapdConnection : public QSnapdWrappedObject
677+{
678+ Q_OBJECT
679+
680+ Q_PROPERTY(QString name READ name)
681+ Q_PROPERTY(QString snap READ snap)
682+
683+public:
684+ explicit QSnapdConnection (void* snapd_object, QObject* parent = 0);
685+
686+ QString name () const;
687+ QString snap () const;
688+};
689+
690+#endif
691
692=== added file 'snapd-qt/Snapd/icon.h'
693--- snapd-qt/Snapd/icon.h 1970-01-01 00:00:00 +0000
694+++ snapd-qt/Snapd/icon.h 2017-01-24 04:26:53 +0000
695@@ -0,0 +1,30 @@
696+/*
697+ * Copyright (C) 2016 Canonical Ltd.
698+ *
699+ * This library is free software; you can redistribute it and/or modify it under
700+ * the terms of the GNU Lesser General Public License as published by the Free
701+ * Software Foundation; either version 2 or version 3 of the License.
702+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
703+ */
704+
705+#ifndef SNAPD_ICON_H
706+#define SNAPD_ICON_H
707+
708+#include <QtCore/QObject>
709+#include <Snapd/WrappedObject>
710+
711+class Q_DECL_EXPORT QSnapdIcon : public QSnapdWrappedObject
712+{
713+ Q_OBJECT
714+
715+ Q_PROPERTY(QString mimeType READ mimeType)
716+ Q_PROPERTY(QByteArray data READ data)
717+
718+public:
719+ explicit QSnapdIcon (void* snapd_object, QObject* parent = 0);
720+
721+ QString mimeType () const;
722+ QByteArray data () const;
723+};
724+
725+#endif
726
727=== added file 'snapd-qt/Snapd/price.h'
728--- snapd-qt/Snapd/price.h 1970-01-01 00:00:00 +0000
729+++ snapd-qt/Snapd/price.h 2017-01-24 04:26:53 +0000
730@@ -0,0 +1,30 @@
731+/*
732+ * Copyright (C) 2016 Canonical Ltd.
733+ *
734+ * This library is free software; you can redistribute it and/or modify it under
735+ * the terms of the GNU Lesser General Public License as published by the Free
736+ * Software Foundation; either version 2 or version 3 of the License.
737+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
738+ */
739+
740+#ifndef SNAPD_PRICE_H
741+#define SNAPD_PRICE_H
742+
743+#include <QtCore/QObject>
744+#include <Snapd/WrappedObject>
745+
746+class Q_DECL_EXPORT QSnapdPrice : public QSnapdWrappedObject
747+{
748+ Q_OBJECT
749+
750+ Q_PROPERTY(double amount READ amount)
751+ Q_PROPERTY(QString currency READ currency)
752+
753+public:
754+ explicit QSnapdPrice (void* snapd_object, QObject* parent = 0);
755+
756+ double amount () const;
757+ QString currency () const;
758+};
759+
760+#endif
761
762=== added file 'snapd-qt/Snapd/request.h'
763--- snapd-qt/Snapd/request.h 1970-01-01 00:00:00 +0000
764+++ snapd-qt/Snapd/request.h 2017-01-24 04:26:53 +0000
765@@ -0,0 +1,76 @@
766+/*
767+ * Copyright (C) 2016 Canonical Ltd.
768+ *
769+ * This library is free software; you can redistribute it and/or modify it under
770+ * the terms of the GNU Lesser General Public License as published by the Free
771+ * Software Foundation; either version 2 or version 3 of the License.
772+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
773+ */
774+
775+#ifndef SNAPD_REQUEST_H
776+#define SNAPD_REQUEST_H
777+
778+#include <QtCore/QObject>
779+#include <Snapd/Task>
780+
781+struct QSnapdRequestPrivate;
782+
783+class Q_DECL_EXPORT QSnapdRequest : public QObject
784+{
785+ Q_OBJECT
786+
787+ Q_PROPERTY(bool isFinished READ isFinished)
788+ Q_PROPERTY(QSnapdError error READ error)
789+ Q_PROPERTY(QString errorString READ errorString)
790+ Q_PROPERTY(QSnapdTask mainTask READ mainTask)
791+ Q_PROPERTY(int taskCount READ taskCount)
792+ Q_ENUMS(QSnapdError)
793+
794+public:
795+ enum QSnapdError
796+ {
797+ NoError,
798+ UnknownError,
799+ ConnectionFailed,
800+ WriteFailed,
801+ ReadFailed,
802+ BadRequest,
803+ BadResponse,
804+ AuthDataRequired,
805+ AuthDataInvalid,
806+ TwoFactorRequired,
807+ TwoFactorInvalid,
808+ PermissionDenied,
809+ Failed,
810+ TermsNotAccepted,
811+ PaymentNotSetup,
812+ PaymentDeclined
813+ };
814+
815+ explicit QSnapdRequest (void *snapd_client, QObject* parent = 0);
816+ bool isFinished () const;
817+ QSnapdError error () const;
818+ QString errorString () const;
819+ Q_INVOKABLE virtual void runSync () = 0;
820+ Q_INVOKABLE virtual void runAsync () = 0;
821+ Q_INVOKABLE void cancel ();
822+ Q_INVOKABLE QSnapdTask *mainTask () const;
823+ Q_INVOKABLE int taskCount () const;
824+ Q_INVOKABLE QSnapdTask *task (int) const;
825+ void handleProgress (void*, void*);
826+
827+protected:
828+ void *getClient () const;
829+ void *getCancellable () const;
830+ void finish (void *error);
831+
832+signals:
833+ void progress ();
834+ void complete ();
835+
836+private:
837+ QSnapdRequestPrivate *d_ptr;
838+ Q_DECLARE_PRIVATE (QSnapdRequest);
839+};
840+
841+#endif
842
843=== added file 'snapd-qt/Snapd/snap.h'
844--- snapd-qt/Snapd/snap.h 1970-01-01 00:00:00 +0000
845+++ snapd-qt/Snapd/snap.h 2017-01-24 04:26:53 +0000
846@@ -0,0 +1,95 @@
847+/*
848+ * Copyright (C) 2016 Canonical Ltd.
849+ *
850+ * This library is free software; you can redistribute it and/or modify it under
851+ * the terms of the GNU Lesser General Public License as published by the Free
852+ * Software Foundation; either version 2 or version 3 of the License.
853+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
854+ */
855+
856+#ifndef SNAPD_SNAP_H
857+#define SNAPD_SNAP_H
858+
859+#include <QtCore/QObject>
860+#include <QtCore/QDate>
861+#include <Snapd/WrappedObject>
862+#include <Snapd/App>
863+#include <Snapd/Price>
864+
865+class Q_DECL_EXPORT QSnapdSnap : public QSnapdWrappedObject
866+{
867+ Q_OBJECT
868+
869+ Q_PROPERTY(int appCount READ appCount)
870+ Q_PROPERTY(QString channel READ channel)
871+ Q_PROPERTY(QSnapdConfinement confinement READ confinement)
872+ Q_PROPERTY(QString description READ description)
873+ Q_PROPERTY(QString developer READ developer)
874+ Q_PROPERTY(bool devmode READ devmode)
875+ Q_PROPERTY(qint64 downloadSize READ downloadSize)
876+ Q_PROPERTY(QString icon READ icon)
877+ Q_PROPERTY(QString id READ id)
878+ Q_PROPERTY(QDateTime installDate READ installDate)
879+ Q_PROPERTY(qint64 installedSize READ installedSize)
880+ Q_PROPERTY(QString name READ name)
881+ Q_PROPERTY(int priceCount READ priceCount)
882+ Q_PROPERTY(bool isPrivate READ isPrivate)
883+ Q_PROPERTY(QString revision READ revision)
884+ Q_PROPERTY(QSnapdSnapType snapType READ snapType)
885+ Q_PROPERTY(QSnapdSnapStatus status READ status)
886+ Q_PROPERTY(QString summary READ summary)
887+ Q_PROPERTY(bool trymode READ trymode)
888+ Q_PROPERTY(QString version READ version)
889+ Q_ENUMS(QSnapdConfinement QSnapdSnapType QSnapdSnapStatus)
890+
891+public:
892+ enum QSnapdConfinement
893+ {
894+ ConfinementUnknown,
895+ Strict,
896+ Devmode
897+ };
898+ enum QSnapdSnapType
899+ {
900+ TypeUnknown,
901+ App,
902+ Kernel,
903+ Gadget,
904+ OperatingSystem
905+ };
906+ enum QSnapdSnapStatus
907+ {
908+ StatusUnknown,
909+ Available,
910+ Priced,
911+ Installed,
912+ Active
913+ };
914+
915+ explicit QSnapdSnap (void* snapd_object, QObject* parent = 0);
916+
917+ int appCount () const;
918+ Q_INVOKABLE QSnapdApp *app (int) const;
919+ QString channel () const;
920+ QSnapdConfinement confinement () const;
921+ QString description () const;
922+ QString developer () const;
923+ bool devmode () const;
924+ qint64 downloadSize () const;
925+ QString icon () const;
926+ QString id () const;
927+ QDateTime installDate () const;
928+ qint64 installedSize () const;
929+ QString name () const;
930+ int priceCount () const;
931+ Q_INVOKABLE QSnapdPrice *price (int) const;
932+ bool isPrivate () const;
933+ QString revision () const;
934+ QSnapdSnapType snapType () const;
935+ QSnapdSnapStatus status () const;
936+ QString summary () const;
937+ bool trymode () const;
938+ QString version () const;
939+};
940+
941+#endif
942
943=== added file 'snapd-qt/Snapd/system-information.h'
944--- snapd-qt/Snapd/system-information.h 1970-01-01 00:00:00 +0000
945+++ snapd-qt/Snapd/system-information.h 2017-01-24 04:26:53 +0000
946@@ -0,0 +1,34 @@
947+/*
948+ * Copyright (C) 2016 Canonical Ltd.
949+ *
950+ * This library is free software; you can redistribute it and/or modify it under
951+ * the terms of the GNU Lesser General Public License as published by the Free
952+ * Software Foundation; either version 2 or version 3 of the License.
953+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
954+ */
955+
956+#ifndef SNAPD_SYSTEM_INFORMATION_H
957+#define SNAPD_SYSTEM_INFORMATION_H
958+
959+#include <QtCore/QObject>
960+#include <Snapd/WrappedObject>
961+
962+class Q_DECL_EXPORT QSnapdSystemInformation : public QSnapdWrappedObject
963+{
964+ Q_OBJECT
965+
966+ Q_PROPERTY(QString osId READ osId)
967+ Q_PROPERTY(QString osVersion READ osVersion)
968+ Q_PROPERTY(QString series READ series)
969+ Q_PROPERTY(QString version READ version)
970+
971+public:
972+ explicit QSnapdSystemInformation (void *snapd_object, QObject* parent = 0);
973+
974+ QString osId () const;
975+ QString osVersion () const;
976+ QString series () const;
977+ QString version () const;
978+};
979+
980+#endif
981
982=== added file 'snapd-qt/Snapd/task.h'
983--- snapd-qt/Snapd/task.h 1970-01-01 00:00:00 +0000
984+++ snapd-qt/Snapd/task.h 2017-01-24 04:26:53 +0000
985@@ -0,0 +1,45 @@
986+/*
987+ * Copyright (C) 2016 Canonical Ltd.
988+ *
989+ * This library is free software; you can redistribute it and/or modify it under
990+ * the terms of the GNU Lesser General Public License as published by the Free
991+ * Software Foundation; either version 2 or version 3 of the License.
992+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
993+ */
994+
995+#ifndef SNAPD_TASK_H
996+#define SNAPD_TASK_H
997+
998+#include <QtCore/QObject>
999+#include <QtCore/QDateTime>
1000+#include <Snapd/WrappedObject>
1001+
1002+class Q_DECL_EXPORT QSnapdTask : public QSnapdWrappedObject
1003+{
1004+ Q_OBJECT
1005+
1006+ Q_PROPERTY (QString id READ id)
1007+ Q_PROPERTY (QString kind READ kind)
1008+ Q_PROPERTY (QString summary READ summary)
1009+ Q_PROPERTY (QString status READ status)
1010+ Q_PROPERTY (bool ready READ ready)
1011+ Q_PROPERTY (qint64 progressDone READ progressDone)
1012+ Q_PROPERTY (qint64 progressTotal READ progressTotal)
1013+ Q_PROPERTY (QDateTime spawnTime READ spawnTime)
1014+ Q_PROPERTY (QDateTime readyTime READ readyTime)
1015+
1016+public:
1017+ explicit QSnapdTask (void* snapd_object, QObject* parent = 0);
1018+
1019+ Q_INVOKABLE QString id () const;
1020+ Q_INVOKABLE QString kind () const;
1021+ Q_INVOKABLE QString summary () const;
1022+ Q_INVOKABLE QString status () const;
1023+ Q_INVOKABLE bool ready () const;
1024+ Q_INVOKABLE qint64 progressDone () const;
1025+ Q_INVOKABLE qint64 progressTotal () const;
1026+ Q_INVOKABLE QDateTime spawnTime () const;
1027+ Q_INVOKABLE QDateTime readyTime () const;
1028+};
1029+
1030+#endif
1031
1032=== added file 'snapd-qt/Snapd/wrapped-object.h'
1033--- snapd-qt/Snapd/wrapped-object.h 1970-01-01 00:00:00 +0000
1034+++ snapd-qt/Snapd/wrapped-object.h 2017-01-24 04:26:53 +0000
1035@@ -0,0 +1,33 @@
1036+/*
1037+ * Copyright (C) 2016 Canonical Ltd.
1038+ *
1039+ * This library is free software; you can redistribute it and/or modify it under
1040+ * the terms of the GNU Lesser General Public License as published by the Free
1041+ * Software Foundation; either version 2 or version 3 of the License.
1042+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
1043+ */
1044+
1045+#ifndef SNAPD_WRAPPED_OBJECT_H
1046+#define SNAPD_WRAPPED_OBJECT_H
1047+
1048+#include <QtCore/QObject>
1049+
1050+class Q_DECL_EXPORT QSnapdWrappedObject : public QObject
1051+{
1052+ Q_OBJECT
1053+
1054+public:
1055+ explicit QSnapdWrappedObject (void* object, void (*unref_func)(void *), QObject *parent = 0) : QObject (parent), wrapped_object (object), unref_func (unref_func) {}
1056+ ~QSnapdWrappedObject ()
1057+ {
1058+ unref_func (wrapped_object);
1059+ }
1060+
1061+protected:
1062+ void *wrapped_object;
1063+
1064+private:
1065+ void (*unref_func)(void *);
1066+};
1067+
1068+#endif
1069
1070=== added file 'snapd-qt/SnapdConfig.cmake.in'
1071--- snapd-qt/SnapdConfig.cmake.in 1970-01-01 00:00:00 +0000
1072+++ snapd-qt/SnapdConfig.cmake.in 2017-01-24 04:26:53 +0000
1073@@ -0,0 +1,5 @@
1074+# SNAPD_INCLUDE_DIRS - The snapd-qt include directories
1075+# SNAPD_LIBRARIES - The libraries needed to use snapd-qt
1076+
1077+set(SNAPD_LIBRARIES @libdir@/libsnapd-qt.so)
1078+set(SNAPD_INCLUDE_DIRS @includedir@/snapd-qt/)
1079
1080=== added file 'snapd-qt/SnapdConfigVersion.cmake.in'
1081--- snapd-qt/SnapdConfigVersion.cmake.in 1970-01-01 00:00:00 +0000
1082+++ snapd-qt/SnapdConfigVersion.cmake.in 2017-01-24 04:26:53 +0000
1083@@ -0,0 +1,10 @@
1084+set(PACKAGE_VERSION @VERSION@)
1085+
1086+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
1087+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
1088+else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
1089+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
1090+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
1091+ set(PACKAGE_VERSION_EXACT TRUE)
1092+ endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
1093+endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
1094
1095=== added file 'snapd-qt/app.cpp'
1096--- snapd-qt/app.cpp 1970-01-01 00:00:00 +0000
1097+++ snapd-qt/app.cpp 2017-01-24 04:26:53 +0000
1098@@ -0,0 +1,19 @@
1099+/*
1100+ * Copyright (C) 2016 Canonical Ltd.
1101+ *
1102+ * This library is free software; you can redistribute it and/or modify it under
1103+ * the terms of the GNU Lesser General Public License as published by the Free
1104+ * Software Foundation; either version 2 or version 3 of the License.
1105+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
1106+ */
1107+
1108+#include <snapd-glib/snapd-glib.h>
1109+
1110+#include "Snapd/app.h"
1111+
1112+QSnapdApp::QSnapdApp (void *snapd_object, QObject *parent) : QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
1113+
1114+QString QSnapdApp::name () const
1115+{
1116+ return snapd_app_get_name (SNAPD_APP (wrapped_object));
1117+}
1118
1119=== added file 'snapd-qt/auth-data.cpp'
1120--- snapd-qt/auth-data.cpp 1970-01-01 00:00:00 +0000
1121+++ snapd-qt/auth-data.cpp 2017-01-24 04:26:53 +0000
1122@@ -0,0 +1,40 @@
1123+/*
1124+ * Copyright (C) 2016 Canonical Ltd.
1125+ *
1126+ * This library is free software; you can redistribute it and/or modify it under
1127+ * the terms of the GNU Lesser General Public License as published by the Free
1128+ * Software Foundation; either version 2 or version 3 of the License.
1129+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
1130+ */
1131+
1132+#include <snapd-glib/snapd-glib.h>
1133+
1134+#include "Snapd/auth-data.h"
1135+
1136+QSnapdAuthData::QSnapdAuthData (void *snapd_object, QObject *parent) :
1137+ QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
1138+
1139+QSnapdAuthData::QSnapdAuthData (const QString& macaroon, const QStringList& discharges, QObject *parent) :
1140+ QSnapdWrappedObject (NULL, g_object_unref, parent)
1141+{
1142+ char *strv[discharges.size () + 1];
1143+ int i;
1144+ for (i = 0; i < discharges.size (); i++)
1145+ strv[i] = (char *) discharges.at (i).toStdString ().c_str ();
1146+ strv[i] = NULL;
1147+ wrapped_object = snapd_auth_data_new (macaroon.toStdString ().c_str (), strv);
1148+}
1149+
1150+QString QSnapdAuthData::macaroon () const
1151+{
1152+ return snapd_auth_data_get_macaroon (SNAPD_AUTH_DATA (wrapped_object));
1153+}
1154+
1155+QStringList QSnapdAuthData::discharges () const
1156+{
1157+ gchar **discharges = snapd_auth_data_get_discharges (SNAPD_AUTH_DATA (wrapped_object));
1158+ QStringList result;
1159+ for (int i = 0; discharges[i] != NULL; i++)
1160+ result.append (discharges[i]);
1161+ return result;
1162+}
1163
1164=== added file 'snapd-qt/client.cpp'
1165--- snapd-qt/client.cpp 1970-01-01 00:00:00 +0000
1166+++ snapd-qt/client.cpp 2017-01-24 04:26:53 +0000
1167@@ -0,0 +1,1066 @@
1168+/*
1169+ * Copyright (C) 2016 Canonical Ltd.
1170+ *
1171+ * This library is free software; you can redistribute it and/or modify it under
1172+ * the terms of the GNU Lesser General Public License as published by the Free
1173+ * Software Foundation; either version 2 or version 3 of the License.
1174+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
1175+ */
1176+
1177+#include <snapd-glib/snapd-glib.h>
1178+
1179+#include "Snapd/client.h"
1180+
1181+struct QSnapdClientPrivate
1182+{
1183+ QSnapdClientPrivate ()
1184+ {
1185+ client = snapd_client_new ();
1186+ }
1187+
1188+ ~QSnapdClientPrivate ()
1189+ {
1190+ g_object_unref (client);
1191+ }
1192+
1193+ SnapdClient *client;
1194+};
1195+
1196+struct QSnapdConnectRequestPrivate
1197+{
1198+};
1199+
1200+struct QSnapdLoginRequestPrivate
1201+{
1202+ QSnapdLoginRequestPrivate (const QString& username, const QString& password, const QString& otp) :
1203+ username(username), password(password), otp(otp) {}
1204+ ~QSnapdLoginRequestPrivate ()
1205+ {
1206+ g_object_unref (auth_data);
1207+ }
1208+ QString username;
1209+ QString password;
1210+ QString otp;
1211+ SnapdAuthData *auth_data;
1212+};
1213+
1214+struct QSnapdGetSystemInformationRequestPrivate
1215+{
1216+ ~QSnapdGetSystemInformationRequestPrivate ()
1217+ {
1218+ g_object_unref (info);
1219+ }
1220+ SnapdSystemInformation *info;
1221+};
1222+
1223+struct QSnapdListRequestPrivate
1224+{
1225+ ~QSnapdListRequestPrivate ()
1226+ {
1227+ g_ptr_array_unref (snaps);
1228+ }
1229+ GPtrArray *snaps;
1230+};
1231+
1232+struct QSnapdListOneRequestPrivate
1233+{
1234+ QSnapdListOneRequestPrivate (const QString& name) :
1235+ name(name) {}
1236+ ~QSnapdListOneRequestPrivate ()
1237+ {
1238+ g_object_unref (snap);
1239+ }
1240+ QString name;
1241+ SnapdSnap *snap;
1242+};
1243+
1244+struct QSnapdGetIconRequestPrivate
1245+{
1246+ QSnapdGetIconRequestPrivate (const QString& name) :
1247+ name(name) {}
1248+ ~QSnapdGetIconRequestPrivate ()
1249+ {
1250+ g_object_unref (icon);
1251+ }
1252+ QString name;
1253+ SnapdIcon *icon;
1254+};
1255+
1256+struct QSnapdGetInterfacesRequestPrivate
1257+{
1258+ ~QSnapdGetInterfacesRequestPrivate ()
1259+ {
1260+ g_ptr_array_unref (plugs);
1261+ g_ptr_array_unref (slots_);
1262+ }
1263+ GPtrArray *plugs;
1264+ GPtrArray *slots_;
1265+};
1266+
1267+struct QSnapdConnectInterfaceRequestPrivate
1268+{
1269+ QSnapdConnectInterfaceRequestPrivate (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name) :
1270+ plug_snap (plug_snap), plug_name (plug_name), slot_snap (slot_snap), slot_name (slot_name) {}
1271+ QString plug_snap;
1272+ QString plug_name;
1273+ QString slot_snap;
1274+ QString slot_name;
1275+};
1276+
1277+struct QSnapdDisconnectInterfaceRequestPrivate
1278+{
1279+ QSnapdDisconnectInterfaceRequestPrivate (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name) :
1280+ plug_snap (plug_snap), plug_name (plug_name), slot_snap (slot_snap), slot_name (slot_name) {}
1281+ QString plug_snap;
1282+ QString plug_name;
1283+ QString slot_snap;
1284+ QString slot_name;
1285+};
1286+
1287+struct QSnapdFindRequestPrivate
1288+{
1289+ QSnapdFindRequestPrivate (int flags, const QString& name) :
1290+ flags (flags), name (name) {}
1291+ ~QSnapdFindRequestPrivate ()
1292+ {
1293+ g_ptr_array_unref (snaps);
1294+ }
1295+ int flags;
1296+ QString name;
1297+ GPtrArray *snaps;
1298+ QString suggestedCurrency;
1299+};
1300+
1301+struct QSnapdInstallRequestPrivate
1302+{
1303+ QSnapdInstallRequestPrivate (const QString& name, const QString& channel) :
1304+ name(name), channel(channel) {}
1305+ QString name;
1306+ QString channel;
1307+};
1308+
1309+struct QSnapdRefreshRequestPrivate
1310+{
1311+ QSnapdRefreshRequestPrivate (const QString& name, const QString& channel) :
1312+ name(name), channel(channel) {}
1313+ QString name;
1314+ QString channel;
1315+};
1316+
1317+struct QSnapdRemoveRequestPrivate
1318+{
1319+ QSnapdRemoveRequestPrivate (const QString& name) :
1320+ name(name) {}
1321+ QString name;
1322+};
1323+
1324+struct QSnapdEnableRequestPrivate
1325+{
1326+ QSnapdEnableRequestPrivate (const QString& name) :
1327+ name(name) {}
1328+ QString name;
1329+};
1330+
1331+struct QSnapdDisableRequestPrivate
1332+{
1333+ QSnapdDisableRequestPrivate (const QString& name) :
1334+ name(name) {}
1335+ QString name;
1336+};
1337+
1338+struct QSnapdCheckBuyRequestPrivate
1339+{
1340+ bool canBuy;
1341+};
1342+
1343+struct QSnapdBuyRequestPrivate
1344+{
1345+ QSnapdBuyRequestPrivate (const QString& id, double amount, const QString& currency) :
1346+ id(id), amount(amount), currency(currency) {}
1347+ QString id;
1348+ double amount;
1349+ QString currency;
1350+};
1351+
1352+QSnapdClient::QSnapdClient(QObject *parent) :
1353+ QObject (parent),
1354+ d_ptr (new QSnapdClientPrivate()) {}
1355+
1356+QSnapdConnectRequest *QSnapdClient::connect ()
1357+{
1358+ Q_D(QSnapdClient);
1359+ return new QSnapdConnectRequest (d->client);
1360+}
1361+
1362+QSnapdLoginRequest *login (const QString& username, const QString& password, const QString& otp)
1363+{
1364+ return new QSnapdLoginRequest (NULL, username, password, otp);
1365+}
1366+
1367+QSnapdLoginRequest *QSnapdClient::login (const QString& username, const QString& password, const QString& otp)
1368+{
1369+ Q_D(QSnapdClient);
1370+ return new QSnapdLoginRequest (d->client, username, password, otp);
1371+}
1372+
1373+QSnapdGetSystemInformationRequest *QSnapdClient::getSystemInformation ()
1374+{
1375+ Q_D(QSnapdClient);
1376+ return new QSnapdGetSystemInformationRequest (d->client);
1377+}
1378+
1379+QSnapdListRequest *QSnapdClient::list ()
1380+{
1381+ Q_D(QSnapdClient);
1382+ return new QSnapdListRequest (d->client);
1383+}
1384+
1385+QSnapdListOneRequest *QSnapdClient::listOne (const QString& name)
1386+{
1387+ Q_D(QSnapdClient);
1388+ return new QSnapdListOneRequest (name, d->client);
1389+}
1390+
1391+QSnapdGetIconRequest *QSnapdClient::getIcon (const QString& name)
1392+{
1393+ Q_D(QSnapdClient);
1394+ return new QSnapdGetIconRequest (name, d->client);
1395+}
1396+
1397+QSnapdGetInterfacesRequest *QSnapdClient::getInterfaces ()
1398+{
1399+ Q_D(QSnapdClient);
1400+ return new QSnapdGetInterfacesRequest (d->client);
1401+}
1402+
1403+QSnapdConnectInterfaceRequest *QSnapdClient::connectInterface (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name)
1404+{
1405+ Q_D(QSnapdClient);
1406+ return new QSnapdConnectInterfaceRequest (plug_snap, plug_name, slot_snap, slot_name, d->client);
1407+}
1408+
1409+QSnapdDisconnectInterfaceRequest *QSnapdClient::disconnectInterface (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name)
1410+{
1411+ Q_D(QSnapdClient);
1412+ return new QSnapdDisconnectInterfaceRequest (plug_snap, plug_name, slot_snap, slot_name, d->client);
1413+}
1414+
1415+QSnapdFindRequest *QSnapdClient::find (FindFlags flags, const QString& name)
1416+{
1417+ Q_D(QSnapdClient);
1418+ return new QSnapdFindRequest (flags, name, d->client);
1419+}
1420+
1421+QSnapdInstallRequest *QSnapdClient::install (const QString& name, const QString& channel)
1422+{
1423+ Q_D(QSnapdClient);
1424+ return new QSnapdInstallRequest (name, channel, d->client);
1425+}
1426+
1427+QSnapdRefreshRequest *QSnapdClient::refresh (const QString& name, const QString& channel)
1428+{
1429+ Q_D(QSnapdClient);
1430+ return new QSnapdRefreshRequest (name, channel, d->client);
1431+}
1432+
1433+QSnapdRemoveRequest *QSnapdClient::remove (const QString& name)
1434+{
1435+ Q_D(QSnapdClient);
1436+ return new QSnapdRemoveRequest (name, d->client);
1437+}
1438+
1439+QSnapdEnableRequest *QSnapdClient::enable (const QString& name)
1440+{
1441+ Q_D(QSnapdClient);
1442+ return new QSnapdEnableRequest (name, d->client);
1443+}
1444+
1445+QSnapdDisableRequest *QSnapdClient::disable (const QString& name)
1446+{
1447+ Q_D(QSnapdClient);
1448+ return new QSnapdDisableRequest (name, d->client);
1449+}
1450+
1451+QSnapdCheckBuyRequest *QSnapdClient::checkBuy ()
1452+{
1453+ Q_D(QSnapdClient);
1454+ return new QSnapdCheckBuyRequest (d->client);
1455+}
1456+
1457+QSnapdBuyRequest *QSnapdClient::buy (const QString& id, double amount, const QString& currency)
1458+{
1459+ Q_D(QSnapdClient);
1460+ return new QSnapdBuyRequest (id, amount, currency, d->client);
1461+}
1462+
1463+QSnapdConnectRequest::QSnapdConnectRequest (void *snapd_client, QObject *parent) :
1464+ QSnapdRequest (snapd_client, parent),
1465+ d_ptr (new QSnapdConnectRequestPrivate()) {}
1466+
1467+void QSnapdConnectRequest::runSync ()
1468+{
1469+ g_autoptr(GError) error = NULL;
1470+ snapd_client_connect_sync (SNAPD_CLIENT (getClient ()), G_CANCELLABLE (getCancellable ()), &error);
1471+ finish (error);
1472+}
1473+
1474+void QSnapdConnectRequest::handleResult (void *object, void *result)
1475+{
1476+ g_autoptr(GError) error = NULL;
1477+ snapd_client_connect_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1478+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1479+ return;
1480+
1481+ finish (error);
1482+}
1483+
1484+static void connect_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1485+{
1486+ QSnapdGetSystemInformationRequest *request = static_cast<QSnapdGetSystemInformationRequest*>(data);
1487+ request->handleResult (object, result);
1488+}
1489+
1490+void QSnapdConnectRequest::runAsync ()
1491+{
1492+ snapd_client_connect_async (SNAPD_CLIENT (getClient ()), G_CANCELLABLE (getCancellable ()), connect_ready_cb, (gpointer) this);
1493+}
1494+
1495+QSnapdLoginRequest::QSnapdLoginRequest (void *snapd_client, const QString& username, const QString& password, const QString& otp, QObject *parent) :
1496+ QSnapdRequest (snapd_client, parent),
1497+ d_ptr (new QSnapdLoginRequestPrivate(username, password, otp))
1498+{
1499+}
1500+
1501+void QSnapdLoginRequest::runSync ()
1502+{
1503+ Q_D(QSnapdLoginRequest);
1504+ g_autoptr(GError) error = NULL;
1505+ if (getClient () != NULL)
1506+ snapd_client_login_sync (SNAPD_CLIENT (getClient ()), d->username.toStdString ().c_str (), d->password.toStdString ().c_str (), d->otp.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), &error);
1507+ else
1508+ snapd_login_sync (d->username.toStdString ().c_str (), d->password.toStdString ().c_str (), d->otp.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), &error);
1509+ finish (error);
1510+}
1511+
1512+void QSnapdLoginRequest::handleResult (void *object, void *result)
1513+{
1514+ g_autoptr(SnapdAuthData) auth_data = NULL;
1515+ g_autoptr(GError) error = NULL;
1516+ auth_data = snapd_client_login_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1517+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1518+ return;
1519+
1520+ Q_D(QSnapdLoginRequest);
1521+ d->auth_data = (SnapdAuthData*) g_steal_pointer (&auth_data);
1522+ finish (error);
1523+}
1524+
1525+static void login_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1526+{
1527+ QSnapdLoginRequest *request = static_cast<QSnapdLoginRequest*>(data);
1528+ request->handleResult (object, result);
1529+}
1530+
1531+void QSnapdLoginRequest::runAsync ()
1532+{
1533+ Q_D(QSnapdLoginRequest);
1534+ if (getClient () != NULL)
1535+ snapd_client_login_async (SNAPD_CLIENT (getClient ()), d->username.toStdString ().c_str (), d->password.toStdString ().c_str (), d->otp.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), login_ready_cb, (gpointer) this);
1536+ else
1537+ snapd_login_async (d->username.toStdString ().c_str (), d->password.toStdString ().c_str (), d->otp.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), login_ready_cb, (gpointer) this);
1538+}
1539+
1540+QSnapdGetSystemInformationRequest::QSnapdGetSystemInformationRequest (void *snapd_client, QObject *parent) :
1541+ QSnapdRequest (snapd_client, parent),
1542+ d_ptr (new QSnapdGetSystemInformationRequestPrivate ()) {}
1543+
1544+void QSnapdGetSystemInformationRequest::runSync ()
1545+{
1546+ Q_D(QSnapdGetSystemInformationRequest);
1547+ g_autoptr(GError) error = NULL;
1548+ d->info = snapd_client_get_system_information_sync (SNAPD_CLIENT (getClient ()), G_CANCELLABLE (getCancellable ()), &error);
1549+ finish (error);
1550+}
1551+
1552+void QSnapdGetSystemInformationRequest::handleResult (void *object, void *result)
1553+{
1554+ g_autoptr(SnapdSystemInformation) info = NULL;
1555+ g_autoptr(GError) error = NULL;
1556+ info = snapd_client_get_system_information_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1557+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1558+ return;
1559+
1560+ Q_D(QSnapdGetSystemInformationRequest);
1561+ d->info = (SnapdSystemInformation*) g_steal_pointer (&info);
1562+ finish (error);
1563+}
1564+
1565+static void system_information_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1566+{
1567+ QSnapdGetSystemInformationRequest *request = static_cast<QSnapdGetSystemInformationRequest*>(data);
1568+ request->handleResult (object, result);
1569+}
1570+
1571+void QSnapdGetSystemInformationRequest::runAsync ()
1572+{
1573+ snapd_client_get_system_information_async (SNAPD_CLIENT (getClient ()), G_CANCELLABLE (getCancellable ()), system_information_ready_cb, (gpointer) this);
1574+}
1575+
1576+QSnapdSystemInformation *QSnapdGetSystemInformationRequest::systemInformation ()
1577+{
1578+ Q_D(QSnapdGetSystemInformationRequest);
1579+ return new QSnapdSystemInformation (d->info);
1580+}
1581+
1582+QSnapdListRequest::QSnapdListRequest (void *snapd_client, QObject *parent) :
1583+ QSnapdRequest (snapd_client, parent),
1584+ d_ptr (new QSnapdListRequestPrivate ()) {}
1585+
1586+void QSnapdListRequest::runSync ()
1587+{
1588+ Q_D(QSnapdListRequest);
1589+ g_autoptr(GError) error = NULL;
1590+ d->snaps = snapd_client_list_sync (SNAPD_CLIENT (getClient ()), G_CANCELLABLE (getCancellable ()), &error);
1591+ finish (error);
1592+}
1593+
1594+void QSnapdListRequest::handleResult (void *object, void *result)
1595+{
1596+ g_autoptr(GPtrArray) snaps = NULL;
1597+ g_autoptr(GError) error = NULL;
1598+ snaps = snapd_client_list_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1599+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1600+ return;
1601+
1602+ Q_D(QSnapdListRequest);
1603+ d->snaps = (GPtrArray*) g_steal_pointer (&snaps);
1604+ finish (error);
1605+}
1606+
1607+static void list_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1608+{
1609+ QSnapdListRequest *request = static_cast<QSnapdListRequest*>(data);
1610+ request->handleResult (object, result);
1611+}
1612+
1613+void QSnapdListRequest::runAsync ()
1614+{
1615+ snapd_client_list_async (SNAPD_CLIENT (getClient ()), G_CANCELLABLE (getCancellable ()), list_ready_cb, (gpointer) this);
1616+}
1617+
1618+int QSnapdListRequest::snapCount () const
1619+{
1620+ Q_D(const QSnapdListRequest);
1621+ return d->snaps != NULL ? d->snaps->len : 0;
1622+}
1623+
1624+QSnapdSnap *QSnapdListRequest::snap (int n) const
1625+{
1626+ Q_D(const QSnapdListRequest);
1627+ if (d->snaps == NULL || n < 0 || (guint) n >= d->snaps->len)
1628+ return NULL;
1629+ return new QSnapdSnap (d->snaps->pdata[n]);
1630+}
1631+
1632+QSnapdListOneRequest::QSnapdListOneRequest (const QString& name, void *snapd_client, QObject *parent) :
1633+ QSnapdRequest (snapd_client, parent),
1634+ d_ptr (new QSnapdListOneRequestPrivate (name)) {}
1635+
1636+void QSnapdListOneRequest::runSync ()
1637+{
1638+ Q_D(QSnapdListOneRequest);
1639+ g_autoptr(GError) error = NULL;
1640+ d->snap = snapd_client_list_one_sync (SNAPD_CLIENT (getClient ()), d->name.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), &error);
1641+ finish (error);
1642+}
1643+
1644+void QSnapdListOneRequest::handleResult (void *object, void *result)
1645+{
1646+ g_autoptr(SnapdSnap) snap = NULL;
1647+ g_autoptr(GError) error = NULL;
1648+ snap = snapd_client_list_one_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1649+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1650+ return;
1651+
1652+ Q_D(QSnapdListOneRequest);
1653+ d->snap = (SnapdSnap*) g_steal_pointer (&snap);
1654+ finish (error);
1655+}
1656+
1657+static void list_one_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1658+{
1659+ QSnapdListOneRequest *request = static_cast<QSnapdListOneRequest*>(data);
1660+ request->handleResult (object, result);
1661+}
1662+
1663+void QSnapdListOneRequest::runAsync ()
1664+{
1665+ Q_D(QSnapdListOneRequest);
1666+ snapd_client_list_one_async (SNAPD_CLIENT (getClient ()), d->name.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), list_one_ready_cb, (gpointer) this);
1667+}
1668+
1669+QSnapdSnap *QSnapdListOneRequest::snap () const
1670+{
1671+ Q_D(const QSnapdListOneRequest);
1672+ return new QSnapdSnap (d->snap);
1673+}
1674+
1675+QSnapdGetIconRequest::QSnapdGetIconRequest (const QString& name, void *snapd_client, QObject *parent) :
1676+ QSnapdRequest (snapd_client, parent),
1677+ d_ptr (new QSnapdGetIconRequestPrivate (name)) {}
1678+
1679+void QSnapdGetIconRequest::runSync ()
1680+{
1681+ Q_D(QSnapdGetIconRequest);
1682+ g_autoptr(GError) error = NULL;
1683+ d->icon = snapd_client_get_icon_sync (SNAPD_CLIENT (getClient ()), d->name.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), &error);
1684+ finish (error);
1685+}
1686+
1687+void QSnapdGetIconRequest::handleResult (void *object, void *result)
1688+{
1689+ g_autoptr(SnapdIcon) icon = NULL;
1690+ g_autoptr(GError) error = NULL;
1691+ icon = snapd_client_get_icon_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1692+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1693+ return;
1694+
1695+ Q_D(QSnapdGetIconRequest);
1696+ d->icon = (SnapdIcon*) g_steal_pointer (&icon);
1697+ finish (error);
1698+}
1699+
1700+static void get_icon_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1701+{
1702+ QSnapdGetIconRequest *request = static_cast<QSnapdGetIconRequest*>(data);
1703+ request->handleResult (object, result);
1704+}
1705+
1706+void QSnapdGetIconRequest::runAsync ()
1707+{
1708+ Q_D(QSnapdGetIconRequest);
1709+ snapd_client_get_icon_async (SNAPD_CLIENT (getClient ()), d->name.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), get_icon_ready_cb, (gpointer) this);
1710+}
1711+
1712+QSnapdIcon *QSnapdGetIconRequest::icon () const
1713+{
1714+ Q_D(const QSnapdGetIconRequest);
1715+ return new QSnapdIcon (d->icon);
1716+}
1717+
1718+QSnapdGetInterfacesRequest::QSnapdGetInterfacesRequest (void *snapd_client, QObject *parent) :
1719+ QSnapdRequest (snapd_client, parent),
1720+ d_ptr (new QSnapdGetInterfacesRequestPrivate ()) {}
1721+
1722+void QSnapdGetInterfacesRequest::runSync ()
1723+{
1724+ Q_D(QSnapdGetInterfacesRequest);
1725+ g_autoptr(GError) error = NULL;
1726+ snapd_client_get_interfaces_sync (SNAPD_CLIENT (getClient ()), &d->plugs, &d->slots_, G_CANCELLABLE (getCancellable ()), &error);
1727+ finish (error);
1728+}
1729+
1730+void QSnapdGetInterfacesRequest::handleResult (void *object, void *result)
1731+{
1732+ g_autoptr(GPtrArray) plugs = NULL;
1733+ g_autoptr(GPtrArray) slots_ = NULL;
1734+ g_autoptr(GError) error = NULL;
1735+ snapd_client_get_interfaces_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &plugs, &slots_, &error);
1736+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1737+ return;
1738+
1739+ Q_D(QSnapdGetInterfacesRequest);
1740+ d->plugs = (GPtrArray*) g_steal_pointer (&plugs);
1741+ d->slots_ = (GPtrArray*) g_steal_pointer (&slots_);
1742+ finish (error);
1743+}
1744+
1745+static void get_interfaces_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1746+{
1747+ QSnapdGetInterfacesRequest *request = static_cast<QSnapdGetInterfacesRequest*>(data);
1748+ request->handleResult (object, result);
1749+}
1750+
1751+void QSnapdGetInterfacesRequest::runAsync ()
1752+{
1753+ snapd_client_get_interfaces_async (SNAPD_CLIENT (getClient ()), G_CANCELLABLE (getCancellable ()), get_interfaces_ready_cb, (gpointer) this);
1754+}
1755+
1756+int QSnapdGetInterfacesRequest::plugCount () const
1757+{
1758+ Q_D(const QSnapdGetInterfacesRequest);
1759+ return d->plugs != NULL ? d->plugs->len : 0;
1760+}
1761+
1762+QSnapdConnection *QSnapdGetInterfacesRequest::plug (int n) const
1763+{
1764+ Q_D(const QSnapdGetInterfacesRequest);
1765+ if (d->plugs == NULL || n < 0 || (guint) n >= d->plugs->len)
1766+ return NULL;
1767+ return new QSnapdConnection (d->plugs->pdata[n]);
1768+}
1769+
1770+int QSnapdGetInterfacesRequest::slotCount () const
1771+{
1772+ Q_D(const QSnapdGetInterfacesRequest);
1773+ return d->slots_ != NULL ? d->slots_->len : 0;
1774+}
1775+
1776+QSnapdConnection *QSnapdGetInterfacesRequest::slot (int n) const
1777+{
1778+ Q_D(const QSnapdGetInterfacesRequest);
1779+ if (d->slots_ == NULL || n < 0 || (guint) n >= d->slots_->len)
1780+ return NULL;
1781+ return new QSnapdConnection (d->slots_->pdata[n]);
1782+}
1783+
1784+QSnapdConnectInterfaceRequest::QSnapdConnectInterfaceRequest (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name, void *snapd_client, QObject *parent) :
1785+ QSnapdRequest (snapd_client, parent),
1786+ d_ptr (new QSnapdConnectInterfaceRequestPrivate (plug_snap, plug_name, slot_snap, slot_name)) {}
1787+
1788+static void progress_cb (SnapdClient *client, SnapdTask *main_task, GPtrArray *tasks, gpointer data)
1789+{
1790+ QSnapdRequest *request = static_cast<QSnapdRequest*>(data);
1791+ request->handleProgress (main_task, tasks);
1792+}
1793+
1794+void QSnapdConnectInterfaceRequest::runSync ()
1795+{
1796+ Q_D(QSnapdConnectInterfaceRequest);
1797+ g_autoptr(GPtrArray) plugs = NULL;
1798+ g_autoptr(GPtrArray) slots_ = NULL;
1799+ g_autoptr(GError) error = NULL;
1800+ snapd_client_connect_interface_sync (SNAPD_CLIENT (getClient ()),
1801+ d->plug_snap.toStdString ().c_str (), d->plug_name.toStdString ().c_str (),
1802+ d->slot_snap.toStdString ().c_str (), d->slot_name.toStdString ().c_str (),
1803+ progress_cb, this,
1804+ G_CANCELLABLE (getCancellable ()), &error);
1805+ finish (error);
1806+}
1807+
1808+void QSnapdConnectInterfaceRequest::handleResult (void *object, void *result)
1809+{
1810+ g_autoptr(GError) error = NULL;
1811+ snapd_client_connect_interface_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1812+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1813+ return;
1814+
1815+ finish (error);
1816+}
1817+
1818+static void connect_interface_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1819+{
1820+ QSnapdConnectInterfaceRequest *request = static_cast<QSnapdConnectInterfaceRequest*>(data);
1821+ request->handleResult (object, result);
1822+}
1823+
1824+void QSnapdConnectInterfaceRequest::runAsync ()
1825+{
1826+ Q_D(QSnapdConnectInterfaceRequest);
1827+ snapd_client_connect_interface_async (SNAPD_CLIENT (getClient ()),
1828+ d->plug_snap.toStdString ().c_str (), d->plug_name.toStdString ().c_str (),
1829+ d->slot_snap.toStdString ().c_str (), d->slot_name.toStdString ().c_str (),
1830+ progress_cb, this,
1831+ G_CANCELLABLE (getCancellable ()), connect_interface_ready_cb, (gpointer) this);
1832+}
1833+
1834+QSnapdDisconnectInterfaceRequest::QSnapdDisconnectInterfaceRequest (const QString &plug_snap, const QString &plug_name, const QString &slot_snap, const QString &slot_name, void *snapd_client, QObject *parent) :
1835+ QSnapdRequest (snapd_client, parent),
1836+ d_ptr (new QSnapdDisconnectInterfaceRequestPrivate (plug_snap, plug_name, slot_snap, slot_name)) {}
1837+
1838+void QSnapdDisconnectInterfaceRequest::runSync ()
1839+{
1840+ Q_D(QSnapdDisconnectInterfaceRequest);
1841+ g_autoptr(GPtrArray) plugs = NULL;
1842+ g_autoptr(GPtrArray) slots_ = NULL;
1843+ g_autoptr(GError) error = NULL;
1844+ snapd_client_disconnect_interface_sync (SNAPD_CLIENT (getClient ()),
1845+ d->plug_snap.toStdString ().c_str (), d->plug_name.toStdString ().c_str (),
1846+ d->slot_snap.toStdString ().c_str (), d->slot_name.toStdString ().c_str (),
1847+ progress_cb, this,
1848+ G_CANCELLABLE (getCancellable ()), &error);
1849+ finish (error);
1850+}
1851+
1852+void QSnapdDisconnectInterfaceRequest::handleResult (void *object, void *result)
1853+{
1854+ g_autoptr(GError) error = NULL;
1855+ snapd_client_disconnect_interface_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1856+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1857+ return;
1858+
1859+ finish (error);
1860+}
1861+
1862+static void disconnect_interface_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1863+{
1864+ QSnapdDisconnectInterfaceRequest *request = static_cast<QSnapdDisconnectInterfaceRequest*>(data);
1865+ request->handleResult (object, result);
1866+}
1867+
1868+void QSnapdDisconnectInterfaceRequest::runAsync ()
1869+{
1870+ Q_D(QSnapdDisconnectInterfaceRequest);
1871+ snapd_client_disconnect_interface_async (SNAPD_CLIENT (getClient ()),
1872+ d->plug_snap.toStdString ().c_str (), d->plug_name.toStdString ().c_str (),
1873+ d->slot_snap.toStdString ().c_str (), d->slot_name.toStdString ().c_str (),
1874+ progress_cb, this,
1875+ G_CANCELLABLE (getCancellable ()), disconnect_interface_ready_cb, (gpointer) this);
1876+}
1877+
1878+static SnapdFindFlags convertFindFlags (int flags)
1879+{
1880+ int result = SNAPD_FIND_FLAGS_NONE;
1881+
1882+ if ((flags & QSnapdClient::FindFlag::MatchName) != 0)
1883+ result |= SNAPD_FIND_FLAGS_MATCH_NAME;
1884+ if ((flags & QSnapdClient::FindFlag::SelectPrivate) != 0)
1885+ result |= SNAPD_FIND_FLAGS_SELECT_PRIVATE;
1886+ if ((flags & QSnapdClient::FindFlag::SelectRefresh) != 0)
1887+ result |= SNAPD_FIND_FLAGS_SELECT_REFRESH;
1888+
1889+ return (SnapdFindFlags) result;
1890+}
1891+
1892+QSnapdFindRequest::QSnapdFindRequest (int flags, const QString& name, void *snapd_client, QObject *parent) :
1893+ QSnapdRequest (snapd_client, parent),
1894+ d_ptr (new QSnapdFindRequestPrivate (flags, name)) {}
1895+
1896+void QSnapdFindRequest::runSync ()
1897+{
1898+ Q_D(QSnapdFindRequest);
1899+ g_autoptr(GError) error = NULL;
1900+ g_autofree gchar *suggested_currency = NULL;
1901+ d->snaps = snapd_client_find_sync (SNAPD_CLIENT (getClient ()), convertFindFlags (d->flags), d->name.toStdString ().c_str (), &suggested_currency, G_CANCELLABLE (getCancellable ()), &error);
1902+ d->suggestedCurrency = suggested_currency;
1903+ finish (error);
1904+}
1905+
1906+void QSnapdFindRequest::handleResult (void *object, void *result)
1907+{
1908+ g_autoptr(GPtrArray) snaps = NULL;
1909+ g_autofree gchar *suggested_currency = NULL;
1910+ g_autoptr(GError) error = NULL;
1911+ snaps = snapd_client_find_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &suggested_currency, &error);
1912+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1913+ return;
1914+
1915+ Q_D(QSnapdFindRequest);
1916+ d->snaps = (GPtrArray*) g_steal_pointer (&snaps);
1917+ d->suggestedCurrency = suggested_currency;
1918+ finish (error);
1919+}
1920+
1921+static void find_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1922+{
1923+ QSnapdFindRequest *request = static_cast<QSnapdFindRequest*>(data);
1924+ request->handleResult (object, result);
1925+}
1926+
1927+void QSnapdFindRequest::runAsync ()
1928+{
1929+ Q_D(QSnapdFindRequest);
1930+ snapd_client_find_async (SNAPD_CLIENT (getClient ()), convertFindFlags (d->flags), d->name.toStdString ().c_str (), G_CANCELLABLE (getCancellable ()), find_ready_cb, (gpointer) this);
1931+}
1932+
1933+int QSnapdFindRequest::snapCount () const
1934+{
1935+ Q_D(const QSnapdFindRequest);
1936+ return d->snaps != NULL ? d->snaps->len : 0;
1937+}
1938+
1939+QSnapdSnap *QSnapdFindRequest::snap (int n) const
1940+{
1941+ Q_D(const QSnapdFindRequest);
1942+ if (d->snaps == NULL || n < 0 || (guint) n >= d->snaps->len)
1943+ return NULL;
1944+ return new QSnapdSnap (d->snaps->pdata[n]);
1945+}
1946+
1947+const QString QSnapdFindRequest::suggestedCurrency () const
1948+{
1949+ Q_D(const QSnapdFindRequest);
1950+ return d->suggestedCurrency;
1951+}
1952+
1953+QSnapdInstallRequest::QSnapdInstallRequest (const QString& name, const QString& channel, void *snapd_client, QObject *parent) :
1954+ QSnapdRequest (snapd_client, parent),
1955+ d_ptr (new QSnapdInstallRequestPrivate (name, channel)) {}
1956+
1957+void QSnapdInstallRequest::runSync ()
1958+{
1959+ Q_D(QSnapdInstallRequest);
1960+ g_autoptr(GError) error = NULL;
1961+ snapd_client_install_sync (SNAPD_CLIENT (getClient ()),
1962+ d->name.toStdString ().c_str (), d->channel.toStdString ().c_str (),
1963+ progress_cb, this,
1964+ G_CANCELLABLE (getCancellable ()), &error);
1965+ finish (error);
1966+}
1967+
1968+void QSnapdInstallRequest::handleResult (void *object, void *result)
1969+{
1970+ g_autoptr(GError) error = NULL;
1971+ snapd_client_install_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
1972+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
1973+ return;
1974+
1975+ finish (error);
1976+}
1977+
1978+static void install_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
1979+{
1980+ QSnapdInstallRequest *request = static_cast<QSnapdInstallRequest*>(data);
1981+ request->handleResult (object, result);
1982+}
1983+
1984+void QSnapdInstallRequest::runAsync ()
1985+{
1986+ Q_D(QSnapdInstallRequest);
1987+ snapd_client_install_async (SNAPD_CLIENT (getClient ()),
1988+ d->name.toStdString ().c_str (), d->channel.toStdString ().c_str (),
1989+ progress_cb, this,
1990+ G_CANCELLABLE (getCancellable ()), install_ready_cb, (gpointer) this);
1991+}
1992+
1993+QSnapdRefreshRequest::QSnapdRefreshRequest (const QString& name, const QString& channel, void *snapd_client, QObject *parent) :
1994+ QSnapdRequest (snapd_client, parent),
1995+ d_ptr (new QSnapdRefreshRequestPrivate (name, channel)) {}
1996+
1997+void QSnapdRefreshRequest::runSync ()
1998+{
1999+ Q_D(QSnapdRefreshRequest);
2000+ g_autoptr(GError) error = NULL;
2001+ snapd_client_refresh_sync (SNAPD_CLIENT (getClient ()),
2002+ d->name.toStdString ().c_str (), d->channel.toStdString ().c_str (),
2003+ progress_cb, this,
2004+ G_CANCELLABLE (getCancellable ()), &error);
2005+ finish (error);
2006+}
2007+
2008+void QSnapdRefreshRequest::handleResult (void *object, void *result)
2009+{
2010+ g_autoptr(GError) error = NULL;
2011+ snapd_client_refresh_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
2012+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
2013+ return;
2014+
2015+ finish (error);
2016+}
2017+
2018+static void refresh_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
2019+{
2020+ QSnapdRefreshRequest *request = static_cast<QSnapdRefreshRequest*>(data);
2021+ request->handleResult (object, result);
2022+}
2023+
2024+void QSnapdRefreshRequest::runAsync ()
2025+{
2026+ Q_D(QSnapdRefreshRequest);
2027+ snapd_client_refresh_async (SNAPD_CLIENT (getClient ()),
2028+ d->name.toStdString ().c_str (), d->channel.toStdString ().c_str (),
2029+ progress_cb, this,
2030+ G_CANCELLABLE (getCancellable ()), refresh_ready_cb, (gpointer) this);
2031+}
2032+
2033+QSnapdRemoveRequest::QSnapdRemoveRequest (const QString& name, void *snapd_client, QObject *parent) :
2034+ QSnapdRequest (snapd_client, parent),
2035+ d_ptr (new QSnapdRemoveRequestPrivate (name)) {}
2036+
2037+void QSnapdRemoveRequest::runSync ()
2038+{
2039+ Q_D(QSnapdRemoveRequest);
2040+ g_autoptr(GError) error = NULL;
2041+ snapd_client_remove_sync (SNAPD_CLIENT (getClient ()),
2042+ d->name.toStdString ().c_str (),
2043+ progress_cb, this,
2044+ G_CANCELLABLE (getCancellable ()), &error);
2045+ finish (error);
2046+}
2047+
2048+void QSnapdRemoveRequest::handleResult (void *object, void *result)
2049+{
2050+ g_autoptr(GError) error = NULL;
2051+ snapd_client_remove_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
2052+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
2053+ return;
2054+
2055+ finish (error);
2056+}
2057+
2058+static void remove_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
2059+{
2060+ QSnapdRemoveRequest *request = static_cast<QSnapdRemoveRequest*>(data);
2061+ request->handleResult (object, result);
2062+}
2063+
2064+void QSnapdRemoveRequest::runAsync ()
2065+{
2066+ Q_D(QSnapdRemoveRequest);
2067+ snapd_client_remove_async (SNAPD_CLIENT (getClient ()),
2068+ d->name.toStdString ().c_str (),
2069+ progress_cb, this,
2070+ G_CANCELLABLE (getCancellable ()), remove_ready_cb, (gpointer) this);
2071+}
2072+
2073+QSnapdEnableRequest::QSnapdEnableRequest (const QString& name, void *snapd_client, QObject *parent) :
2074+ QSnapdRequest (snapd_client, parent),
2075+ d_ptr (new QSnapdEnableRequestPrivate (name)) {}
2076+
2077+void QSnapdEnableRequest::runSync ()
2078+{
2079+ Q_D(QSnapdEnableRequest);
2080+ g_autoptr(GError) error = NULL;
2081+ snapd_client_enable_sync (SNAPD_CLIENT (getClient ()),
2082+ d->name.toStdString ().c_str (),
2083+ progress_cb, this,
2084+ G_CANCELLABLE (getCancellable ()), &error);
2085+ finish (error);
2086+}
2087+
2088+void QSnapdEnableRequest::handleResult (void *object, void *result)
2089+{
2090+ g_autoptr(GError) error = NULL;
2091+ snapd_client_enable_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
2092+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
2093+ return;
2094+
2095+ finish (error);
2096+}
2097+
2098+static void enable_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
2099+{
2100+ QSnapdEnableRequest *request = static_cast<QSnapdEnableRequest*>(data);
2101+ request->handleResult (object, result);
2102+}
2103+
2104+void QSnapdEnableRequest::runAsync ()
2105+{
2106+ Q_D(QSnapdEnableRequest);
2107+ snapd_client_enable_async (SNAPD_CLIENT (getClient ()),
2108+ d->name.toStdString ().c_str (),
2109+ progress_cb, this,
2110+ G_CANCELLABLE (getCancellable ()), enable_ready_cb, (gpointer) this);
2111+}
2112+
2113+QSnapdDisableRequest::QSnapdDisableRequest (const QString& name, void *snapd_client, QObject *parent) :
2114+ QSnapdRequest (snapd_client, parent),
2115+ d_ptr (new QSnapdDisableRequestPrivate (name)) {}
2116+
2117+void QSnapdDisableRequest::runSync ()
2118+{
2119+ Q_D(QSnapdDisableRequest);
2120+ g_autoptr(GError) error = NULL;
2121+ snapd_client_disable_sync (SNAPD_CLIENT (getClient ()),
2122+ d->name.toStdString ().c_str (),
2123+ progress_cb, this,
2124+ G_CANCELLABLE (getCancellable ()), &error);
2125+ finish (error);
2126+}
2127+
2128+void QSnapdDisableRequest::handleResult (void *object, void *result)
2129+{
2130+ g_autoptr(GError) error = NULL;
2131+ snapd_client_disable_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
2132+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
2133+ return;
2134+
2135+ finish (error);
2136+}
2137+
2138+static void disable_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
2139+{
2140+ QSnapdDisableRequest *request = static_cast<QSnapdDisableRequest*>(data);
2141+ request->handleResult (object, result);
2142+}
2143+
2144+void QSnapdDisableRequest::runAsync ()
2145+{
2146+ Q_D(QSnapdDisableRequest);
2147+ snapd_client_disable_async (SNAPD_CLIENT (getClient ()),
2148+ d->name.toStdString ().c_str (),
2149+ progress_cb, this,
2150+ G_CANCELLABLE (getCancellable ()), disable_ready_cb, (gpointer) this);
2151+}
2152+
2153+QSnapdCheckBuyRequest::QSnapdCheckBuyRequest (void *snapd_client, QObject *parent):
2154+ QSnapdRequest (snapd_client, parent),
2155+ d_ptr (new QSnapdCheckBuyRequestPrivate ()) {}
2156+
2157+void QSnapdCheckBuyRequest::runSync ()
2158+{
2159+ Q_D(QSnapdCheckBuyRequest);
2160+ g_autoptr(GError) error = NULL;
2161+ d->canBuy = snapd_client_check_buy_sync (SNAPD_CLIENT (getClient ()),
2162+ G_CANCELLABLE (getCancellable ()), &error);
2163+ finish (error);
2164+}
2165+
2166+void QSnapdCheckBuyRequest::handleResult (void *object, void *result)
2167+{
2168+ gboolean can_buy;
2169+ g_autoptr(GError) error = NULL;
2170+ can_buy = snapd_client_check_buy_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
2171+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
2172+ return;
2173+
2174+ Q_D(QSnapdCheckBuyRequest);
2175+ d->canBuy = can_buy;
2176+ finish (error);
2177+}
2178+
2179+static void check_buy_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
2180+{
2181+ QSnapdCheckBuyRequest *request = static_cast<QSnapdCheckBuyRequest*>(data);
2182+ request->handleResult (object, result);
2183+}
2184+
2185+void QSnapdCheckBuyRequest::runAsync ()
2186+{
2187+ snapd_client_check_buy_async (SNAPD_CLIENT (getClient ()),
2188+ G_CANCELLABLE (getCancellable ()), check_buy_ready_cb, (gpointer) this);
2189+}
2190+
2191+bool QSnapdCheckBuyRequest::canBuy () const
2192+{
2193+ Q_D(const QSnapdCheckBuyRequest);
2194+ return d->canBuy;
2195+}
2196+
2197+QSnapdBuyRequest::QSnapdBuyRequest (const QString& id, double amount, const QString& currency, void *snapd_client, QObject *parent) :
2198+ QSnapdRequest (snapd_client, parent),
2199+ d_ptr (new QSnapdBuyRequestPrivate (id, amount, currency)) {}
2200+
2201+void QSnapdBuyRequest::runSync ()
2202+{
2203+ Q_D(QSnapdBuyRequest);
2204+ g_autoptr(GError) error = NULL;
2205+ snapd_client_buy_sync (SNAPD_CLIENT (getClient ()),
2206+ d->id.toStdString ().c_str (), d->amount, d->currency.toStdString ().c_str (),
2207+ G_CANCELLABLE (getCancellable ()), &error);
2208+ finish (error);
2209+}
2210+
2211+void QSnapdBuyRequest::handleResult (void *object, void *result)
2212+{
2213+ g_autoptr(GError) error = NULL;
2214+ snapd_client_buy_finish (SNAPD_CLIENT (object), G_ASYNC_RESULT (result), &error);
2215+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
2216+ return;
2217+
2218+ finish (error);
2219+}
2220+
2221+static void buy_ready_cb (GObject *object, GAsyncResult *result, gpointer data)
2222+{
2223+ QSnapdBuyRequest *request = static_cast<QSnapdBuyRequest*>(data);
2224+ request->handleResult (object, result);
2225+}
2226+
2227+void QSnapdBuyRequest::runAsync ()
2228+{
2229+ Q_D(QSnapdBuyRequest);
2230+ snapd_client_buy_async (SNAPD_CLIENT (getClient ()),
2231+ d->id.toStdString ().c_str (), d->amount, d->currency.toStdString ().c_str (),
2232+ G_CANCELLABLE (getCancellable ()), buy_ready_cb, (gpointer) this);
2233+}
2234
2235=== added file 'snapd-qt/connection.cpp'
2236--- snapd-qt/connection.cpp 1970-01-01 00:00:00 +0000
2237+++ snapd-qt/connection.cpp 2017-01-24 04:26:53 +0000
2238@@ -0,0 +1,24 @@
2239+/*
2240+ * Copyright (C) 2016 Canonical Ltd.
2241+ *
2242+ * This library is free software; you can redistribute it and/or modify it under
2243+ * the terms of the GNU Lesser General Public License as published by the Free
2244+ * Software Foundation; either version 2 or version 3 of the License.
2245+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2246+ */
2247+
2248+#include <snapd-glib/snapd-glib.h>
2249+
2250+#include "Snapd/connection.h"
2251+
2252+QSnapdConnection::QSnapdConnection (void *snapd_object, QObject *parent) : QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
2253+
2254+QString QSnapdConnection::name () const
2255+{
2256+ return snapd_connection_get_name (SNAPD_CONNECTION (wrapped_object));
2257+}
2258+
2259+QString QSnapdConnection::snap () const
2260+{
2261+ return snapd_connection_get_snap (SNAPD_CONNECTION (wrapped_object));
2262+}
2263
2264=== added file 'snapd-qt/icon.cpp'
2265--- snapd-qt/icon.cpp 1970-01-01 00:00:00 +0000
2266+++ snapd-qt/icon.cpp 2017-01-24 04:26:53 +0000
2267@@ -0,0 +1,27 @@
2268+/*
2269+ * Copyright (C) 2016 Canonical Ltd.
2270+ *
2271+ * This library is free software; you can redistribute it and/or modify it under
2272+ * the terms of the GNU Lesser General Public License as published by the Free
2273+ * Software Foundation; either version 2 or version 3 of the License.
2274+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2275+ */
2276+
2277+#include <snapd-glib/snapd-glib.h>
2278+
2279+#include "Snapd/icon.h"
2280+
2281+QSnapdIcon::QSnapdIcon (void *snapd_object, QObject *parent) : QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
2282+
2283+QString QSnapdIcon::mimeType () const
2284+{
2285+ return snapd_icon_get_mime_type (SNAPD_ICON (wrapped_object));
2286+}
2287+
2288+QByteArray QSnapdIcon::data () const
2289+{
2290+ GBytes *data = snapd_icon_get_data (SNAPD_ICON (wrapped_object));
2291+ gsize length;
2292+ gchar *raw_data = (gchar *) g_bytes_get_data (data, &length);
2293+ return QByteArray::fromRawData (raw_data, length);
2294+}
2295
2296=== added file 'snapd-qt/price.cpp'
2297--- snapd-qt/price.cpp 1970-01-01 00:00:00 +0000
2298+++ snapd-qt/price.cpp 2017-01-24 04:26:53 +0000
2299@@ -0,0 +1,24 @@
2300+/*
2301+ * Copyright (C) 2016 Canonical Ltd.
2302+ *
2303+ * This library is free software; you can redistribute it and/or modify it under
2304+ * the terms of the GNU Lesser General Public License as published by the Free
2305+ * Software Foundation; either version 2 or version 3 of the License.
2306+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2307+ */
2308+
2309+#include <snapd-glib/snapd-glib.h>
2310+
2311+#include "Snapd/price.h"
2312+
2313+QSnapdPrice::QSnapdPrice (void *snapd_object, QObject *parent) : QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
2314+
2315+double QSnapdPrice::amount () const
2316+{
2317+ return snapd_price_get_amount (SNAPD_PRICE (wrapped_object));
2318+}
2319+
2320+QString QSnapdPrice::currency () const
2321+{
2322+ return snapd_price_get_currency (SNAPD_PRICE (wrapped_object));
2323+}
2324
2325=== added file 'snapd-qt/qml-plugin.cpp'
2326--- snapd-qt/qml-plugin.cpp 1970-01-01 00:00:00 +0000
2327+++ snapd-qt/qml-plugin.cpp 2017-01-24 04:26:53 +0000
2328@@ -0,0 +1,41 @@
2329+/*
2330+ * Copyright (C) 2016 Canonical, Ltd.
2331+ *
2332+ * This library is free software; you can redistribute it and/or modify it under
2333+ * the terms of the GNU Lesser General Public License as published by the Free
2334+ * Software Foundation; either version 2 or version 3 of the License.
2335+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2336+ */
2337+
2338+#include <QtQml/QtQml>
2339+#include <Snapd/Client>
2340+#include "qml-plugin.h"
2341+
2342+void SnapdQmlPlugin::registerTypes(const char *uri)
2343+{
2344+ Q_ASSERT(uri == QLatin1String("Snapd"));
2345+ qmlRegisterType<QSnapdClient>(uri, 1, 0, "SnapdClient");
2346+ qmlRegisterType<QSnapdAuthData>(uri, 1, 0, "SnapdAuthData");
2347+ qmlRegisterUncreatableType<QSnapdIcon>(uri, 1, 0, "SnapdIcon", "Can't create");
2348+ qmlRegisterUncreatableType<QSnapdConnection>(uri, 1, 0, "SnapdConnection", "Can't create");
2349+ qmlRegisterUncreatableType<QSnapdSnap>(uri, 1, 0, "SnapdSnap", "Can't create");
2350+ qmlRegisterUncreatableType<QSnapdSystemInformation>(uri, 1, 0, "SnapdSystemInformation", "Can't create");
2351+ qmlRegisterUncreatableType<QSnapdRequest>(uri, 1, 0, "SnapdRequest", "Can't create");
2352+ qmlRegisterUncreatableType<QSnapdConnectRequest>(uri, 1, 0, "SnapdConnectRequest", "Can't create");
2353+ qmlRegisterUncreatableType<QSnapdLoginRequest>(uri, 1, 0, "SnapdLoginRequest", "Can't create");
2354+ qmlRegisterUncreatableType<QSnapdGetSystemInformationRequest>(uri, 1, 0, "SnapdGetSystemInformationRequest", "Can't create");
2355+ qmlRegisterUncreatableType<QSnapdListRequest>(uri, 1, 0, "SnapdListRequest", "Can't create");
2356+ qmlRegisterUncreatableType<QSnapdListOneRequest>(uri, 1, 0, "SnapdListOneRequest", "Can't create");
2357+ qmlRegisterUncreatableType<QSnapdGetIconRequest>(uri, 1, 0, "SnapdGetIconRequest", "Can't create");
2358+ qmlRegisterUncreatableType<QSnapdGetInterfacesRequest>(uri, 1, 0, "SnapdGetInterfacesRequest", "Can't create");
2359+ qmlRegisterUncreatableType<QSnapdConnectInterfaceRequest>(uri, 1, 0, "SnapdConnectInterfaceRequest", "Can't create");
2360+ qmlRegisterUncreatableType<QSnapdDisconnectInterfaceRequest>(uri, 1, 0, "SnapdDisconnectInterfaceRequest", "Can't create");
2361+ qmlRegisterUncreatableType<QSnapdFindRequest>(uri, 1, 0, "SnapdFindRequest", "Can't create");
2362+ qmlRegisterUncreatableType<QSnapdInstallRequest>(uri, 1, 0, "SnapdInstallRequest", "Can't create");
2363+ qmlRegisterUncreatableType<QSnapdRefreshRequest>(uri, 1, 0, "SnapdRefreshRequest", "Can't create");
2364+ qmlRegisterUncreatableType<QSnapdRemoveRequest>(uri, 1, 0, "SnapdRemoveRequest", "Can't create");
2365+ qmlRegisterUncreatableType<QSnapdEnableRequest>(uri, 1, 0, "SnapdEnableRequest", "Can't create");
2366+ qmlRegisterUncreatableType<QSnapdDisableRequest>(uri, 1, 0, "SnapdDisableRequest", "Can't create");
2367+ qmlRegisterUncreatableType<QSnapdCheckBuyRequest>(uri, 1, 0, "SnapdCheckBuyRequest", "Can't create");
2368+ qmlRegisterUncreatableType<QSnapdBuyRequest>(uri, 1, 0, "SnapdBuyRequest", "Can't create");
2369+}
2370
2371=== added file 'snapd-qt/qml-plugin.h'
2372--- snapd-qt/qml-plugin.h 1970-01-01 00:00:00 +0000
2373+++ snapd-qt/qml-plugin.h 2017-01-24 04:26:53 +0000
2374@@ -0,0 +1,24 @@
2375+/*
2376+ * Copyright (C) 2016 Canonical, Ltd.
2377+ *
2378+ * This library is free software; you can redistribute it and/or modify it under
2379+ * the terms of the GNU Lesser General Public License as published by the Free
2380+ * Software Foundation; either version 2 or version 3 of the License.
2381+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2382+ */
2383+
2384+#ifndef QML_PLUGIN_H
2385+#define QML_PLUGIN_H
2386+
2387+#include <QtQml/QQmlExtensionPlugin>
2388+
2389+class SnapdQmlPlugin : public QQmlExtensionPlugin
2390+{
2391+ Q_OBJECT
2392+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
2393+
2394+public:
2395+ void registerTypes(const char *uri);
2396+};
2397+
2398+#endif
2399
2400=== added file 'snapd-qt/qmldir'
2401--- snapd-qt/qmldir 1970-01-01 00:00:00 +0000
2402+++ snapd-qt/qmldir 2017-01-24 04:26:53 +0000
2403@@ -0,0 +1,2 @@
2404+module Snapd
2405+plugin Snapd
2406
2407=== added file 'snapd-qt/request.cpp'
2408--- snapd-qt/request.cpp 1970-01-01 00:00:00 +0000
2409+++ snapd-qt/request.cpp 2017-01-24 04:26:53 +0000
2410@@ -0,0 +1,176 @@
2411+/*
2412+ * Copyright (C) 2016 Canonical Ltd.
2413+ *
2414+ * This library is free software; you can redistribute it and/or modify it under
2415+ * the terms of the GNU Lesser General Public License as published by the Free
2416+ * Software Foundation; either version 2 or version 3 of the License.
2417+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2418+ */
2419+
2420+#include <snapd-glib/snapd-glib.h>
2421+
2422+#include "Snapd/request.h"
2423+
2424+struct QSnapdRequestPrivate
2425+{
2426+ QSnapdRequestPrivate (void *snapd_client)
2427+ {
2428+ client = SNAPD_CLIENT (g_object_ref (snapd_client));
2429+ cancellable = g_cancellable_new ();
2430+ }
2431+
2432+ ~QSnapdRequestPrivate ()
2433+ {
2434+ g_cancellable_cancel (cancellable);
2435+ g_object_unref (cancellable);
2436+ g_object_unref (client);
2437+ g_object_unref (main_task);
2438+ g_ptr_array_unref (tasks);
2439+ }
2440+
2441+ SnapdClient *client;
2442+ GCancellable *cancellable;
2443+ bool finished;
2444+ QSnapdRequest::QSnapdError error;
2445+ QString errorString;
2446+ SnapdTask *main_task;
2447+ GPtrArray *tasks;
2448+};
2449+
2450+QSnapdRequest::QSnapdRequest (void *snapd_client, QObject *parent) :
2451+ QObject (parent),
2452+ d_ptr (new QSnapdRequestPrivate (snapd_client)) {}
2453+
2454+void* QSnapdRequest::getClient () const
2455+{
2456+ Q_D(const QSnapdRequest);
2457+ return d->client;
2458+}
2459+
2460+void* QSnapdRequest::getCancellable () const
2461+{
2462+ Q_D(const QSnapdRequest);
2463+ return d->cancellable;
2464+}
2465+
2466+void QSnapdRequest::finish (void *error)
2467+{
2468+ Q_D(QSnapdRequest);
2469+
2470+ d->finished = true;
2471+ if (error == NULL) {
2472+ d->error = NoError;
2473+ d->errorString = "";
2474+ }
2475+ else {
2476+ GError *e = (GError *) error;
2477+ if (e->domain == SNAPD_ERROR) {
2478+ switch ((SnapdError) e->code)
2479+ {
2480+ case SNAPD_ERROR_CONNECTION_FAILED:
2481+ d->error = QSnapdRequest::QSnapdError::ConnectionFailed;
2482+ break;
2483+ case SNAPD_ERROR_WRITE_FAILED:
2484+ d->error = QSnapdRequest::QSnapdError::WriteFailed;
2485+ break;
2486+ case SNAPD_ERROR_READ_FAILED:
2487+ d->error = QSnapdRequest::QSnapdError::ReadFailed;
2488+ break;
2489+ case SNAPD_ERROR_BAD_REQUEST:
2490+ d->error = QSnapdRequest::QSnapdError::BadRequest;
2491+ break;
2492+ case SNAPD_ERROR_BAD_RESPONSE:
2493+ d->error = QSnapdRequest::QSnapdError::BadResponse;
2494+ break;
2495+ case SNAPD_ERROR_AUTH_DATA_REQUIRED:
2496+ d->error = QSnapdRequest::QSnapdError::AuthDataRequired;
2497+ break;
2498+ case SNAPD_ERROR_AUTH_DATA_INVALID:
2499+ d->error = QSnapdRequest::QSnapdError::AuthDataInvalid;
2500+ break;
2501+ case SNAPD_ERROR_TWO_FACTOR_REQUIRED:
2502+ d->error = QSnapdRequest::QSnapdError::TwoFactorRequired;
2503+ break;
2504+ case SNAPD_ERROR_TWO_FACTOR_INVALID:
2505+ d->error = QSnapdRequest::QSnapdError::TwoFactorInvalid;
2506+ break;
2507+ case SNAPD_ERROR_PERMISSION_DENIED:
2508+ d->error = QSnapdRequest::QSnapdError::PermissionDenied;
2509+ break;
2510+ case SNAPD_ERROR_FAILED:
2511+ d->error = QSnapdRequest::QSnapdError::Failed;
2512+ break;
2513+ case SNAPD_ERROR_TERMS_NOT_ACCEPTED:
2514+ d->error = QSnapdRequest::QSnapdError::TermsNotAccepted;
2515+ break;
2516+ case SNAPD_ERROR_PAYMENT_NOT_SETUP:
2517+ d->error = QSnapdRequest::QSnapdError::PaymentNotSetup;
2518+ break;
2519+ case SNAPD_ERROR_PAYMENT_DECLINED:
2520+ d->error = QSnapdRequest::QSnapdError::PaymentDeclined;
2521+ break;
2522+ default:
2523+ /* This indicates we should add a new entry here... */
2524+ d->error = QSnapdRequest::QSnapdError::UnknownError;
2525+ break;
2526+ }
2527+ d->error = (QSnapdRequest::QSnapdError) e->code;
2528+ }
2529+ else
2530+ d->error = QSnapdRequest::QSnapdError::UnknownError;
2531+ d->errorString = e->message;
2532+ }
2533+ emit complete ();
2534+}
2535+
2536+bool QSnapdRequest::isFinished () const
2537+{
2538+ Q_D(const QSnapdRequest);
2539+ return d->finished;
2540+}
2541+
2542+QSnapdRequest::QSnapdError QSnapdRequest::error () const
2543+{
2544+ Q_D(const QSnapdRequest);
2545+ return d->error;
2546+}
2547+
2548+QString QSnapdRequest::errorString () const
2549+{
2550+ Q_D(const QSnapdRequest);
2551+ return d->errorString;
2552+}
2553+
2554+void QSnapdRequest::cancel ()
2555+{
2556+ Q_D(QSnapdRequest);
2557+ g_cancellable_cancel (d->cancellable);
2558+}
2559+
2560+void QSnapdRequest::handleProgress (void *main_task_, void *tasks_)
2561+{
2562+ Q_D(QSnapdRequest);
2563+ d->main_task = SNAPD_TASK (g_object_ref (main_task_));
2564+ d->tasks = g_ptr_array_ref ((GPtrArray*) tasks_);
2565+ emit progress ();
2566+}
2567+
2568+QSnapdTask *QSnapdRequest::mainTask () const
2569+{
2570+ Q_D(const QSnapdRequest);
2571+ return new QSnapdTask (g_object_ref (d->main_task));
2572+}
2573+
2574+int QSnapdRequest::taskCount () const
2575+{
2576+ Q_D(const QSnapdRequest);
2577+ return d->tasks != NULL ? d->tasks->len : 0;
2578+}
2579+
2580+QSnapdTask *QSnapdRequest::task (int n) const
2581+{
2582+ Q_D(const QSnapdRequest);
2583+ if (d->tasks == NULL || n < 0 || (guint) n >= d->tasks->len)
2584+ return NULL;
2585+ return new QSnapdTask (g_object_ref (d->tasks->pdata[n]));
2586+}
2587
2588=== added file 'snapd-qt/snap.cpp'
2589--- snapd-qt/snap.cpp 1970-01-01 00:00:00 +0000
2590+++ snapd-qt/snap.cpp 2017-01-24 04:26:53 +0000
2591@@ -0,0 +1,188 @@
2592+/*
2593+ * Copyright (C) 2016 Canonical Ltd.
2594+ *
2595+ * This library is free software; you can redistribute it and/or modify it under
2596+ * the terms of the GNU Lesser General Public License as published by the Free
2597+ * Software Foundation; either version 2 or version 3 of the License.
2598+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2599+ */
2600+
2601+#include <snapd-glib/snapd-glib.h>
2602+
2603+#include "Snapd/snap.h"
2604+
2605+QSnapdSnap::QSnapdSnap (void *snapd_object, QObject *parent) :
2606+ QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
2607+
2608+int QSnapdSnap::appCount () const
2609+{
2610+ GPtrArray *apps;
2611+
2612+ apps = snapd_snap_get_apps (SNAPD_SNAP (wrapped_object));
2613+ return apps != NULL ? apps->len : 0;
2614+}
2615+
2616+QSnapdApp *QSnapdSnap::app (int n) const
2617+{
2618+ GPtrArray *apps;
2619+
2620+ apps = snapd_snap_get_apps (SNAPD_SNAP (wrapped_object));
2621+ if (apps == NULL || n < 0 || (guint) n >= apps->len)
2622+ return NULL;
2623+ return new QSnapdApp (g_object_ref (apps->pdata[n]));
2624+}
2625+
2626+QString QSnapdSnap::channel () const
2627+{
2628+ return snapd_snap_get_channel (SNAPD_SNAP (wrapped_object));
2629+}
2630+
2631+QSnapdSnap::QSnapdConfinement QSnapdSnap::confinement () const
2632+{
2633+ switch (snapd_snap_get_confinement (SNAPD_SNAP (wrapped_object)))
2634+ {
2635+ case SNAPD_CONFINEMENT_STRICT:
2636+ return QSnapdConfinement::Strict;
2637+ case SNAPD_CONFINEMENT_DEVMODE:
2638+ return QSnapdConfinement::Devmode;
2639+ case SNAPD_CONFINEMENT_UNKNOWN:
2640+ default:
2641+ return QSnapdConfinement::ConfinementUnknown;
2642+ }
2643+}
2644+
2645+QString QSnapdSnap::description () const
2646+{
2647+ return snapd_snap_get_description (SNAPD_SNAP (wrapped_object));
2648+}
2649+
2650+QString QSnapdSnap::developer () const
2651+{
2652+ return snapd_snap_get_developer (SNAPD_SNAP (wrapped_object));
2653+}
2654+
2655+bool QSnapdSnap::devmode () const
2656+{
2657+ return snapd_snap_get_devmode (SNAPD_SNAP (wrapped_object));
2658+}
2659+
2660+qint64 QSnapdSnap::downloadSize () const
2661+{
2662+ return snapd_snap_get_download_size (SNAPD_SNAP (wrapped_object));
2663+}
2664+
2665+QString QSnapdSnap::icon () const
2666+{
2667+ return snapd_snap_get_icon (SNAPD_SNAP (wrapped_object));
2668+}
2669+
2670+QString QSnapdSnap::id () const
2671+{
2672+ return snapd_snap_get_id (SNAPD_SNAP (wrapped_object));
2673+}
2674+
2675+static QDateTime convertDateTime (GDateTime *datetime)
2676+{
2677+ QDate date (g_date_time_get_year (datetime),
2678+ g_date_time_get_month (datetime),
2679+ g_date_time_get_day_of_month (datetime));
2680+ QTime time (g_date_time_get_hour (datetime),
2681+ g_date_time_get_minute (datetime),
2682+ g_date_time_get_second (datetime),
2683+ g_date_time_get_microsecond (datetime) / 1000);
2684+ return QDateTime (date, time, Qt::OffsetFromUTC, g_date_time_get_utc_offset (datetime) / 1000000);
2685+}
2686+
2687+QDateTime QSnapdSnap::installDate () const
2688+{
2689+ return convertDateTime (snapd_snap_get_install_date (SNAPD_SNAP (wrapped_object)));
2690+}
2691+
2692+qint64 QSnapdSnap::installedSize () const
2693+{
2694+ return snapd_snap_get_installed_size (SNAPD_SNAP (wrapped_object));
2695+}
2696+
2697+QString QSnapdSnap::name () const
2698+{
2699+ return snapd_snap_get_name (SNAPD_SNAP (wrapped_object));
2700+}
2701+
2702+int QSnapdSnap::priceCount () const
2703+{
2704+ GPtrArray *prices;
2705+
2706+ prices = snapd_snap_get_prices (SNAPD_SNAP (wrapped_object));
2707+ return prices != NULL ? prices->len : 0;
2708+}
2709+
2710+QSnapdPrice *QSnapdSnap::price (int n) const
2711+{
2712+ GPtrArray *prices;
2713+
2714+ prices = snapd_snap_get_prices (SNAPD_SNAP (wrapped_object));
2715+ if (prices == NULL || n < 0 || (guint) n >= prices->len)
2716+ return NULL;
2717+ return new QSnapdPrice (g_object_ref (prices->pdata[n]));
2718+}
2719+
2720+bool QSnapdSnap::isPrivate () const
2721+{
2722+ return snapd_snap_get_private (SNAPD_SNAP (wrapped_object));
2723+}
2724+
2725+QString QSnapdSnap::revision () const
2726+{
2727+ return snapd_snap_get_revision (SNAPD_SNAP (wrapped_object));
2728+}
2729+
2730+QSnapdSnap::QSnapdSnapType QSnapdSnap::snapType () const
2731+{
2732+ switch (snapd_snap_get_snap_type (SNAPD_SNAP (wrapped_object)))
2733+ {
2734+ case SNAPD_SNAP_TYPE_APP:
2735+ return QSnapdSnapType::App;
2736+ case SNAPD_SNAP_TYPE_KERNEL:
2737+ return QSnapdSnapType::Kernel;
2738+ case SNAPD_SNAP_TYPE_GADGET:
2739+ return QSnapdSnapType::Gadget;
2740+ case SNAPD_SNAP_TYPE_OS:
2741+ return QSnapdSnapType::OperatingSystem;
2742+ case SNAPD_SNAP_TYPE_UNKNOWN:
2743+ default:
2744+ return QSnapdSnapType::TypeUnknown;
2745+ }
2746+}
2747+
2748+QSnapdSnap::QSnapdSnapStatus QSnapdSnap::status () const
2749+{
2750+ switch (snapd_snap_get_status (SNAPD_SNAP (wrapped_object)))
2751+ {
2752+ case SNAPD_SNAP_STATUS_AVAILABLE:
2753+ return QSnapdSnapStatus::Available;
2754+ case SNAPD_SNAP_STATUS_PRICED:
2755+ return QSnapdSnapStatus::Priced;
2756+ case SNAPD_SNAP_STATUS_INSTALLED:
2757+ return QSnapdSnapStatus::Installed;
2758+ case SNAPD_SNAP_STATUS_ACTIVE:
2759+ return QSnapdSnapStatus::Active;
2760+ case SNAPD_SNAP_STATUS_UNKNOWN:
2761+ default:
2762+ return QSnapdSnapStatus::StatusUnknown;
2763+ }
2764+}
2765+
2766+QString QSnapdSnap::summary () const
2767+{
2768+ return snapd_snap_get_summary (SNAPD_SNAP (wrapped_object));
2769+}
2770+
2771+bool QSnapdSnap::trymode () const
2772+{
2773+ return snapd_snap_get_trymode (SNAPD_SNAP (wrapped_object));
2774+}
2775+
2776+QString QSnapdSnap::version () const
2777+{
2778+ return snapd_snap_get_version (SNAPD_SNAP (wrapped_object));
2779+}
2780
2781=== added file 'snapd-qt/snapd-qt.pc.in'
2782--- snapd-qt/snapd-qt.pc.in 1970-01-01 00:00:00 +0000
2783+++ snapd-qt/snapd-qt.pc.in 2017-01-24 04:26:53 +0000
2784@@ -0,0 +1,11 @@
2785+prefix=@prefix@
2786+exec_prefix=@exec_prefix@
2787+libdir=@libdir@
2788+includedir=@includedir@
2789+
2790+Name: Snapd Qt
2791+Description: Libary for accessing snapd
2792+Version: @VERSION@
2793+Libs: -L${libdir} -lsnapd-qt
2794+Cflags: -I${includedir}/snapd-qt
2795+Requires: Qt5Core
2796
2797=== added file 'snapd-qt/system-information.cpp'
2798--- snapd-qt/system-information.cpp 1970-01-01 00:00:00 +0000
2799+++ snapd-qt/system-information.cpp 2017-01-24 04:26:53 +0000
2800@@ -0,0 +1,34 @@
2801+/*
2802+ * Copyright (C) 2016 Canonical Ltd.
2803+ *
2804+ * This library is free software; you can redistribute it and/or modify it under
2805+ * the terms of the GNU Lesser General Public License as published by the Free
2806+ * Software Foundation; either version 2 or version 3 of the License.
2807+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2808+ */
2809+
2810+#include <snapd-glib/snapd-glib.h>
2811+
2812+#include "Snapd/system-information.h"
2813+
2814+QSnapdSystemInformation::QSnapdSystemInformation (void *snapd_object, QObject *parent) : QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
2815+
2816+QString QSnapdSystemInformation::osId () const
2817+{
2818+ return snapd_system_information_get_os_id (SNAPD_SYSTEM_INFORMATION (wrapped_object));
2819+}
2820+
2821+QString QSnapdSystemInformation::osVersion () const
2822+{
2823+ return snapd_system_information_get_os_version (SNAPD_SYSTEM_INFORMATION (wrapped_object));
2824+}
2825+
2826+QString QSnapdSystemInformation::series () const
2827+{
2828+ return snapd_system_information_get_series (SNAPD_SYSTEM_INFORMATION (wrapped_object));
2829+}
2830+
2831+QString QSnapdSystemInformation::version () const
2832+{
2833+ return snapd_system_information_get_version (SNAPD_SYSTEM_INFORMATION (wrapped_object));
2834+}
2835
2836=== added file 'snapd-qt/task.cpp'
2837--- snapd-qt/task.cpp 1970-01-01 00:00:00 +0000
2838+++ snapd-qt/task.cpp 2017-01-24 04:26:53 +0000
2839@@ -0,0 +1,71 @@
2840+/*
2841+ * Copyright (C) 2016 Canonical Ltd.
2842+ *
2843+ * This library is free software; you can redistribute it and/or modify it under
2844+ * the terms of the GNU Lesser General Public License as published by the Free
2845+ * Software Foundation; either version 2 or version 3 of the License.
2846+ * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
2847+ */
2848+
2849+#include <snapd-glib/snapd-glib.h>
2850+
2851+#include "Snapd/task.h"
2852+
2853+QSnapdTask::QSnapdTask (void *snapd_object, QObject *parent) : QSnapdWrappedObject (snapd_object, g_object_unref, parent) {}
2854+
2855+QString QSnapdTask::id () const
2856+{
2857+ return snapd_task_get_id (SNAPD_TASK (wrapped_object));
2858+}
2859+
2860+QString QSnapdTask::kind () const
2861+{
2862+ return snapd_task_get_kind (SNAPD_TASK (wrapped_object));
2863+}
2864+
2865+QString QSnapdTask::summary () const
2866+{
2867+ return snapd_task_get_summary (SNAPD_TASK (wrapped_object));
2868+}
2869+
2870+QString QSnapdTask::status () const
2871+{
2872+ return snapd_task_get_status (SNAPD_TASK (wrapped_object));
2873+}
2874+
2875+bool QSnapdTask::ready () const
2876+{
2877+ return snapd_task_get_ready (SNAPD_TASK (wrapped_object));
2878+}
2879+
2880+qint64 QSnapdTask::progressDone () const
2881+{
2882+ return snapd_task_get_progress_done (SNAPD_TASK (wrapped_object));
2883+}
2884+
2885+qint64 QSnapdTask::progressTotal () const
2886+{
2887+ return snapd_task_get_progress_total (SNAPD_TASK (wrapped_object));
2888+}
2889+
2890+static QDateTime convertDateTime (GDateTime *datetime)
2891+{
2892+ QDate date (g_date_time_get_year (datetime),
2893+ g_date_time_get_month (datetime),
2894+ g_date_time_get_day_of_month (datetime));
2895+ QTime time (g_date_time_get_hour (datetime),
2896+ g_date_time_get_minute (datetime),
2897+ g_date_time_get_second (datetime),
2898+ g_date_time_get_microsecond (datetime) / 1000);
2899+ return QDateTime (date, time, Qt::OffsetFromUTC, g_date_time_get_utc_offset (datetime) / 1000000);
2900+}
2901+
2902+QDateTime QSnapdTask::spawnTime () const
2903+{
2904+ return convertDateTime (snapd_task_get_spawn_time (SNAPD_TASK (wrapped_object)));
2905+}
2906+
2907+QDateTime QSnapdTask::readyTime () const
2908+{
2909+ return convertDateTime (snapd_task_get_ready_time (SNAPD_TASK (wrapped_object)));
2910+}

Subscribers

People subscribed via source and target branches