~lubuntu-software-center-team/lubuntu-software-center/vala-port

« back to all changes in this revision

Viewing changes to src/Backend/AppsManager.vala

  • Committer: Stephen Smally
  • Date: 2012-07-04 13:40:36 UTC
  • Revision ID: eco.stefi@fastwebnet.it-20120704134036-jzxry23ch4in5o80
Implemented packages list via Database, listing works and is fast!

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
            return (Package) res.get_package_array()[0];
129
129
        }
130
130
        
 
131
        public int count_category (string category) {
 
132
                        Query q = database.prepare ("SELECT COUNT (*) FROM '%s';".printf (category));
 
133
            QueryResult r = q.execute();
 
134
            return r.fetch_int (0);
 
135
                }
 
136
        
131
137
        public void get_categories () {
132
138
            try {
133
139
                                Query cat_query = database.prepare ("SELECT * FROM 'DIRECTORIES';");
137
143
                                        category_added (new LscCategory (result.fetch_string (0),
138
144
                                                                  result.fetch_string (1),
139
145
                                                                  result.fetch_string (2),
140
 
                                                                  result.fetch_string (3), 0));
 
146
                                                                  result.fetch_string (3),
 
147
                                                                  count_category (result.fetch_string (0))));
141
148
                                }
142
149
                        } catch (GLib.Error e) {
143
150
                                GLib.error ("Error retrieving packages: %s\n", e.message);
158
165
            try {
159
166
                    database = new Database ("/var/cache/lsc-vala.db", FileMode.READ);
160
167
                        } catch (GLib.Error e) {
161
 
                                GLib.error ("Error opening the database: %s\n", e.message);
 
168
                                GLib.error ("Error opening the database: %s\nPlease run 'lsc-db-build -d /var/cache/lsc-packages.db' as root", e.message);
162
169
                        }
163
170
        }
164
171
    }