From owner-svn-soc-all@FreeBSD.ORG Wed Jun 26 16:31:13 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BBA209D3 for ; Wed, 26 Jun 2013 16:31:13 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id AC14B1ED9 for ; Wed, 26 Jun 2013 16:31:13 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5QGVDR0082149 for ; Wed, 26 Jun 2013 16:31:13 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5QGVDFN082142 for svn-soc-all@FreeBSD.org; Wed, 26 Jun 2013 16:31:13 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 26 Jun 2013 16:31:13 GMT Message-Id: <201306261631.r5QGVDFN082142@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253546 - in soc2013/mattbw/backend: . actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jun 2013 16:31:13 -0000 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 + * + * 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 +#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 + * + * 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 /* 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: */