[packagekit] packagekit: Branch 'master' - 5 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Thu Oct 11 11:06:11 PDT 2007
backends/apt/Makefile.am | 3 ++-
backends/apt/sqlite-pkg-cache.c | 12 ++++++------
backends/yum/helpers/.gitignore | 2 ++
backends/yum/helpers/yumBackend.py | 17 ++++++++++++++++-
4 files changed, 26 insertions(+), 8 deletions(-)
New commits:
diff-tree 666a81a1072ac5315be3c1b7a8174b6ee4b87b57 (from a1efc237053eb8482ac5c5f558dba8e34b470bfa)
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Oct 11 19:05:03 2007 +0100
add a gitignore file
diff --git a/backends/yum/helpers/.gitignore b/backends/yum/helpers/.gitignore
new file mode 100644
index 0000000..2f78cf5
--- /dev/null
+++ b/backends/yum/helpers/.gitignore
@@ -0,0 +1,2 @@
+*.pyc
+
diff-tree a1efc237053eb8482ac5c5f558dba8e34b470bfa (from 14ebb9513918eab4139a3b1454b435bdc8074814)
Author: Tim Lauridsen <tim at localhost.localdomain>
Date: Thu Oct 11 16:31:59 2007 +0200
removed wrong yum. prefix
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 391264c..a022c1f 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -57,7 +57,7 @@ class PackageKitYumBackend(PackageKitBas
def __init__(self,args):
PackageKitBaseBackend.__init__(self,args)
- self.yumbase = yum.PackageKitYumBase()
+ self.yumbase = PackageKitYumBase()
def _get_package_ver(self,po):
''' return the a ver as epoch:version-release or version-release, if epoch=0'''
diff-tree 14ebb9513918eab4139a3b1454b435bdc8074814 (from 6f5c9481d1cf1d21c5a893222052193821311dea)
Author: Tim Lauridsen <tim at localhost.localdomain>
Date: Thu Oct 11 16:28:50 2007 +0200
Add stub to yum backend to prepare for the RepoSignatureRequired signal
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index da772a2..391264c 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -33,6 +33,20 @@ from yum.callbacks import *
from yum.misc import prco_tuple_to_string, unique
import rpmUtils
+class PackageKitYumBase(yum.YumBase):
+ """
+ Custom YumBase Class for PackageKit
+ Used to overload methods in YumBase there need to be different in
+ PackageKit
+
+ """
+ def _askForGPGKeyImport(self, po, userid, hexkeyid):
+ '''
+ Ask for GPGKeyImport
+ '''
+ # TODO: Add code here to send the RepoSignatureRequired signal
+ return False
+
class PackageKitYumBackend(PackageKitBaseBackend):
# Packages there require a reboot
@@ -43,7 +57,7 @@ class PackageKitYumBackend(PackageKitBas
def __init__(self,args):
PackageKitBaseBackend.__init__(self,args)
- self.yumbase = yum.YumBase()
+ self.yumbase = yum.PackageKitYumBase()
def _get_package_ver(self,po):
''' return the a ver as epoch:version-release or version-release, if epoch=0'''
diff-tree 6f5c9481d1cf1d21c5a893222052193821311dea (from cdcd8f7cc16a150a9a66665466e0f95b948efbd1)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Thu Sep 27 09:26:40 2007 +0200
Add bandwith throttling to yum backend
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index edd240b..da772a2 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -559,6 +559,7 @@ class PackageKitYumBackend(PackageKitBas
def _setup_yum(self):
self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0) # Setup Yum Config
+ self.yumbase.conf.throttle = "40%" # Set bandwidth throttle to 40%
self.dnlCallback = DownloadCallback(self,showNames=True) # Download callback
self.yumbase.repos.setProgressBar( self.dnlCallback ) # Setup the download callback class
diff-tree cdcd8f7cc16a150a9a66665466e0f95b948efbd1 (from 58b32e8a981ff098a989a9187637649a69c4ded1)
Author: Tom Parker <palfrey at tevp.net>
Date: Thu Oct 11 16:23:16 2007 +0200
Rename apt's sqlite-pkg-cache and python-backend-common to .c
diff --git a/backends/apt/Makefile.am b/backends/apt/Makefile.am
index 05dcc43..b651273 100644
--- a/backends/apt/Makefile.am
+++ b/backends/apt/Makefile.am
@@ -2,8 +2,9 @@ SUBDIRS = helpers
plugindir = @PK_PLUGIN_DIR@
plugin_LTLIBRARIES = libpk_backend_apt.la
libpk_backend_apt_la_INCLUDES = $(APT_CFLAGS) $(SQLITE_CFLAGS)
-libpk_backend_apt_la_SOURCES = pk-backend-apt.cpp sqlite-pkg-cache.cpp apt-build-db.cpp python-backend-common.cpp
+libpk_backend_apt_la_SOURCES = pk-backend-apt.cpp sqlite-pkg-cache.c apt-build-db.cpp python-backend-common.c
libpk_backend_apt_la_LIBADD = @PK_PLUGIN_LIBS@ $(APT_LIBS) $(SQLITE_LIBS)
libpk_backend_apt_la_LDFLAGS = -module -avoid-version
+libpk_backend_apt_la_CFLAGS = @PK_PLUGIN_CFLAGS@ -DDATABASEDIR=\""$(PK_DB_DIR)"\"
libpk_backend_apt_la_CXXFLAGS = @PK_PLUGIN_CFLAGS@ -DDATABASEDIR=\""$(PK_DB_DIR)"\"
diff --git a/backends/apt/python-backend-common.c b/backends/apt/python-backend-common.c
new file mode 100644
index 0000000..cfc82c7
--- /dev/null
+++ b/backends/apt/python-backend-common.c
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <pk-backend.h>
+
+/**
+ * python_refresh_cache:
+ **/
+void python_refresh_cache(PkBackend * backend, gboolean force)
+{
+ /* check network state */
+ if (pk_backend_network_is_online(backend) == FALSE)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished(backend);
+ return;
+ }
+
+ pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
+}
+
diff --git a/backends/apt/python-backend-common.cpp b/backends/apt/python-backend-common.cpp
deleted file mode 100644
index cfc82c7..0000000
--- a/backends/apt/python-backend-common.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <pk-backend.h>
-
-/**
- * python_refresh_cache:
- **/
-void python_refresh_cache(PkBackend * backend, gboolean force)
-{
- /* check network state */
- if (pk_backend_network_is_online(backend) == FALSE)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
- pk_backend_finished(backend);
- return;
- }
-
- pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
-}
-
diff --git a/backends/apt/sqlite-pkg-cache.c b/backends/apt/sqlite-pkg-cache.c
new file mode 100644
index 0000000..faa871f
--- /dev/null
+++ b/backends/apt/sqlite-pkg-cache.c
@@ -0,0 +1,227 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <sqlite3.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include "sqlite-pkg-cache.h"
+
+static sqlite3 *db = NULL;
+
+typedef struct {
+ PkPackageId *pi;
+} desc_task;
+
+typedef struct {
+ gchar *search;
+ gchar *filter;
+ SearchDepth depth;
+} search_task;
+
+void
+sqlite_init_cache(PkBackend *backend, const char* dbname, const char *compare_fname, void (*build_db)(PkBackend *, sqlite3 *))
+{
+ int ret;
+ struct stat st;
+ time_t db_age;
+
+ ret = sqlite3_open (dbname, &db);
+ ret = sqlite3_exec(db,"PRAGMA synchronous = OFF",NULL,NULL,NULL);
+ g_assert(ret == SQLITE_OK);
+
+ g_stat(dbname, &st);
+ db_age = st.st_mtime;
+ g_stat(compare_fname, &st);
+ if (db_age>=st.st_mtime)
+ {
+ ret = sqlite3_exec(db, "select value from params where name = 'build_complete'", NULL, NULL, NULL);
+ if (ret != SQLITE_ERROR)
+ return;
+ }
+ ret = sqlite3_exec(db,"drop table packages",NULL,NULL,NULL); // wipe it!
+ //g_assert(ret == SQLITE_OK);
+ pk_debug("wiped db");
+ ret = sqlite3_exec(db,"create table packages (name text, version text, deps text, arch text, short_desc text, long_desc text, repo string, primary key(name,version,arch,repo))",NULL,NULL,NULL);
+ g_assert(ret == SQLITE_OK);
+
+ build_db(backend,db);
+
+ sqlite3_exec(db,"create table params (name text primary key, value integer)", NULL, NULL, NULL);
+ sqlite3_exec(db,"insert into params values ('build_complete',1)", NULL, NULL, NULL);
+}
+
+// sqlite_search_packages_thread
+static gboolean
+sqlite_search_packages_thread (PkBackend *backend, gpointer data)
+{
+ search_task *st = (search_task *) data;
+ int res;
+ gchar *sel;
+
+ pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_no_percentage_updates(backend);
+
+ pk_debug("finding %s", st->search);
+
+ sqlite3_stmt *package = NULL;
+ g_strdelimit(st->search," ",'%');
+
+ if (st->depth == SEARCH_NAME)
+ sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%'",st->search);
+ else if (st->depth == SEARCH_DETAILS)
+ sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%' or short_desc like '%%%s%%' or long_desc like '%%%s%%'",st->search, st->search, st->search);
+ else
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Unknown search task type");
+ goto end_search_packages;
+ }
+
+ pk_debug("statement is '%s'",sel);
+ res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
+ g_free(sel);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
+ res = sqlite3_step(package);
+ while (res == SQLITE_ROW)
+ {
+ gchar *pid = pk_package_id_build((const gchar*)sqlite3_column_text(package,0),
+ (const gchar*)sqlite3_column_text(package,1),
+ (const gchar*)sqlite3_column_text(package,2),
+ (const gchar*)sqlite3_column_text(package,3));
+ pk_backend_package(backend, PK_INFO_ENUM_UNKNOWN, pid, (const gchar*)sqlite3_column_text(package,4));
+ g_free(pid);
+ if (res==SQLITE_ROW)
+ res = sqlite3_step(package);
+ }
+ if (res!=SQLITE_DONE)
+ {
+ pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
+ g_assert(0);
+ }
+
+ end_search_packages:
+ g_free(st->search);
+ g_free(st);
+
+ return TRUE;
+}
+
+/**
+ * backend_search_common
+ **/
+void
+backend_search_common(PkBackend * backend, const gchar * filter, const gchar * search, SearchDepth which, PkBackendThreadFunc func)
+{
+ g_return_if_fail (backend != NULL);
+ search_task *data = g_new(search_task, 1);
+ if (data == NULL)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
+ pk_backend_finished(backend);
+ }
+ else
+ {
+ data->search = g_strdup(search);
+ data->filter = g_strdup(filter);
+ data->depth = which;
+ pk_backend_thread_helper (backend, func, data);
+ }
+}
+
+/**
+ * sqlite_search_details:
+ */
+void
+sqlite_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+ backend_search_common(backend, filter, search, SEARCH_DETAILS, sqlite_search_packages_thread);
+}
+
+/**
+ * sqlite_search_name:
+ */
+void
+sqlite_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+ backend_search_common(backend, filter, search, SEARCH_NAME, sqlite_search_packages_thread);
+}
+
+// sqlite_get_description_thread
+static gboolean sqlite_get_description_thread (PkBackend *backend, gpointer data)
+{
+ desc_task *dt = (desc_task *) data;
+ int res;
+
+ pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_no_percentage_updates(backend);
+
+ pk_debug("finding %s", dt->pi->name);
+
+ sqlite3_stmt *package = NULL;
+ gchar *sel = g_strdup_printf("select long_desc from packages where name = '%s' and version = '%s' and repo = '%s'",dt->pi->name,dt->pi->version,dt->pi->data);
+ pk_debug("statement is '%s'",sel);
+ res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
+ g_free(sel);
+ if (res!=SQLITE_OK)
+ pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
+ res = sqlite3_step(package);
+ pk_backend_description(backend,dt->pi->name, "unknown", PK_GROUP_ENUM_OTHER,(const gchar*)sqlite3_column_text(package,0),"",0,"");
+ res = sqlite3_step(package);
+ if (res==SQLITE_ROW)
+ pk_error("multiple matches for that package!");
+ if (res!=SQLITE_DONE)
+ {
+ pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
+ g_assert(0);
+ }
+
+ g_free(dt);
+
+ return TRUE;
+}
+
+/**
+ * sqlite_get_description:
+ */
+void
+sqlite_get_description (PkBackend *backend, const gchar *package_id)
+{
+ g_return_if_fail (backend != NULL);
+ desc_task *data = g_new(desc_task, 1);
+ if (data == NULL)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
+ pk_backend_finished(backend);
+ return;
+ }
+
+ data->pi = pk_package_id_new_from_string(package_id);
+ if (data->pi == NULL)
+ {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+ pk_backend_finished(backend);
+ return;
+ }
+
+ pk_backend_thread_helper (backend, sqlite_get_description_thread, data);
+ return;
+}
+
+
diff --git a/backends/apt/sqlite-pkg-cache.cpp b/backends/apt/sqlite-pkg-cache.cpp
deleted file mode 100644
index 369801d..0000000
--- a/backends/apt/sqlite-pkg-cache.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <sqlite3.h>
-#include <glib.h>
-#include <glib/gstdio.h>
-#include "sqlite-pkg-cache.h"
-
-static sqlite3 *db = NULL;
-
-struct desc_task {
- PkPackageId *pi;
-};
-
-struct search_task {
- gchar *search;
- gchar *filter;
- SearchDepth depth;
-};
-
-void
-sqlite_init_cache(PkBackend *backend, const char* dbname, const char *compare_fname, void (*build_db)(PkBackend *, sqlite3 *))
-{
- int ret;
- struct stat st;
- time_t db_age;
-
- ret = sqlite3_open (dbname, &db);
- ret = sqlite3_exec(db,"PRAGMA synchronous = OFF",NULL,NULL,NULL);
- g_assert(ret == SQLITE_OK);
-
- g_stat(dbname, &st);
- db_age = st.st_mtime;
- g_stat(compare_fname, &st);
- if (db_age>=st.st_mtime)
- {
- ret = sqlite3_exec(db, "select value from params where name = 'build_complete'", NULL, NULL, NULL);
- if (ret != SQLITE_ERROR)
- return;
- }
- ret = sqlite3_exec(db,"drop table packages",NULL,NULL,NULL); // wipe it!
- //g_assert(ret == SQLITE_OK);
- pk_debug("wiped db");
- ret = sqlite3_exec(db,"create table packages (name text, version text, deps text, arch text, short_desc text, long_desc text, repo string, primary key(name,version,arch,repo))",NULL,NULL,NULL);
- g_assert(ret == SQLITE_OK);
-
- build_db(backend,db);
-
- sqlite3_exec(db,"create table params (name text primary key, value integer)", NULL, NULL, NULL);
- sqlite3_exec(db,"insert into params values ('build_complete',1)", NULL, NULL, NULL);
-}
-
-// sqlite_search_packages_thread
-static gboolean
-sqlite_search_packages_thread (PkBackend *backend, gpointer data)
-{
- search_task *st = (search_task *) data;
- int res;
- gchar *sel;
-
- pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
- pk_backend_no_percentage_updates(backend);
-
- pk_debug("finding %s", st->search);
-
- sqlite3_stmt *package = NULL;
- g_strdelimit(st->search," ",'%');
-
- if (st->depth == SEARCH_NAME)
- sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%'",st->search);
- else if (st->depth == SEARCH_DETAILS)
- sel = g_strdup_printf("select name,version,arch,repo,short_desc from packages where name like '%%%s%%' or short_desc like '%%%s%%' or long_desc like '%%%s%%'",st->search, st->search, st->search);
- else
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Unknown search task type");
- goto end_search_packages;
- }
-
- pk_debug("statement is '%s'",sel);
- res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
- g_free(sel);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
- res = sqlite3_step(package);
- while (res == SQLITE_ROW)
- {
- gchar *pid = pk_package_id_build((const gchar*)sqlite3_column_text(package,0),
- (const gchar*)sqlite3_column_text(package,1),
- (const gchar*)sqlite3_column_text(package,2),
- (const gchar*)sqlite3_column_text(package,3));
- pk_backend_package(backend, PK_INFO_ENUM_UNKNOWN, pid, (const gchar*)sqlite3_column_text(package,4));
- g_free(pid);
- if (res==SQLITE_ROW)
- res = sqlite3_step(package);
- }
- if (res!=SQLITE_DONE)
- {
- pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
- g_assert(0);
- }
-
- end_search_packages:
- g_free(st->search);
- g_free(st);
-
- return TRUE;
-}
-
-/**
- * backend_search_common
- **/
-void
-backend_search_common(PkBackend * backend, const gchar * filter, const gchar * search, SearchDepth which, PkBackendThreadFunc func)
-{
- g_return_if_fail (backend != NULL);
- search_task *data = g_new(struct search_task, 1);
- if (data == NULL)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
- pk_backend_finished(backend);
- }
- else
- {
- data->search = g_strdup(search);
- data->filter = g_strdup(filter);
- data->depth = which;
- pk_backend_thread_helper (backend, func, data);
- }
-}
-
-/**
- * sqlite_search_details:
- */
-void
-sqlite_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- backend_search_common(backend, filter, search, SEARCH_DETAILS, sqlite_search_packages_thread);
-}
-
-/**
- * sqlite_search_name:
- */
-void
-sqlite_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- backend_search_common(backend, filter, search, SEARCH_NAME, sqlite_search_packages_thread);
-}
-
-// sqlite_get_description_thread
-static gboolean sqlite_get_description_thread (PkBackend *backend, gpointer data)
-{
- desc_task *dt = (desc_task *) data;
- int res;
-
- pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
- pk_backend_no_percentage_updates(backend);
-
- pk_debug("finding %s", dt->pi->name);
-
- sqlite3_stmt *package = NULL;
- gchar *sel = g_strdup_printf("select long_desc from packages where name = '%s' and version = '%s' and repo = '%s'",dt->pi->name,dt->pi->version,dt->pi->data);
- pk_debug("statement is '%s'",sel);
- res = sqlite3_prepare_v2(db,sel, -1, &package, NULL);
- g_free(sel);
- if (res!=SQLITE_OK)
- pk_error("sqlite error during select prepare: %s", sqlite3_errmsg(db));
- res = sqlite3_step(package);
- pk_backend_description(backend,dt->pi->name, "unknown", PK_GROUP_ENUM_OTHER,(const gchar*)sqlite3_column_text(package,0),"",0,"");
- res = sqlite3_step(package);
- if (res==SQLITE_ROW)
- pk_error("multiple matches for that package!");
- if (res!=SQLITE_DONE)
- {
- pk_debug("sqlite error during step (%d): %s", res, sqlite3_errmsg(db));
- g_assert(0);
- }
-
- g_free(dt);
-
- return TRUE;
-}
-
-/**
- * sqlite_get_description:
- */
-void
-sqlite_get_description (PkBackend *backend, const gchar *package_id)
-{
- g_return_if_fail (backend != NULL);
- desc_task *data = g_new(struct desc_task, 1);
- if (data == NULL)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
- pk_backend_finished(backend);
- return;
- }
-
- data->pi = pk_package_id_new_from_string(package_id);
- if (data->pi == NULL)
- {
- pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
- pk_backend_finished(backend);
- return;
- }
-
- pk_backend_thread_helper (backend, sqlite_get_description_thread, data);
- return;
-}
-
-
More information about the PackageKit
mailing list