Merge lp:~mefrio-g/light-software-center/libappstore-port into lp:light-software-center

Proposed by Mario Guerriero
Status: Merged
Merged at revision: 46
Proposed branch: lp:~mefrio-g/light-software-center/libappstore-port
Merge into: lp:light-software-center
Diff against target: 653 lines (+54/-315)
8 files modified
build.sh (+1/-1)
src/Backend/AppsManager.vala (+0/-207)
src/Backend/Backend.vala (+0/-51)
src/Frontend.vala (+21/-22)
src/Widgets/InfoMessage.vala (+5/-6)
src/Widgets/Pages/AppsInfo.vala (+13/-12)
src/Widgets/Pages/AppsView.vala (+6/-7)
src/Widgets/Pages/CategoriesView.vala (+8/-9)
To merge this branch: bzr merge lp:~mefrio-g/light-software-center/libappstore-port
Reviewer Review Type Date Requested Status
Lubuntu Software Center Team Pending
Review via email: mp+117167@code.launchpad.net

Description of the change

This is a porting to libappstore lib

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build.sh'
2--- build.sh 2012-07-10 16:27:53 +0000
3+++ build.sh 2012-07-28 20:36:19 +0000
4@@ -5,7 +5,7 @@
5 echo -e "\t * libsqlheavy-dev"
6
7
8-VALAC_PKGS="--pkg gio-2.0 --pkg packagekit-glib2 --pkg gtk+-3.0 --pkg sqlheavy-0.1"
9+VALAC_PKGS="--pkg gio-2.0 --pkg packagekit-glib2 --pkg gtk+-3.0 --pkg sqlheavy-0.1 --pkg appstore"
10 VALAC_FLAGS="--vapidir=vapi/ -X
11 -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE"
12 BIN="light-software-center"
13
14=== removed directory 'src/Backend'
15=== removed file 'src/Backend/AppsManager.vala'
16--- src/Backend/AppsManager.vala 2012-07-12 14:59:00 +0000
17+++ src/Backend/AppsManager.vala 1970-01-01 00:00:00 +0000
18@@ -1,207 +0,0 @@
19-// Copyright © 2012 Stephen Smally
20-// This program is free software; you can redistribute it and/or modify
21-// it under the terms of the GNU General Public License as published by
22-// the Free Software Foundation; either version 2 of the License, or
23-// (at your option) any later version.
24-//
25-// This program is distributed in the hope that it will be useful,
26-// but WITHOUT ANY WARRANTY; without even the implied warranty of
27-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28-// GNU General Public License for more details.
29-//
30-// You should have received a copy of the GNU General Public License
31-// along with this program; if not, write to the Free Software
32-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
33-// MA 02110-1301, USA.
34-//
35-
36-using PackageKit;
37-using SQLHeavy;
38-
39-namespace Lsc.Backend {
40- public class AppsManager : Object {
41- // Signals
42- public signal void app_added (LscApp app);
43- public signal void category_added (LscCategory cat);
44- public signal void loading_started (LoadingType load, string text);
45- public signal void loading_finished (LoadingType load);
46- public signal void loading_progress (int percentage);
47- public signal void details_received (LscApp app, Package pkg, Details details);
48-
49- // PackageKit stuffs
50- private Client client;
51- private Control control;
52- private Task task;
53- private Cancellable transaction;
54-
55- // SQLHeavy stuffs
56- private Database database;
57-
58- public void remove_packages (string[] ids, bool deps, bool auto) {
59- loading_started (LoadingType.REMOVE, "Removing packages...");
60- task.remove_packages_async (ids,
61- deps,
62- auto,
63- null,
64- (p) => {
65- if (p.percentage != -1) {
66- loading_progress (p.percentage);
67- }
68- },
69- () => {
70- loading_finished (LoadingType.REMOVE);
71- });
72- }
73-
74- public void install_packages (string[] ids) {
75- loading_started (LoadingType.INSTALL, "Installing packages...");
76- task.install_packages_async (ids,
77- null,
78- (p) => {
79- if (p.percentage != -1) {
80- loading_progress (p.percentage);
81- }
82- },
83- () => {
84- loading_finished (LoadingType.INSTALL);
85- });
86- }
87-
88- public void get_pkgs (string category) {
89- try {
90- Query get_query = database.prepare ("SELECT * FROM '%s';".printf (category));
91- QueryResult result = get_query.execute ();
92-
93- for (int record = 1; ! result.finished; record++, result.next ()) {
94- app_added (new LscApp (
95- result.fetch_string (0),
96- result.fetch_string (1),
97- result.fetch_string (2),
98- result.fetch_string (3)));
99- //if ("x" in result.fetch_string (0))
100- //stdout.printf ("\n%s", result.fetch_string (0));
101- }
102- } catch (GLib.Error e) {
103- GLib.error ("Error retrieving packages: %s\n", e.message);
104- }
105-
106- }
107-
108- private void get_details_2 (LscApp pkg, Package p) {
109- client.get_details_async({p.get_id(), null},
110- null,
111- () => {
112- while (Gtk.events_pending()) {
113- Gtk.main_iteration();
114- }
115- },
116- (obj, resu) => {
117- try {
118- Results res = client.generic_finish (resu);
119- details_received (pkg, p, res.get_details_array()[0]);
120- } catch (GLib.Error e) {
121- stderr.printf ("ERROR! %s\n", e.message);
122- }
123- loading_finished (LoadingType.DETAILS);
124- }
125- );
126- }
127-
128- public void get_details (LscApp pkg) {
129- loading_started (LoadingType.DETAILS, "Loading infos...");
130- client.resolve_async(0,
131- {pkg.id, null},
132- null,
133- () => {
134- while (Gtk.events_pending()) {
135- Gtk.main_iteration();
136- }
137- },
138- (obj, resu) => {
139- try {
140- Results res = client.generic_finish (resu);
141- get_details_2 (pkg, res.get_package_array()[0]);
142- } catch (GLib.Error e) {
143- stdout.printf ("ERROR! %s\n", e.message);
144- }
145- });
146- }
147-
148- private int count_category (string category) {
149- try {
150- Query q = database.prepare ("SELECT COUNT (*) FROM '%s';".printf (category));
151- QueryResult r = q.execute();
152- return r.fetch_int (0);
153- } catch (GLib.Error e) {
154- stdout.printf ("ERROR! %s\n", e.message);
155- }
156- return -1;
157- }
158-
159- public void get_categories () {
160- loading_started(LoadingType.CATEGORIES, "Loading categories...");
161- try {
162- Query cat_query = database.prepare ("SELECT * FROM 'DIRECTORIES';");
163- QueryResult result = cat_query.execute ();
164-
165- for (int record = 1; ! result.finished; record++, result.next ()) {
166- category_added (new LscCategory (result.fetch_string (0),
167- result.fetch_string (1),
168- result.fetch_string (2),
169- result.fetch_string (3),
170- count_category (result.fetch_string (0))));
171- }
172- } catch (GLib.Error e) {
173- GLib.error ("Error retrieving packages: %s\n", e.message);
174- }
175-
176- loading_finished(LoadingType.CATEGORIES);
177- }
178-
179- public void search_for_apps (string search_string) {
180-
181- // Categories
182- try {
183- Query get_query = database.prepare ("SELECT * FROM 'DIRECTORIES';");
184- QueryResult result = get_query.execute ();
185-
186- // Foreach category
187- for (int record = 1; ! result.finished; record++, result.next ()) {
188- // Check for a package
189- stdout.printf ("\n%s", result.fetch_string (0));
190- try {
191- get_query = database.prepare ("SELECT * FROM '%s';".printf (result.fetch_string (0)));
192- result = get_query.execute ();
193-
194- for (record = 1; ! result.finished; record++, result.next ()) {
195- if (search_string in result.fetch_string (0)) // If something is found let's send the application
196- app_added (new LscApp (
197- result.fetch_string (0),
198- result.fetch_string (1),
199- result.fetch_string (2),
200- result.fetch_string (3)));
201- }
202- } catch (GLib.Error e) {
203- GLib.error ("Error retrieving packages: %s\n", e.message);
204- }
205- }
206- } catch (GLib.Error e) {
207- GLib.error ("Error retrieving packages: %s\n", e.message);
208- }
209- }
210-
211- public AppsManager () {
212- client = new Client();
213- control = new Control();
214- task = new Task();
215- transaction = new Cancellable();
216- stdout.printf ("Cache age: %ld\n", client.get_cache_age());
217-
218- try {
219- database = new Database ("/var/cache/lsc-vala.db", FileMode.READ);
220- } catch (GLib.Error e) {
221- GLib.error ("Error opening the database: %s\nPlease run 'lsc-db-build -d /var/cache/lsc-packages.db' as root", e.message);
222- }
223- }
224- }
225-}
226
227=== removed file 'src/Backend/Backend.vala'
228--- src/Backend/Backend.vala 2012-07-12 09:21:39 +0000
229+++ src/Backend/Backend.vala 1970-01-01 00:00:00 +0000
230@@ -1,51 +0,0 @@
231-
232-namespace Lsc.Backend {
233- public enum LoadingType {
234- PACKAGES, // Loaded packages
235- CATEGORIES, // Loaded categories
236- DETAILS, // Loading details
237- INSTALL,
238- REMOVE, // Installed or so
239- SEARCH; // When it is searching apps
240- }
241-
242- public enum ActionType {
243- INSTALL,
244- REMOVE;
245- }
246-
247- public enum ResponseId {
248- INFO,
249- INSTALL;
250- }
251-
252- public class LscCategory : Object {
253- public string id;
254- public string name;
255- public string summary;
256- public string icon;
257- public int records;
258-
259- public LscCategory (string id, string name, string summary, string icon, int records = 0) {
260- this.id = id;
261- this.name = name;
262- this.summary = summary;
263- this.icon = icon;
264- this.records = records;
265- }
266- }
267-
268- public class LscApp : Object {
269- public string id { get; private set; } // A valid id retrieved from a PkPackage
270- public string name { get; private set; }
271- public string summary { get; private set; }
272- public string icon { get; set; }
273-
274- public LscApp (string id, string name, string summary, string icon) {
275- this.id = id;
276- this.name = name;
277- this.summary = summary;
278- this.icon = icon;
279- }
280- }
281-}
282
283=== modified file 'src/Frontend.vala'
284--- src/Frontend.vala 2012-07-12 09:21:39 +0000
285+++ src/Frontend.vala 2012-07-28 20:36:19 +0000
286@@ -16,14 +16,13 @@
287 //
288
289 using Gtk;
290-using Lsc.Backend;
291 using Lsc.Utils;
292 using Lsc.Widgets;
293
294 namespace Lsc {
295 // Elements which should be accessible to every void or class
296- public LscCategory last_category;
297- public LscApp last_app;
298+ public AppStore.Category last_category;
299+ public AppStore.ModelApp last_app;
300
301 public enum PageType {
302 HOMEPAGE,
303@@ -49,7 +48,7 @@
304 }
305
306 // Apps Manager which handle the PackageKit connection
307- public AppsManager apps_manager;
308+ public AppStore.AppsManager apps_manager;
309
310 public class Frontend : Window {
311 // Widgets
312@@ -64,7 +63,7 @@
313 private int _width = 0;
314
315 public Frontend () {
316- apps_manager = new AppsManager();
317+ apps_manager = new AppStore.AppsManager();
318
319 destroy.connect(Gtk.main_quit);
320 size_allocate.connect(on_size_allocate);
321@@ -110,35 +109,35 @@
322 set_focus(null);
323 }
324
325- public void on_info_message_response (ResponseId id, LscApp app) {
326+ public void on_info_message_response (AppStore.ResponseId id, AppStore.ModelApp app) {
327 switch (id) {
328- case ResponseId.INFO:
329+ case AppStore.ResponseId.INFO:
330 load_details (app);
331 break;
332- case ResponseId.INSTALL:
333+ case AppStore.ResponseId.INSTALL:
334 break;
335 }
336 }
337
338- public void load_details (LscApp app) {
339+ public void load_details (AppStore.ModelApp app) {
340 info_message.set_visible (false);
341 last_app = app;
342 apps_manager.get_details (app);
343 pages_view.set_page(PageType.APPSINFO);
344 }
345
346- public void load_packages (LscCategory category) {
347+ public void load_packages (AppStore.Category category) {
348 last_category = category;
349 pages_view.set_page(PageType.APPSVIEW);
350 pages_view.apps_view.apps_tree.clear();
351- apps_manager.get_pkgs(category.id);
352+ apps_manager.get_apps(category.id);
353 toolbar.label.label = category.name;
354 info_message.set_visible (false);
355 }
356
357- public void on_action_response (ActionType type, string id) {
358+ public void on_action_response (AppStore.ActionType type, string id) {
359 switch (type) {
360- case ActionType.INSTALL:
361+ case AppStore.ActionType.INSTALL:
362 apps_manager.install_packages ({id, null});
363 break;
364 default:
365@@ -247,18 +246,18 @@
366 return true;
367 }
368
369- public void on_load_started (LoadingType load, string comment) {
370+ public void on_load_started (AppStore.LoadingType load, string comment) {
371 switch (load) {
372- case LoadingType.PACKAGES:
373+ case AppStore.LoadingType.PACKAGES:
374 progress_info.load (comment);
375 break;
376- case LoadingType.DETAILS:
377+ case AppStore.LoadingType.DETAILS:
378 pages_view.apps_info.start_load();
379 break;
380- case LoadingType.INSTALL:
381+ case AppStore.LoadingType.INSTALL:
382 progress_info.load (comment);
383 break;
384- case LoadingType.REMOVE:
385+ case AppStore.LoadingType.REMOVE:
386 progress_info.load (comment);
387 break;
388 default:
389@@ -267,15 +266,15 @@
390 info_box.set_visible (true);
391 }
392
393- public void on_load_finished (LoadingType load) {
394+ public void on_load_finished (AppStore.LoadingType load) {
395 switch (load) {
396- case LoadingType.CATEGORIES:
397+ case AppStore.LoadingType.CATEGORIES:
398 rework_categories_columns();
399 break;
400- case LoadingType.PACKAGES:
401+ case AppStore.LoadingType.PACKAGES:
402 progress_info.clear();
403 break;
404- case LoadingType.DETAILS:
405+ case AppStore.LoadingType.DETAILS:
406 progress_info.clear();
407 break;
408 default:
409
410=== modified file 'src/Widgets/InfoMessage.vala'
411--- src/Widgets/InfoMessage.vala 2012-07-10 09:44:20 +0000
412+++ src/Widgets/InfoMessage.vala 2012-07-28 20:36:19 +0000
413@@ -16,27 +16,26 @@
414 //
415
416 using Gtk;
417-using Lsc.Backend;
418
419 namespace Lsc.Widgets {
420 public class InfoMessage : InfoBar {
421 // Signals
422- public signal void choosed (ResponseId id, LscApp app);
423+ public signal void choosed (AppStore.ResponseId id, AppStore.ModelApp app);
424
425 // Widgets
426 public Label text;
427 public Button info_button;
428 public Button action_button;
429- private LscApp current_app;
430+ private AppStore.ModelApp current_app;
431
432- public void update (LscApp app) {
433+ public void update (AppStore.ModelApp app) {
434 current_app = app;
435 set_visible (true);
436 text.set_label("Selected package <b>%s</b>".printf (app.id));
437 }
438
439 public void get_response (InfoBar bar, int id) {
440- choosed ((ResponseId) id, current_app);
441+ choosed ((AppStore.ResponseId) id, current_app);
442 }
443
444 public InfoMessage () {
445@@ -51,7 +50,7 @@
446 text.use_markup = true;
447 text.ellipsize = Pango.EllipsizeMode.END;
448
449- add_button(Stock.INFO, ResponseId.INFO);
450+ add_button(Stock.INFO, AppStore.ResponseId.INFO);
451
452 focus_out_event.connect(() => {
453 set_visible(false);
454
455=== modified file 'src/Widgets/Pages/AppsInfo.vala'
456--- src/Widgets/Pages/AppsInfo.vala 2012-07-10 19:06:05 +0000
457+++ src/Widgets/Pages/AppsInfo.vala 2012-07-28 20:36:19 +0000
458@@ -18,12 +18,11 @@
459 using Gtk;
460 using PackageKit;
461 using Lsc.Widgets;
462-using Lsc.Backend;
463 using Granite.Widgets;
464
465 namespace Lsc.Pages {
466 public class AppsInfo : BlankBox {
467- public signal void action_response (ActionType type, string id);
468+ public signal void action_response (AppStore.ActionType type, string id);
469
470 private Separator separator;
471 public RoundBox reviews_box;
472@@ -42,15 +41,15 @@
473 private Label license;
474 private Button action_button;
475 private string pkg_id;
476- private ActionType action_type;
477+ private AppStore.ActionType action_type;
478
479- public void set_action (ActionType type) {
480+ public void set_action (AppStore.ActionType type) {
481 action_type = type;
482 switch (type) {
483- case ActionType.INSTALL:
484+ case AppStore.ActionType.INSTALL:
485 action_button.label = "Install";
486 break;
487- case ActionType.REMOVE:
488+ case AppStore.ActionType.REMOVE:
489 action_button.label = "Remove";
490 break;
491 }
492@@ -61,17 +60,19 @@
493 case Info.INSTALLED:
494 status_icon.set_from_stock (Stock.YES, IconSize.MENU);
495 status_label.label = "Installed";
496- set_action (ActionType.REMOVE);
497+ set_action (AppStore.ActionType.REMOVE);
498 break;
499 default:
500 status_icon.set_from_icon_name ("applications-internet", IconSize.MENU);
501 status_label.label = "Available";
502- set_action (ActionType.INSTALL);
503+ set_action (AppStore.ActionType.INSTALL);
504 break;
505 }
506 }
507
508- public void set_details (LscApp app, Package pkg, Details details) {
509+ public void set_details (AppStore.App app) {
510+ var pkg = app.package;
511+
512 pkg_id = pkg.get_id();
513
514 this.show_children();
515@@ -84,14 +85,14 @@
516 pkg_name.label = "<span size='x-large'><b>%s</b></span>".printf (app.name);
517 short_description.label = "<big>%s</big>".printf (app.summary);
518
519- description.label = details.description;
520+ description.label = app.description;
521
522 image.set_from_icon_name (app.icon, IconSize.DIALOG);
523
524 id.label = pkg.get_name();
525 version.label = pkg.get_version();
526- size.label = Utils.size_to_str ((int) details.size);
527- license.label = details.license;
528+ size.label = Utils.size_to_str ((int) app.size);
529+ license.label = app.license;
530 details_box.set_visible (false);
531 s_nb.page = 0;
532 }
533
534=== modified file 'src/Widgets/Pages/AppsView.vala'
535--- src/Widgets/Pages/AppsView.vala 2012-07-12 09:21:39 +0000
536+++ src/Widgets/Pages/AppsView.vala 2012-07-28 20:36:19 +0000
537@@ -17,13 +17,12 @@
538
539 using Gtk;
540 using PackageKit;
541-using Lsc.Backend;
542
543 namespace Lsc.Widgets {
544 public class AppsTree : TreeView {
545 // Signals
546- public signal void selected_row (LscApp app);
547- public signal void activated_row (LscApp app);
548+ public signal void selected_row (AppStore.ModelApp app);
549+ public signal void activated_row (AppStore.ModelApp app);
550
551 // Vars
552 private IconTheme theme;
553@@ -31,7 +30,7 @@
554 private TreeIter iter;
555 private new TreePath path;
556
557- public void append_app (LscApp app) {
558+ public void append_app (AppStore.ModelApp app) {
559 model.append(out iter);
560 //model.set(iter, 0, app.icon, 1, "<span size='medium'>"+Utils.escape_text (app.name)+"</span>\n<span size='small'>"+Utils.escape_text (app.summary)+"</span>", 2, app);
561 model.set(iter, 0, app.icon, 1, "<b>"+Utils.escape_text (app.name)+"</b>\n"+Utils.escape_text (app.summary), 2, app); // FIXME: this actually take time
562@@ -44,7 +43,7 @@
563 public void on_cursor_changed (TreeView widget) {
564 get_cursor(out path, null);
565 if (path != null) {
566- LscApp val;
567+ AppStore.ModelApp val;
568 model.get_iter(out iter, path);
569 model.get(iter, 2, out val);
570 selected_row(val);
571@@ -54,7 +53,7 @@
572 public void on_row_activated (TreePath path, TreeViewColumn column) {
573 get_cursor(out this.path, null);
574 if (path != null) {
575- LscApp val;
576+ AppStore.ModelApp val;
577 model.get_iter(out iter, this.path);
578 model.get(iter, 2, out val);
579 activated_row(val);
580@@ -69,7 +68,7 @@
581 model = new ListStore(3,
582 t_string, // Icon name
583 t_string, // Name and description
584- typeof(LscApp) // LscApp object
585+ typeof(AppStore.ModelApp) // AppStore.App object
586 );
587
588 set_model(model);
589
590=== modified file 'src/Widgets/Pages/CategoriesView.vala'
591--- src/Widgets/Pages/CategoriesView.vala 2012-07-11 18:59:07 +0000
592+++ src/Widgets/Pages/CategoriesView.vala 2012-07-28 20:36:19 +0000
593@@ -16,19 +16,18 @@
594 //
595
596 using Gtk;
597-using Lsc.Backend;
598
599 namespace Lsc.Widgets {
600 public class CategoryButton : EventBox {
601- private LscCategory desc;
602- public signal void category_clicked (LscCategory cat);
603+ private AppStore.Category desc;
604+ public signal void category_clicked (AppStore.Category cat);
605
606 private bool emit_clicked (Widget box, Gdk.EventButton button) {
607 category_clicked (desc);
608 return true;
609 }
610
611- public CategoryButton (LscCategory desc, bool fill = false) {
612+ public CategoryButton (AppStore.Category desc, bool fill = false) {
613 this.desc = desc;
614
615 sensitive = ! fill;
616@@ -69,16 +68,16 @@
617 }
618
619 public class CategoriesView : GridView {
620- public signal void category_choosed (LscCategory cat);
621+ public signal void category_choosed (AppStore.Category cat);
622
623 // Vars
624 private Box box_child;
625 private CategoryButton button_child;
626 public int columns { get; set; }
627 private int actual_col;
628- private new List<LscCategory> children = null;
629+ private new List<AppStore.Category> children = null;
630
631- public void add_category (LscCategory cat) {
632+ public void add_category (AppStore.Category cat) {
633 children.append(cat);
634 }
635
636@@ -89,7 +88,7 @@
637 box_child = null;
638 actual_col = columns;
639
640- foreach (LscCategory button_desc in children) {
641+ foreach (AppStore.Category button_desc in children) {
642 if (actual_col == columns) {
643 box_child = new Box(Orientation.HORIZONTAL, 5);
644 box_child.homogeneous = true;
645@@ -109,7 +108,7 @@
646 }
647
648 while (actual_col != columns) {
649- button_child = new CategoryButton(new LscCategory("", "", "", "", 0), true);
650+ button_child = new CategoryButton(new AppStore.Category("", "", "", "", 0), true);
651 box_child.pack_start(button_child, true, true, 0);
652 button_child.show_all();
653 actual_col++;

Subscribers

People subscribed via source and target branches