socsvn commit: r256745 - in soc2013/mattbw/backend: . actions query
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Fri Aug 30 14:16:00 UTC 2013
Author: mattbw
Date: Fri Aug 30 14:15:59 2013
New Revision: 256745
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256745
Log:
Split emission functions from pkgutils.
This allows pkgutils to compile without pk_backend_*, which allows it to be
tested easily.
Added:
soc2013/mattbw/backend/emit.c
soc2013/mattbw/backend/emit.h
Modified:
soc2013/mattbw/backend/Makefile
soc2013/mattbw/backend/actions/install_files.c
soc2013/mattbw/backend/actions/resolve.c
soc2013/mattbw/backend/actions/search_files.c
soc2013/mattbw/backend/event.c
soc2013/mattbw/backend/jobs.c
soc2013/mattbw/backend/pkgutils.c
soc2013/mattbw/backend/pkgutils.h
soc2013/mattbw/backend/query/depends.c
soc2013/mattbw/backend/search.c
Modified: soc2013/mattbw/backend/Makefile
==============================================================================
--- soc2013/mattbw/backend/Makefile Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/Makefile Fri Aug 30 14:15:59 2013 (r256745)
@@ -24,6 +24,7 @@
SRCS= pk-backend-pkgng.c
SRCS+= \
db.c \
+ emit.c \
event.c \
group.c \
group_map.c \
Modified: soc2013/mattbw/backend/actions/install_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/install_files.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/actions/install_files.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -23,6 +23,7 @@
#include "pkg.h"
#include "../db.h" /* db_open_remote */
+#include "../emit.h" /* emit_package */
#include "../pkgutils.h" /* pkgutils_... */
#include "../utils.h" /* INTENTIONALLY_IGNORE */
@@ -80,7 +81,7 @@
"could not open file");
goto cleanup;
}
- pkgutils_emit(pkg, backend, pkgutils_pkg_install_state(pkg));
+ emit_package(pkg, backend, pkgutils_pkg_install_state(pkg));
success = TRUE;
} else {
@@ -89,7 +90,7 @@
db = db_open_remote(backend);
if (db == NULL)
goto cleanup;
-
+
(void)pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL);
if (pkg_add(db, path, PKG_FLAG_NONE, keys) != EPKG_OK) {
@@ -106,7 +107,7 @@
pkgdb_close(db);
pkg_free(pkg);
pkg_manifest_keys_free(keys);
-
+
return success;
}
Modified: soc2013/mattbw/backend/actions/resolve.c
==============================================================================
--- soc2013/mattbw/backend/actions/resolve.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/actions/resolve.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -22,11 +22,11 @@
#include "../pk-backend.h"
#include "pkg.h"
-#include "../db.h" /* db_open_remote */
-#include "../pkgutils.h" /* pkgutils_* */
+#include "../actions.h" /* resolve_thread prototype */
+#include "../emit.h" /* emit_package */
+#include "../pkgutils.h" /* pkgutils_... */
#include "../query.h" /* query_* */
#include "../utils.h" /* INTENTIONALLY_IGNORE */
-#include "../actions.h" /* resolve_thread prototype */
static bool emit(PkBackend *backend, struct pkgdb *db, struct pkg *pkg);
@@ -53,6 +53,6 @@
INTENTIONALLY_IGNORE(db);
- pkgutils_emit(pkg, backend, pkgutils_pkg_current_state(pkg));
+ emit_package(pkg, backend, pkgutils_pkg_current_state(pkg));
return true;
}
Modified: soc2013/mattbw/backend/actions/search_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/search_files.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/actions/search_files.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -25,6 +25,7 @@
#include "../actions.h" /* search_files_thread prototype */
#include "../db.h" /* db_open_remote */
+#include "../emit.h" /* emit_package */
#include "../utils.h" /* INTENTIONALLY_IGNORE */
#include "../pkgutils.h" /* pkgutils_... */
@@ -76,7 +77,7 @@
== EPKG_OK) {
assert(pkg != NULL);
- pkgutils_emit(pkg, backend,
+ emit_package(pkg, backend,
pkgutils_pkg_current_state(pkg));
at_least_one = true;
}
Added: soc2013/mattbw/backend/emit.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2013/mattbw/backend/emit.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -0,0 +1,46 @@
+
+
+#include <assert.h> /* assert */
+#include <glib.h> /* g_free, gchar */
+#include "pkg.h" /* struct pkg, pkg_get */
+
+#include "emit.h" /* emit_... */
+#include "pkgutils.h" /* pkgutils_... */
+
+/* Functions for emitting a package to the PackageKit daemon. */
+
+/*
+ * Emits a package through the backend with the given info enum.
+ */
+void
+emit_package(struct pkg *pkg, PkBackend *backend, PkInfoEnum info)
+{
+ char *comment;
+ gchar *id;
+
+ assert(pkg != NULL);
+ assert(backend != NULL);
+
+ comment = id = NULL;
+
+ pkg_get(pkg, PKG_COMMENT, &comment);
+ id = pkgutils_pkg_to_id(pkg);
+ (void)pk_backend_package(backend, info, id, comment);
+ g_free(id);
+}
+
+/*
+ * Emits a package if it satisfies the given filter set.
+ */
+void
+emit_filtered_package(struct pkg *pkg, PkBackend *backend, PkBitfield filters,
+ PkInfoEnum info)
+{
+
+ assert(pkg != NULL);
+ assert(backend != NULL);
+
+ if (pkgutils_pkg_matches_filters(pkg, filters)) {
+ emit_package(pkg, backend, info);
+ }
+}
Added: soc2013/mattbw/backend/emit.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2013/mattbw/backend/emit.h Fri Aug 30 14:15:59 2013 (r256745)
@@ -0,0 +1,30 @@
+/*-
+ * 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_EMIT_H_
+#define _PKGNG_BACKEND_EMIT_H_
+
+#include "pk-backend.h" /* Pk... */
+#include "pkg.h" /* pkg... */
+
+void emit_package(struct pkg *pkg, PkBackend *backend, PkInfoEnum info);
+void emit_filtered_package(struct pkg *pkg, PkBackend *backend, PkBitfield filters, PkInfoEnum info);
+
+#endif /* !_PKGNG_BACKEND_EMIT_H_ */
Modified: soc2013/mattbw/backend/event.c
==============================================================================
--- soc2013/mattbw/backend/event.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/event.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -22,8 +22,8 @@
#include "pk-backend.h" /* pk_..., Pk... */
#include "pkg.h" /* pkg... */
+#include "emit.h" /* emit... */
#include "event.h" /* event_... */
-#include "pkgutils.h" /* pkgutils... */
#include "utils.h" /* ERR, STATUS */
/*
@@ -43,34 +43,34 @@
switch (event->type) {
case PKG_EVENT_INSTALL_BEGIN:
STATUS(backend, PK_STATUS_ENUM_INSTALL);
- pkgutils_emit(event->e_install_begin.pkg,
+ emit_package(event->e_install_begin.pkg,
backend,
PK_INFO_ENUM_INSTALLING);
break;
case PKG_EVENT_INSTALL_FINISHED:
- pkgutils_emit(event->e_install_finished.pkg,
+ emit_package(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,
+ emit_package(event->e_deinstall_begin.pkg,
backend,
PK_INFO_ENUM_REMOVING);
break;
case PKG_EVENT_DEINSTALL_FINISHED:
- pkgutils_emit(event->e_deinstall_finished.pkg,
+ emit_package(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,
+ emit_package(event->e_upgrade_begin.pkg,
backend,
PK_INFO_ENUM_UPDATING);
break;
case PKG_EVENT_UPGRADE_FINISHED:
- pkgutils_emit(event->e_upgrade_finished.pkg,
+ emit_package(event->e_upgrade_finished.pkg,
backend,
PK_INFO_ENUM_FINISHED);
break;
Modified: soc2013/mattbw/backend/jobs.c
==============================================================================
--- soc2013/mattbw/backend/jobs.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/jobs.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -28,6 +28,7 @@
#include "pkg.h" /* pkg_... */
#include "db.h" /* db_... */
+#include "emit.h" /* emit_package */
#include "event.h" /* event_cb */
#include "utils.h" /* ERR, type_of_repo_name */
#include "jobs.h" /* jobs_... */
@@ -146,7 +147,7 @@
pkg = NULL;
while (pkg_jobs(jobs, &pkg) == EPKG_OK) {
assert(pkg != NULL);
- pkgutils_emit(pkg, backend, info(pkg));
+ emit_package(pkg, backend, info(pkg));
}
}
Modified: soc2013/mattbw/backend/pkgutils.c
==============================================================================
--- soc2013/mattbw/backend/pkgutils.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/pkgutils.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -28,7 +28,7 @@
#include "pkgutils.h" /* Prototypes */
#include "utils.h" /* INTENTIONALLY_IGNORE */
-static bool pkg_matches_filters(struct pkg *pkg, PkBitfield filters);
+
static const char *repo_of_remote(struct pkg *pkg);
/* Package utility functions that do not depend on PackageKit. */
@@ -215,44 +215,8 @@
assert (old_p == NULL || pkg2 == NULL || *old_p != NULL);
}
-/*
- * Emits a package through the backend with the given info enum.
- */
-void
-pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info)
-{
- char *comment;
- gchar *id;
-
- assert(pkg != NULL);
- assert(backend != NULL);
-
- comment = id = NULL;
-
- pkg_get(pkg, PKG_COMMENT, &comment);
- id = pkgutils_pkg_to_id(pkg);
- (void)pk_backend_package(backend, info, id, comment);
- g_free(id);
-}
-
-/*
- * Emits a package if it satisfies the given filter set.
- */
-void
-pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters,
- PkInfoEnum info)
-{
-
- assert(pkg != NULL);
- assert(backend != NULL);
-
- if (pkg_matches_filters(pkg, filters)) {
- pkgutils_emit(pkg, backend, info);
- }
-}
-
-static bool
-pkg_matches_filters(struct pkg *pkg, PkBitfield filters)
+bool
+pkgutils_pkg_matches_filters(struct pkg *pkg, PkBitfield filters)
{
bool matches_filters;
PkFilterEnum wrong_filter;
Modified: soc2013/mattbw/backend/pkgutils.h
==============================================================================
--- soc2013/mattbw/backend/pkgutils.h Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/pkgutils.h Fri Aug 30 14:15:59 2013 (r256745)
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef _PKGNG_BACKEND_PKGUTILS_H_
-#define _PKGNG_BACKEND_PKGUTILS_H_
+#ifndef _PKGNG_BACKEND_PKGUTILS_H_
+#define _PKGNG_BACKEND_PKGUTILS_H_
#include <glib.h>
#include "pk-backend.h"
@@ -28,11 +28,10 @@
PkInfoEnum pkgutils_pkg_current_state(struct pkg *pkg);
PkInfoEnum pkgutils_pkg_install_state(struct pkg *pkg);
PkInfoEnum pkgutils_pkg_remove_state(struct pkg *pkg);
+bool pkgutils_pkg_matches_filters(struct pkg *pkg, PkBitfield filters);
char *pkgutils_package_id_namever(gchar *package_id);
const char *pkgutils_pk_repo_of(struct pkg *pkg);
gchar *pkgutils_pkg_to_id(struct pkg *pkg);
void pkgutils_add_old_version(struct pkgdb *db, struct pkg *pkg, struct pkg **old_p);
-void pkgutils_emit(struct pkg *pkg, PkBackend *backend, PkInfoEnum info);
-void pkgutils_emit_filtered(struct pkg *pkg, PkBackend *backend, PkBitfield filters, PkInfoEnum info);
#endif /* !_PKGNG_BACKEND_PKGUTILS_H_ */
Modified: soc2013/mattbw/backend/query/depends.c
==============================================================================
--- soc2013/mattbw/backend/query/depends.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/query/depends.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -23,6 +23,7 @@
#include "pkg.h" /* pkg... */
#include "../pk-backend.h" /* PkBackend */
+#include "../emit.h" /* emit_package */
#include "../pkgutils.h" /* pkgutils_... */
#include "../utils.h" /* ERR */
#include "depends.h" /* query_depends_... */
@@ -60,7 +61,7 @@
package = id_to_package(package_id, db, load_flags);
if (package == NULL) {
- pkgutils_emit(pkg, backend,
+ emit_package(pkg, backend,
pkgutils_pkg_current_state(pkg));
success = true;
} else {
Modified: soc2013/mattbw/backend/search.c
==============================================================================
--- soc2013/mattbw/backend/search.c Fri Aug 30 13:25:15 2013 (r256744)
+++ soc2013/mattbw/backend/search.c Fri Aug 30 14:15:59 2013 (r256745)
@@ -22,6 +22,7 @@
#include <stdbool.h> /* bool */
#include "pkg.h" /* pkg_... */
+#include "emit.h" /* emit_... */
#include "pkgutils.h" /* pkgutils_... */
#include "search.h" /* search_... */
@@ -53,7 +54,7 @@
assert(pkg != NULL);
pkgutils_add_old_version(search->db, pkg, NULL);
- pkgutils_emit_filtered(pkg,
+ emit_filtered_package(pkg,
search->backend,
search->filters,
pkgutils_pkg_current_state(pkg));
@@ -62,7 +63,7 @@
success = true;
pkg_free(pkg);
}
-
+
pkgdb_it_free(it);
return success;
}
More information about the svn-soc-all
mailing list