From owner-svn-soc-all@FreeBSD.ORG Fri Jul 12 18:58:37 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 EFEBED2E for ; Fri, 12 Jul 2013 18:58:37 +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 E106B190B for ; Fri, 12 Jul 2013 18:58:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6CIwbLB012658 for ; Fri, 12 Jul 2013 18:58:37 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6CIwbNT012653 for svn-soc-all@FreeBSD.org; Fri, 12 Jul 2013 18:58:37 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 12 Jul 2013 18:58:37 GMT Message-Id: <201307121858.r6CIwbNT012653@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: r254701 - 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: Fri, 12 Jul 2013 18:58:38 -0000 Author: mattbw Date: Fri Jul 12 18:58:37 2013 New Revision: 254701 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254701 Log: split event handler into new file Added: soc2013/mattbw/backend/event.c soc2013/mattbw/backend/event.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/actions/install_packages.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Fri Jul 12 17:37:05 2013 (r254700) +++ soc2013/mattbw/backend/Makefile Fri Jul 12 18:58:37 2013 (r254701) @@ -5,8 +5,9 @@ SRCS= pk-backend-pkgng.c SRCS+= \ db.c \ - group_map.c \ + event.c \ group.c \ + group_map.c \ licenses.c \ pkgutils.c \ search.c \ Modified: soc2013/mattbw/backend/actions/install_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/install_packages.c Fri Jul 12 17:37:05 2013 (r254700) +++ soc2013/mattbw/backend/actions/install_packages.c Fri Jul 12 18:58:37 2013 (r254701) @@ -18,20 +18,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "../pk-backend.h" -#include "pkg.h" +#include /* gboolean */ +#include /* bool, true, false */ +#include "../pk-backend.h" /* pk..., Pk... */ +#include "pkg.h" /* pkg... */ +#include "../actions.h" /* install_packages_thread prototype */ +#include "../event.h" /* event_... */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ #include "../utils.h" /* INTENTIONALLY_IGNORE, ERR */ -#include "../actions.h" /* install_packages_thread prototype */ - static bool job (struct pkg_jobs *jobs, struct query *q); static bool sim_job(struct pkg_jobs *jobs, struct query *q); static bool solve_job(struct query *q, struct pkg_jobs *jobs); -static int install_event_cb(void *backend_v, struct pkg_event *event); /* * The thread that performs an InstallPackages operation. Should be invoked @@ -81,7 +81,7 @@ if (solve_job(q, jobs) == false) goto cleanup; - pkg_event_register(install_event_cb, backend); + pkg_event_register(event_cb, backend); (void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL); if (pkg_jobs_apply(jobs) != EPKG_OK) { @@ -155,103 +155,3 @@ return success; } - -/* - * Event handler for events emitted by pkg during an installation. TODO: Many - * of these events are unhandled or deficiently handled. - */ -static int -install_event_cb(void *backend_v, struct pkg_event *event) -{ - PkBackend *backend; - - backend = (PkBackend *)backend_v; - - switch (event->type) { - case PKG_EVENT_INSTALL_BEGIN: - STATUS(backend, PK_STATUS_ENUM_INSTALL); - pkgutils_emit(event->e_install_begin.pkg, - backend, - PK_INFO_ENUM_INSTALLING); - break; - case PKG_EVENT_INSTALL_FINISHED: - pkgutils_emit(event->e_install_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_DEINSTALL_BEGIN: - STATUS(backend, PK_STATUS_ENUM_REMOVE); - pkgutils_emit(event->e_deinstall_begin.pkg, - backend, - PK_INFO_ENUM_REMOVING); - break; - case PKG_EVENT_DEINSTALL_FINISHED: - pkgutils_emit(event->e_deinstall_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_UPGRADE_BEGIN: - STATUS(backend, PK_STATUS_ENUM_UPDATE); - pkgutils_emit(event->e_upgrade_begin.pkg, - backend, - PK_INFO_ENUM_UPDATING); - break; - case PKG_EVENT_UPGRADE_FINISHED: - pkgutils_emit(event->e_upgrade_finished.pkg, - backend, - PK_INFO_ENUM_FINISHED); - break; - case PKG_EVENT_FETCHING: - STATUS(backend, PK_STATUS_ENUM_DOWNLOAD); - break; - case PKG_EVENT_INTEGRITYCHECK_BEGIN: - case PKG_EVENT_INTEGRITYCHECK_FINISHED: - /* Unimplemented */ - break; - case PKG_EVENT_INTEGRITYCHECK_CONFLICT: - ERR(backend, - PK_ERROR_ENUM_PACKAGE_CORRUPT, - event->e_integrity_conflict.pkg_name); - break; - case PKG_EVENT_NEWPKGVERSION: - case PKG_EVENT_NOTICE: - case PKG_EVENT_INCREMENTAL_UPDATE: - /* Unimplemented */ - break; - case PKG_EVENT_ERROR: - /* - * This is sometimes used for nonfatal errors, so we can't - * throw an error code here. - */ - break; - case PKG_EVENT_ERRNO: - case PKG_EVENT_ARCHIVE_COMP_UNSUP: - case PKG_EVENT_ALREADY_INSTALLED: - case PKG_EVENT_FAILED_CKSUM: - case PKG_EVENT_CREATE_DB_ERROR: - case PKG_EVENT_LOCKED: - case PKG_EVENT_REQUIRED: - case PKG_EVENT_MISSING_DEP: - case PKG_EVENT_NOREMOTEDB: - case PKG_EVENT_NOLOCALDB: - /* Unimplemented */ - break; - case PKG_EVENT_FILE_MISMATCH: - ERR(backend, - PK_ERROR_ENUM_PACKAGE_CORRUPT, - pkg_file_path(event->e_file_mismatch.file)); - break; - case PKG_EVENT_DEVELOPER_MODE: - case PKG_EVENT_PLUGIN_ERRNO: - case PKG_EVENT_PLUGIN_ERROR: - case PKG_EVENT_PLUGIN_INFO: - /* Unimplemented */ - break; - case PKG_EVENT_NOT_FOUND: - ERR(backend, - PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, - event->e_not_found.pkg_name); - } - - return EPKG_OK; -} Added: soc2013/mattbw/backend/event.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/event.c Fri Jul 12 18:58:37 2013 (r254701) @@ -0,0 +1,126 @@ +/*- + * 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 "pk-backend.h" /* pk_..., Pk... */ +#include "pkg.h" /* pkg... */ + +#include "event.h" /* event_... */ +#include "pkgutils.h" /* pkgutils... */ +#include "utils.h" /* ERR, STATUS */ + +/* + * Event handler for events emitted by pkg during an installation. TODO: Many + * of these events are unhandled or deficiently handled. + */ +int +event_cb(void *backend_v, struct pkg_event *event) +{ + PkBackend *backend; + + backend = (PkBackend *)backend_v; + + switch (event->type) { + case PKG_EVENT_INSTALL_BEGIN: + STATUS(backend, PK_STATUS_ENUM_INSTALL); + pkgutils_emit(event->e_install_begin.pkg, + backend, + PK_INFO_ENUM_INSTALLING); + break; + case PKG_EVENT_INSTALL_FINISHED: + pkgutils_emit(event->e_install_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_DEINSTALL_BEGIN: + STATUS(backend, PK_STATUS_ENUM_REMOVE); + pkgutils_emit(event->e_deinstall_begin.pkg, + backend, + PK_INFO_ENUM_REMOVING); + break; + case PKG_EVENT_DEINSTALL_FINISHED: + pkgutils_emit(event->e_deinstall_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_UPGRADE_BEGIN: + STATUS(backend, PK_STATUS_ENUM_UPDATE); + pkgutils_emit(event->e_upgrade_begin.pkg, + backend, + PK_INFO_ENUM_UPDATING); + break; + case PKG_EVENT_UPGRADE_FINISHED: + pkgutils_emit(event->e_upgrade_finished.pkg, + backend, + PK_INFO_ENUM_FINISHED); + break; + case PKG_EVENT_FETCHING: + STATUS(backend, PK_STATUS_ENUM_DOWNLOAD); + break; + case PKG_EVENT_INTEGRITYCHECK_BEGIN: + case PKG_EVENT_INTEGRITYCHECK_FINISHED: + /* Unimplemented */ + break; + case PKG_EVENT_INTEGRITYCHECK_CONFLICT: + ERR(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + event->e_integrity_conflict.pkg_name); + break; + case PKG_EVENT_NEWPKGVERSION: + case PKG_EVENT_NOTICE: + case PKG_EVENT_INCREMENTAL_UPDATE: + /* Unimplemented */ + break; + case PKG_EVENT_ERROR: + /* + * This is sometimes used for nonfatal errors, so we can't + * throw an error code here. + */ + break; + case PKG_EVENT_ERRNO: + case PKG_EVENT_ARCHIVE_COMP_UNSUP: + case PKG_EVENT_ALREADY_INSTALLED: + case PKG_EVENT_FAILED_CKSUM: + case PKG_EVENT_CREATE_DB_ERROR: + case PKG_EVENT_LOCKED: + case PKG_EVENT_REQUIRED: + case PKG_EVENT_MISSING_DEP: + case PKG_EVENT_NOREMOTEDB: + case PKG_EVENT_NOLOCALDB: + /* Unimplemented */ + break; + case PKG_EVENT_FILE_MISMATCH: + ERR(backend, + PK_ERROR_ENUM_PACKAGE_CORRUPT, + pkg_file_path(event->e_file_mismatch.file)); + break; + case PKG_EVENT_DEVELOPER_MODE: + case PKG_EVENT_PLUGIN_ERRNO: + case PKG_EVENT_PLUGIN_ERROR: + case PKG_EVENT_PLUGIN_INFO: + /* Unimplemented */ + break; + case PKG_EVENT_NOT_FOUND: + ERR(backend, + PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, + event->e_not_found.pkg_name); + } + + return EPKG_OK; +} Added: soc2013/mattbw/backend/event.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/event.h Fri Jul 12 18:58:37 2013 (r254701) @@ -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 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. + */ + +#ifndef _PKGNG_BACKEND_EVENT_H_ +#define _PKGNG_BACKEND_EVENT_H_ + +#include "pkg.h" /* struct pkg_event */ + +int event_cb(void *backend, struct pkg_event *event); + +#endif /* !_PKGNG_BACKEND_EVENT_H_ */