socsvn commit: r253546 - in soc2013/mattbw/backend: . actions
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Wed Jun 26 16:31:13 UTC 2013
Author: mattbw
Date: Wed Jun 26 16:31:13 2013
New Revision: 253546
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253546
Log:
add get-repo-list; port to pkg1.1; some things need ironing out
Added:
soc2013/mattbw/backend/actions/get-repo-list.c
soc2013/mattbw/backend/actions/get-repo-list.h
Modified:
soc2013/mattbw/backend/Makefile
soc2013/mattbw/backend/db.c
soc2013/mattbw/backend/iterate.c
soc2013/mattbw/backend/pk-backend-pkgng.c
Modified: soc2013/mattbw/backend/Makefile
==============================================================================
--- soc2013/mattbw/backend/Makefile Wed Jun 26 12:57:21 2013 (r253545)
+++ soc2013/mattbw/backend/Makefile Wed Jun 26 16:31:13 2013 (r253546)
@@ -3,7 +3,7 @@
LIB= pk_backend_pkgng
SHLIB_MAJOR= 1
SRCS= pk-backend-pkgng.c groups.c db.c licenses.c iterate.c
-SRCS+= actions/get-details.c actions/get-files.c
+SRCS+= actions/get-details.c actions/get-files.c actions/get-repo-list.c
LIBDIR= /usr/local/lib/packagekit-backend
Added: soc2013/mattbw/backend/actions/get-repo-list.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2013/mattbw/backend/actions/get-repo-list.c Wed Jun 26 16:31:13 2013 (r253546)
@@ -0,0 +1,52 @@
+/*-
+ *
+ * Copyright (C) 2013 Matt Windsor <mattbw at FreeBSD.org>
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <glib.h>
+#include "../pk-backend.h"
+#include "pkg.h"
+
+/*
+ * The thread that performs a GetRepoList operation. Should be invoked by the
+ * pk_backend_get_repo_list hook.
+ */
+gboolean
+get_repo_list_thread(PkBackend *backend)
+{
+ int err;
+ struct pkg_repo *repo;
+
+ repo = NULL;
+
+ for (;;) {
+ err = pkg_repos(&repo);
+ if (err == EPKG_OK && repo != NULL)
+ pk_backend_repo_detail(backend,
+pkg_repo_ident(repo),
+pkg_repo_name(repo),
+pkg_repo_enabled(repo));
+ else
+ break;
+ }
+
+ return (err == EPKG_END ? TRUE : FALSE);
+}
+
+
Added: soc2013/mattbw/backend/actions/get-repo-list.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2013/mattbw/backend/actions/get-repo-list.h Wed Jun 26 16:31:13 2013 (r253546)
@@ -0,0 +1,29 @@
+/*-
+ * Copyright (C) 2013 Matt Windsor <mattbw at FreeBSD.org>
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 repo_list.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _PKGNG_BACKEND_GET_REPO_LIST_H_
+#define _PKGNG_BACKEND_GET_REPO_LIST_H_
+
+#include <glib.h> /* gboolean */
+#include "../pk-backend.h" /* PkBackend */
+
+gboolean get_repo_list_thread(PkBackend *backend);
+
+#endif /* !_PKGNG_BACKEND_GET_REPO_LIST_H_ */
Modified: soc2013/mattbw/backend/db.c
==============================================================================
--- soc2013/mattbw/backend/db.c Wed Jun 26 12:57:21 2013 (r253545)
+++ soc2013/mattbw/backend/db.c Wed Jun 26 16:31:13 2013 (r253546)
@@ -53,21 +53,30 @@
open_remote_db(struct pkgdb **db, PkBackend *backend)
{
gboolean success;
+ int access_return;
int open_return;
- /* TODO: pkgdb_access for pkg1.1 */
success = FALSE;
- open_return = pkgdb_open(db, PKGDB_REMOTE);
- if (open_return != EPKG_OK)
- pk_backend_error_code(backend,
- PK_ERROR_ENUM_INTERNAL_ERROR,
- "pkgdb_open returned an error");
- else if (*db == NULL)
+
+ access_return = pkgdb_access(PKGDB_MODE_READ | PKGDB_MODE_WRITE,
+ PKGDB_DB_LOCAL | PKGDB_DB_REPO);
+ if (access_return != EPKG_OK)
pk_backend_error_code(backend,
PK_ERROR_ENUM_INTERNAL_ERROR,
- "pkgdb_open gave us a null pointer");
- else
- success = TRUE;
+ "cannot access database");
+ else {
+ open_return = pkgdb_open(db, PKGDB_REMOTE);
+ if (open_return != EPKG_OK)
+ pk_backend_error_code(backend,
+ PK_ERROR_ENUM_INTERNAL_ERROR,
+ "pkgdb_open returned an error");
+ else if (*db == NULL)
+ pk_backend_error_code(backend,
+ PK_ERROR_ENUM_INTERNAL_ERROR,
+ "pkgdb_open gave us a null pointer");
+ else
+ success = TRUE;
+ }
return success;
}
Modified: soc2013/mattbw/backend/iterate.c
==============================================================================
--- soc2013/mattbw/backend/iterate.c Wed Jun 26 12:57:21 2013 (r253545)
+++ soc2013/mattbw/backend/iterate.c Wed Jun 26 16:31:13 2013 (r253546)
@@ -91,13 +91,11 @@
const char *p_arch;
const char *p_data;
const char *p_name;
- const char *p_reponame;
const char *p_version;
pkg_get(pkg,
PKG_ARCH, &p_arch,
PKG_NAME, &p_name,
- PKG_REPONAME, &p_reponame,
PKG_VERSION, &p_version);
switch (pkg_type(pkg)) {
@@ -107,8 +105,11 @@
case PKG_INSTALLED:
p_data = "installed";
break;
+ case PKG_REMOTE:
+ pkg_get(pkg, PKG_REPONAME, &p_data);
+ break;
default:
- p_data = p_reponame;
+ p_data = "unknown";
break;
}
Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jun 26 12:57:21 2013 (r253545)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c Wed Jun 26 16:31:13 2013 (r253546)
@@ -33,6 +33,7 @@
#include "groups.h" /* available_groups */
#include "actions/get-files.h" /* get_files_thread */
#include "actions/get-details.h"/* get_details_thread */
+#include "actions/get-repo-list.h"/* get_repo_list_thread */
#define INTENTIONALLY_IGNORE(x) (void)(x)
@@ -70,7 +71,10 @@
_progress_percentage = 0;
- err = pkg_init(NULL);
+ err = EPKG_OK;
+
+ if (!pkg_initialized())
+ err = pkg_init(NULL);
if (err)
pk_backend_error_code(backend,
PK_ERROR_ENUM_INTERNAL_ERROR,
@@ -1173,15 +1177,12 @@
void
pk_backend_get_repo_list(PkBackend *backend, PkBitfield filters)
{
+ INTENTIONALLY_IGNORE(filters);
+
pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
- pk_backend_repo_detail(backend, "fedora",
- "Fedora - 9", _repo_enabled_fedora);
- if (!pk_bitfield_contain(filters, PK_FILTER_ENUM_NOT_DEVELOPMENT)) {
- pk_backend_repo_detail(backend, "development",
- "Fedora - Development", _repo_enabled_devel);
- }
- pk_backend_repo_detail(backend, "livna-development",
- "Livna for Fedora Core 8 - i386 - Development Tree", _repo_enabled_livna);
+ pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
+
+ pk_backend_thread_create(backend, get_repo_list_thread);
pk_backend_finished(backend);
}
@@ -1473,6 +1474,7 @@
*/
}
+
/**
* pk_backend_get_description:
*/
More information about the svn-soc-all
mailing list