~ubuntu-branches/debian/stretch/apper/stretch

« back to all changes in this revision

Viewing changes to debian/patches/01_appstream-0.6.patch

  • Committer: Package Import Robot
  • Author(s): Matthias Klumpp
  • Date: 2014-04-20 14:42:30 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140420144230-6qghsh10mvw17o87
Tags: 0.8.2-1
* New upstream bugfix release: 0.8.2
* Update debian/watch file
* Drop all patches: Applied upstream
* Build with autoremove enabled
* Bump standards version: No changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: Add support for AppStream 0.6
2
 
 This allows compilation of Apper against the latest libappstream release.
3
 
Forwarded: yes
4
 
Author: Matthias Klumpp <matthias@tenstral.net>
5
 
Last-Update: 2014-04-14
6
 
 
7
 
diff --git a/libapper/AppStream.cpp b/libapper/AppStream.cpp
8
 
index 9786ccf..4c12c18 100644
9
 
--- a/libapper/AppStream.cpp
10
 
+++ b/libapper/AppStream.cpp
11
 
@@ -37,8 +37,10 @@ AppStream* AppStream::m_instance = 0;
12
 
 
13
 
 AppStream* AppStream::instance()
14
 
 {
15
 
-    if(!m_instance)
16
 
+    if(!m_instance) {
17
 
         m_instance = new AppStream(qApp);
18
 
+        m_instance->open();
19
 
+    }
20
 
 
21
 
     return m_instance;
22
 
 }
23
 
@@ -47,71 +49,114 @@ AppStream::AppStream(QObject *parent)
24
 
  : QObject(parent)
25
 
 {
26
 
 #ifdef HAVE_APPSTREAM
27
 
-    bool ret;
28
 
-
29
 
     // create new AppStream database and screenshot service
30
 
-    m_asDB = appstream_database_new();
31
 
-    m_asScreenshots = appstream_screenshot_service_new();
32
 
+    m_asDB = as_database_new();
33
 
+#endif //HAVE_APPSTREAM
34
 
+}
35
 
+
36
 
+AppStream::~AppStream()
37
 
+{
38
 
+#ifdef HAVE_APPSTREAM
39
 
+    g_object_unref(m_asDB);
40
 
+#endif
41
 
+}
42
 
 
43
 
-    ret = appstream_database_open(m_asDB);
44
 
+bool AppStream::open()
45
 
+{
46
 
+#ifdef HAVE_APPSTREAM
47
 
+    bool ret = as_database_open(m_asDB);
48
 
     if (!ret) {
49
 
         qWarning("Unable to open AppStream Xapian database!");
50
 
-        return;
51
 
+        return false;
52
 
     }
53
 
 
54
 
     // cache application data (we might use the db directly, later (making use of AppstreamSearchQuery))
55
 
-    GPtrArray *appArray = NULL;
56
 
-    appArray = appstream_database_get_all_applications(m_asDB);
57
 
+    GPtrArray *cptArray;
58
 
+    cptArray = as_database_get_all_components(m_asDB);
59
 
+    if (cptArray == NULL) {
60
 
+        qWarning("AppStream application array way NULL! (This should never happen)");
61
 
+        return false;
62
 
+    }
63
 
 
64
 
-    for (uint i = 0; i < appArray->len; i++) {
65
 
-        AppstreamAppInfo *appInfo;
66
 
-        appInfo = (AppstreamAppInfo*) g_ptr_array_index(appArray, i);
67
 
+    for (uint i = 0; i < cptArray->len; i++) {
68
 
+        AsComponent *cpt;
69
 
+        GPtrArray *sshot_array;
70
 
+        AsScreenshot *sshot;
71
 
+        cpt = (AsComponent*) g_ptr_array_index(cptArray, i);
72
 
+        // we only want desktop apps at time
73
 
+        if (as_component_get_kind (cpt) != AS_COMPONENT_KIND_DESKTOP_APP)
74
 
+            continue;
75
 
 
76
 
         Application app;
77
 
         // Application name
78
 
-        app.name = QString::fromUtf8(appstream_app_info_get_name(appInfo));
79
 
+        app.name = QString::fromUtf8(as_component_get_name(cpt));
80
 
 
81
 
         // Package name
82
 
-        QString pkgName = QString::fromUtf8(appstream_app_info_get_pkgname(appInfo));
83
 
+        QString pkgName = QString::fromUtf8(as_component_get_pkgname(cpt));
84
 
 
85
 
         // Desktop file
86
 
-        app.id = QString::fromUtf8(appstream_app_info_get_desktop_file(appInfo));
87
 
+        app.id = QString::fromUtf8(as_component_get_idname(cpt));
88
 
 
89
 
         // Summary
90
 
-        app.summary = QString::fromUtf8(appstream_app_info_get_summary(appInfo));
91
 
+        app.summary = QString::fromUtf8(as_component_get_summary(cpt));
92
 
+
93
 
+        // Description
94
 
+        app.description = QString::fromUtf8(as_component_get_description(cpt));
95
 
 
96
 
         // Application stock icon
97
 
-        app.icon = QString::fromUtf8(appstream_app_info_get_icon(appInfo));
98
 
+        app.icon = QString::fromUtf8(as_component_get_icon(cpt));
99
 
 
100
 
         // Application categories
101
 
-        int clen;
102
 
-        gchar **cats = appstream_app_info_get_categories(appInfo, &clen);
103
 
+        gchar **cats = as_component_get_categories(cpt);
104
 
         if (cats != NULL) {
105
 
             app.categories = QStringList();
106
 
-            for (int j = 0; j < clen; j++) {
107
 
+            for (int j = 0; cats[j] != NULL; j++) {
108
 
                 app.categories << QString::fromUtf8(cats[j]);
109
 
             }
110
 
         }
111
 
         g_strfreev(cats);
112
 
 
113
 
+        // add default screenshot urls
114
 
+        sshot_array = as_component_get_screenshots (cpt);
115
 
+
116
 
+        // find default screenshot, if possible
117
 
+        sshot = NULL;
118
 
+        for (uint i = 0; i < sshot_array->len; i++) {
119
 
+            sshot = (AsScreenshot*) g_ptr_array_index (sshot_array, 0);
120
 
+            if (as_screenshot_get_kind (sshot) == AS_SCREENSHOT_KIND_DEFAULT)
121
 
+                break;
122
 
+        }
123
 
+
124
 
+        if (sshot != NULL) {
125
 
+            GPtrArray *imgs;
126
 
+            imgs = as_screenshot_get_images (sshot);
127
 
+            for (uint i = 0; i < imgs->len; i++) {
128
 
+                AsImage *img;
129
 
+                img = (AsImage*) g_ptr_array_index (imgs, i);
130
 
+                if ((as_image_get_kind (img) == AS_IMAGE_KIND_SOURCE) && (app.screenshot.isEmpty())) {
131
 
+                    app.screenshot = QString::fromUtf8(as_image_get_url (img));
132
 
+                } else if ((as_image_get_kind (img) == AS_IMAGE_KIND_THUMBNAIL) && (app.thumbnail.isEmpty())) {
133
 
+                    app.thumbnail = QString::fromUtf8(as_image_get_url (img));
134
 
+                }
135
 
+
136
 
+                if ((!app.screenshot.isEmpty()) && (!app.thumbnail.isEmpty()))
137
 
+                    break;
138
 
+            }
139
 
+        }
140
 
+
141
 
         m_appInfo.insertMulti(pkgName, app);
142
 
     }
143
 
-    g_ptr_array_unref(appArray);
144
 
+    g_ptr_array_unref(cptArray);
145
 
 
146
 
-#endif //HAVE_APPSTREAM
147
 
-}
148
 
-
149
 
-AppStream::~AppStream()
150
 
-{
151
 
-#ifdef HAVE_APPSTREAM
152
 
-    g_object_unref(m_asDB);
153
 
-    g_object_unref(m_asScreenshots);
154
 
+    return true;
155
 
+#else
156
 
+    return false;
157
 
 #endif
158
 
 }
159
 
 
160
 
 QList<AppStream::Application> AppStream::applications(const QString &pkgName) const
161
 
 {
162
 
-    return m_appInfo.values(pkgName);;
163
 
+    return m_appInfo.values(pkgName);
164
 
 }
165
 
 
166
 
 QString AppStream::genericIcon(const QString &pkgName) const
167
 
@@ -146,8 +191,13 @@ QStringList AppStream::findPkgNames(const CategoryMatcher &parser) const
168
 
 QString AppStream::thumbnail(const QString &pkgName) const
169
 
 {
170
 
 #ifdef HAVE_APPSTREAM
171
 
-    const gchar *url = appstream_screenshot_service_get_thumbnail_url(m_asScreenshots, pkgName.toLatin1().data());
172
 
-    return QLatin1String(url);
173
 
+    QString url = "";
174
 
+    if (m_appInfo.contains(pkgName)) {
175
 
+        Application app = m_appInfo.value(pkgName);
176
 
+        url = app.thumbnail;
177
 
+    }
178
 
+
179
 
+    return url;
180
 
 #else
181
 
     Q_UNUSED(pkgName)
182
 
     return QString();
183
 
@@ -157,8 +207,13 @@ QString AppStream::thumbnail(const QString &pkgName) const
184
 
 QString AppStream::screenshot(const QString &pkgName) const
185
 
 {
186
 
 #ifdef HAVE_APPSTREAM
187
 
-    const gchar *url = appstream_screenshot_service_get_screenshot_url(m_asScreenshots, pkgName.toLatin1().data());
188
 
-    return QLatin1String(url);
189
 
+    QString url = "";
190
 
+    if (m_appInfo.contains(pkgName)) {
191
 
+        Application app = m_appInfo.value(pkgName);
192
 
+        url = app.screenshot;
193
 
+    }
194
 
+
195
 
+    return url;
196
 
 #else
197
 
     Q_UNUSED(pkgName)
198
 
     return QString();
199
 
diff --git a/libapper/AppStream.h b/libapper/AppStream.h
200
 
index c288543..2059ff4 100644
201
 
--- a/libapper/AppStream.h
202
 
+++ b/libapper/AppStream.h
203
 
@@ -29,23 +29,27 @@
204
 
 
205
 
 #include <kdemacros.h>
206
 
 
207
 
-struct _AppstreamDatabase;
208
 
-typedef struct _AppstreamDatabase AppstreamDatabase;
209
 
+struct _AsDatabase;
210
 
+typedef struct _AsDatabase AsDatabase;
211
 
 
212
 
-struct _AppstreamScreenshotService;
213
 
-typedef struct _AppstreamScreenshotService AppstreamScreenshotService;
214
 
+struct _AsScreenshotService;
215
 
+typedef struct _AsScreenshotService AsScreenshotService;
216
 
 
217
 
 class KDE_EXPORT AppStream : public QObject {
218
 
     public:
219
 
         struct Application {
220
 
             QString name;
221
 
             QString summary;
222
 
+            QString description;
223
 
             QString icon;
224
 
             QString id;
225
 
             QStringList categories;
226
 
+            QString screenshot;
227
 
+            QString thumbnail;
228
 
         };
229
 
         static AppStream* instance();
230
 
         virtual ~AppStream();
231
 
+        bool open();
232
 
 
233
 
         QList<Application> applications(const QString &pkgName) const;
234
 
         QString genericIcon(const QString &pkgName) const;
235
 
@@ -55,8 +59,7 @@ class KDE_EXPORT AppStream : public QObject {
236
 
 
237
 
     private:
238
 
         explicit AppStream(QObject *parent = 0);
239
 
-        AppstreamDatabase *m_asDB;
240
 
-       AppstreamScreenshotService *m_asScreenshots;
241
 
+        AsDatabase *m_asDB;
242
 
 
243
 
         QHash<QString, Application> m_appInfo;
244
 
         static AppStream         *m_instance;
245
 
diff --git a/libapper/CMakeLists.txt b/libapper/CMakeLists.txt
246
 
index e156419..cb040cc 100644
247
 
--- a/libapper/CMakeLists.txt
248
 
+++ b/libapper/CMakeLists.txt
249
 
@@ -33,7 +33,7 @@ set(libapper_SRCS
250
 
 
251
 
 if(APPSTREAM)
252
 
     pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.36)
253
 
-    pkg_check_modules(APPSTREAM REQUIRED appstream>=0.3.1)
254
 
+    pkg_check_modules(APPSTREAM REQUIRED appstream>=0.6)
255
 
 
256
 
     set(libapper_SRCS ${libapper_SRCS} AppStream.cpp)
257
 
 endif()