socsvn commit: r254701 - in soc2013/mattbw/backend: . actions
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Fri Jul 12 18:58:38 UTC 2013
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 <glib.h>
-#include "../pk-backend.h"
-#include "pkg.h"
+#include <glib.h> /* gboolean */
+#include <stdbool.h> /* 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 <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 "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 <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.
+ */
+
+#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_ */
More information about the svn-soc-all
mailing list