From owner-svn-soc-all@FreeBSD.ORG Tue Jun 25 01:20:36 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 3DDA594D for ; Tue, 25 Jun 2013 01:20:36 +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 2179C1A19 for ; Tue, 25 Jun 2013 01:20:36 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5P1KasR062481 for ; Tue, 25 Jun 2013 01:20:36 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5P1KaAf062451 for svn-soc-all@FreeBSD.org; Tue, 25 Jun 2013 01:20:36 GMT (envelope-from mattbw@FreeBSD.org) Date: Tue, 25 Jun 2013 01:20:36 GMT Message-Id: <201306250120.r5P1KaAf062451@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: r253467 - soc2013/mattbw/backend 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: Tue, 25 Jun 2013 01:20:36 -0000 Author: mattbw Date: Tue Jun 25 01:20:35 2013 New Revision: 253467 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253467 Log: hook up get-details to licence NAME getter (for some reason get-details wants name and not enum, may need to ask about this...). Modified: soc2013/mattbw/backend/get-details.c soc2013/mattbw/backend/licenses.c soc2013/mattbw/backend/licenses.h Modified: soc2013/mattbw/backend/get-details.c ============================================================================== --- soc2013/mattbw/backend/get-details.c Tue Jun 25 01:12:25 2013 (r253466) +++ soc2013/mattbw/backend/get-details.c Tue Jun 25 01:20:35 2013 (r253467) @@ -25,8 +25,11 @@ #include "pkg.h" #include "db.h" /* open_remote_db */ -#include "groups.h" /* group_from_origin */ #include "get-details.h" /* get_details_thread prototype */ +#include "groups.h" /* group_from_origin */ +#include "licenses.h" /* license_from_pkg */ + +static const int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_LICENSES; /* TODO: move out of get-details? */ const char *null_if_empty(const char *in); @@ -88,7 +91,7 @@ found = FALSE; match = NULL; do { - err = pkgdb_it_next(matches, &match, PKG_LOAD_BASIC); + err = pkgdb_it_next(matches, &match, LOAD_FLAGS); if (err == EPKG_OK) { const char *arch; const char *data; @@ -140,7 +143,7 @@ /* TODO: implement category, size and licence */ pk_backend_details(backend, new_id, - NULL, + license_name_from_pkg(match), group_from_origin(origin), description, www, Modified: soc2013/mattbw/backend/licenses.c ============================================================================== --- soc2013/mattbw/backend/licenses.c Tue Jun 25 01:12:25 2013 (r253466) +++ soc2013/mattbw/backend/licenses.c Tue Jun 25 01:20:35 2013 (r253467) @@ -18,13 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "pkg.h" /* struct pkg, etc */ -#include "pk-backend.h" /* PkLicenseEnum, PK_* */ +#include "pkg.h" /* struct pkg, etc */ +#include "pk-backend.h" /* PkLicenseEnum, PK_* */ -#include "licenses.h" /* prototypes */ -#include "mappings.h" /* mapping macros */ - -static const char * license_name_from_pkg(struct pkg *pkg); +#include "licenses.h" /* prototypes */ +#include "mappings.h" /* mapping macros */ struct license_mapping { const char *key; @@ -32,9 +30,9 @@ }; /* - * Mappings between the output of "pkg_license_name" and the closest available - * PackageKit license. - * + * Mappings between the output of "pkg_license_name" and the closest + * available PackageKit license. + * * These should ALWAYS be in ASCIIbetical order of license names. This is in * case anything relies on this property when searching the list (for example * binary searching). @@ -44,24 +42,26 @@ {NULL, PK_LICENSE_ENUM_UNKNOWN} }; -/* Returns the closest approximation packagekit has to this package's license. - * +/* + * Returns the closest approximation packagekit has to this package's + * license. + * * PackageKit only has a simple concept of licencing, so this is inherently a * very lossy mapping. */ PkLicenseEnum license_from_pkg(struct pkg *pkg) { - const char *pkg_license_name; + const char *pkg_license_name; struct license_mapping *map; - PkLicenseEnum result; + PkLicenseEnum result; pkg_license_name = license_name_from_pkg(pkg); - /* Is it in our manual license mapping? - * If not, then try interpreting it as a PackageKit license name and - * convert it back (messy, but hopefully safe), but only if it isn't - * NULL. + /* + * Is it in our manual license mapping? If not, then try interpreting + * it as a PackageKit license name and convert it back (messy, but + * hopefully safe), but only if it isn't NULL. */ MAPPING_FIND(pkg_license_name, &map, license_mappings); if (pkg_license_name != NULL && map->key == NULL) @@ -73,11 +73,11 @@ } /* Retrieves the name of the FIRST license attached to the package. */ -static const char * +const char * license_name_from_pkg(struct pkg *pkg) { - int err; - const char *match; + int err; + const char *match; struct pkg_license *lic; lic = NULL; Modified: soc2013/mattbw/backend/licenses.h ============================================================================== --- soc2013/mattbw/backend/licenses.h Tue Jun 25 01:12:25 2013 (r253466) +++ soc2013/mattbw/backend/licenses.h Tue Jun 25 01:20:35 2013 (r253467) @@ -24,5 +24,6 @@ #include "pk-backend.h" PkLicenseEnum license_from_pkg(struct pkg *pkg); +const char *license_name_from_pkg(struct pkg *pkg); #endif /* _PKGNG_BACKEND_LICENSES_H_ */