Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Aug 2013 18:01:52 GMT
From:      mattbw@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r255542 - in soc2013/mattbw/backend: . actions query
Message-ID:  <201308051801.r75I1q19038491@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mattbw
Date: Mon Aug  5 18:01:52 2013
New Revision: 255542
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255542

Log:
  Remove query/jobs.[ch].
  
  This code is no longer needed due to being replaced with jobs.[ch].
  
  The query structures and invocations have been simplified a bit by removing
  job related elements, but the three-file split remains for now.  As
  query/match.c has only one function left it's probably best to merge the
  query functions into one unit again.
  

Deleted:
  soc2013/mattbw/backend/query/jobs.c
  soc2013/mattbw/backend/query/jobs.h
Modified:
  soc2013/mattbw/backend/Makefile
  soc2013/mattbw/backend/actions/resolve.c
  soc2013/mattbw/backend/query.h
  soc2013/mattbw/backend/query/core.c
  soc2013/mattbw/backend/query/core.h
  soc2013/mattbw/backend/query/match.c
  soc2013/mattbw/backend/query/match.h

Modified: soc2013/mattbw/backend/Makefile
==============================================================================
--- soc2013/mattbw/backend/Makefile	Mon Aug  5 16:16:50 2013	(r255541)
+++ soc2013/mattbw/backend/Makefile	Mon Aug  5 18:01:52 2013	(r255542)
@@ -51,7 +51,6 @@
 SRCS+=						\
 		query/core.c			\
 		query/do.c			\
-		query/jobs.c			\
 		query/match.c
 
 LIBDIR=		/usr/local/lib/packagekit-backend

Modified: soc2013/mattbw/backend/actions/resolve.c
==============================================================================
--- soc2013/mattbw/backend/actions/resolve.c	Mon Aug  5 16:16:50 2013	(r255541)
+++ soc2013/mattbw/backend/actions/resolve.c	Mon Aug  5 18:01:52 2013	(r255542)
@@ -41,9 +41,8 @@
 	struct query_target t;
 
 	s.type = QUERY_BACKEND_MIXED;
-	t.type = QUERY_EMIT;
-	t.emit.load_flags = PKG_LOAD_BASIC;
-	t.emit.f = emit;
+	t.load_flags = PKG_LOAD_BASIC;
+	t.f = emit;
 
 	success = query_do(backend, &s, &t);
 

Modified: soc2013/mattbw/backend/query.h
==============================================================================
--- soc2013/mattbw/backend/query.h	Mon Aug  5 16:16:50 2013	(r255541)
+++ soc2013/mattbw/backend/query.h	Mon Aug  5 18:01:52 2013	(r255542)
@@ -24,7 +24,6 @@
 /* Meta-header for the public interfaces to the query system. */
 
 #include "query/do.h"		/* query_do_... */
-#include "query/jobs.h"		/* query_jobs_... */
 #include "query/match.h"	/* query_match_... */
 
 #endif				/* !_PKGNG_BACKEND_QUERY_H_ */

Modified: soc2013/mattbw/backend/query/core.c
==============================================================================
--- soc2013/mattbw/backend/query/core.c	Mon Aug  5 16:16:50 2013	(r255541)
+++ soc2013/mattbw/backend/query/core.c	Mon Aug  5 18:01:52 2013	(r255542)
@@ -30,7 +30,6 @@
 #include "../utils.h"		/* string_match */
 #include "../pkgutils.h"	/* pkgutils_... */
 #include "core.h"		/* Prototypes */
-#include "jobs.h"		/* query_jobs...*/
 
 enum repo_type {
 	REPO_INVALID,
@@ -52,7 +51,6 @@
 };
 
 static bool	can_remote_iterate(struct query *q);
-static bool	emit(struct pkg *pkg, const char *match_id, struct query *q);
 static enum repo_type type_of_repo_name(const char *name);
 static gchar   *match_pkg(struct pkg *pkg, struct query *q);
 static gchar  **init_unpack_source(PkBackend *backend, struct query_source *s);
@@ -135,7 +133,7 @@
 		    PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
 		    "package not found");
 	else
-		emit(pkg, match_id, q);
+		success = q->t->f(pkg, match_id, q);
 
 	pkg_free(pkg);
 	g_free(match_id);
@@ -284,8 +282,7 @@
 	 * Stop pkg from catching fire if we try to load files from
 	 * non-installed packages.
 	 */
-	if (q->t->type == QUERY_EMIT &&
-	    (q->t->emit.load_flags & PKG_LOAD_FILES)) {
+	if (q->t->load_flags & PKG_LOAD_FILES) {
 		ERR(q->backend,
 		    PK_ERROR_ENUM_CANNOT_GET_FILELIST,
 		    "cannot get files for remote package");
@@ -295,30 +292,6 @@
 }
 
 /*
- * Sends a query result to the appropriate emitter.
- */
-static bool
-emit(struct pkg *pkg, const char *match_id, struct query *q)
-{
-	bool		success;
-
-	assert(match_id != NULL);
-	assert(pkg != NULL);
-	assert(q != NULL);
-
-	switch(q->t->type) {
-	case QUERY_EMIT:
-		success = q->t->emit.f(pkg, match_id, q);
-		break;
-	case QUERY_JOB:
-		success = query_jobs_run(q, pkg, q->t->job.type, q->t->job.f);
-		break;
-	}
-
-	return success;
-}
-
-/*
  * Finds the type of the given PackageKit repository name.
  */
 static enum repo_type
@@ -370,19 +343,15 @@
 static struct pkg *
 match_iterator(struct pkgdb_it *it, struct query *q, gchar **match_id_p)
 {
-	unsigned int	load_flags;
 	gchar          *match_id;
 	struct pkg     *pkg;
 
 	assert(it != NULL);
 	assert(q != NULL);
 
-	load_flags = (q->t->type == QUERY_EMIT) ?
-	    q->t->emit.load_flags : PKG_LOAD_BASIC;
-
 	match_id = NULL;
 	pkg = NULL;
-	while (pkgdb_it_next(it, &pkg, load_flags) == EPKG_OK) {
+	while (pkgdb_it_next(it, &pkg, q->t->load_flags) == EPKG_OK) {
 		match_id = match_pkg(pkg, q);
 		/* Did it match? */
 		if (match_id != NULL)

Modified: soc2013/mattbw/backend/query/core.h
==============================================================================
--- soc2013/mattbw/backend/query/core.h	Mon Aug  5 16:16:50 2013	(r255541)
+++ soc2013/mattbw/backend/query/core.h	Mon Aug  5 18:01:52 2013	(r255542)
@@ -28,7 +28,6 @@
 struct query;
 
 typedef		bool   (*emit_ptr) (struct pkg *pkg, const gchar *id, struct query *q);
-typedef		bool   (*job_emit_ptr) (struct pkg_jobs *jobs, struct query *q);
 typedef		bool   (*query_body_ptr) (struct query *q);
 
 /*
@@ -41,11 +40,6 @@
 	QUERY_BACKEND_MIXED	/* As above but treat non-PackeIDs as names. */
 };
 
-enum query_target_type {
-	QUERY_EMIT,
-	QUERY_JOB
-};
-
 /* Holds information about where the query package is coming from. */
 struct query_source {
 	enum query_source_type type;
@@ -61,17 +55,8 @@
 
 /* Holds information about where the result of a query should go. */
 struct query_target {
-	enum query_target_type type;
-	union {
-		struct {
-			unsigned int	load_flags;
-			emit_ptr	f;
-		}		emit;
-		struct {
-			pkg_jobs_t	type;
-			job_emit_ptr	f;
-		}		job;
-	};
+	unsigned int	load_flags;
+	emit_ptr	f;
 };
 
 PkBackend      *query_backend(struct query *q);

Modified: soc2013/mattbw/backend/query/match.c
==============================================================================
--- soc2013/mattbw/backend/query/match.c	Mon Aug  5 16:16:50 2013	(r255541)
+++ soc2013/mattbw/backend/query/match.c	Mon Aug  5 18:01:52 2013	(r255542)
@@ -42,33 +42,8 @@
 	s.total = 1;
 	s.type = QUERY_BACKEND_IDS;
 
-	t.emit.f = emitter;
-	t.emit.load_flags = load_flags;
-	t.type = QUERY_EMIT;
-
-	return query_do(backend, &s, &t);
-}
-
-/*
- * Runs a query over the PackageIDs selected in the backend that converts the
- * first match into a job of the given type and hands it to a function for
- * solving and applying.
- */
-bool
-query_match_id_to_job(PkBackend *backend, pkg_jobs_t type,
-    job_emit_ptr emitter)
-{
-	struct query_source s;
-	struct query_target t;
-
-	s.unused = true;
-	s.position = 0;
-	s.total = 1;
-	s.type = QUERY_BACKEND_IDS;
-
-	t.job.f = emitter;
-	t.job.type = type;
-	t.type = QUERY_JOB;
+	t.f = emitter;
+	t.load_flags = load_flags;
 
 	return query_do(backend, &s, &t);
 }

Modified: soc2013/mattbw/backend/query/match.h
==============================================================================
--- soc2013/mattbw/backend/query/match.h	Mon Aug  5 16:16:50 2013	(r255541)
+++ soc2013/mattbw/backend/query/match.h	Mon Aug  5 18:01:52 2013	(r255542)
@@ -28,6 +28,5 @@
 #include "core.h"		/* *_ptr */
 
 bool		query_match_id_to_emitter(PkBackend *backend, unsigned int load_flags, emit_ptr emitter);
-bool		query_match_id_to_job(PkBackend *backend, pkg_jobs_t type, job_emit_ptr job_emitter);
 
 #endif				/* !_PKGNG_BACKEND_QUERY_MATCH_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308051801.r75I1q19038491>