socsvn commit: r255996 - in soc2013/mattbw/backend: . actions

From: <mattbw_at_FreeBSD.org>
Date: Thu, 15 Aug 2013 21:16:03 GMT
Author: mattbw
Date: Thu Aug 15 21:16:03 2013
New Revision: 255996
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255996

Log:
  Add stub GetDepends and GetImplements to the backend.
  
  These are now wired up to the query code, but need the actual package
  emitters making.  These should both use very similar code, so I'll probably
  factor it out as part of the query directory.
  

Modified:
  soc2013/mattbw/backend/actions/get_depends.c
  soc2013/mattbw/backend/actions/get_files.c
  soc2013/mattbw/backend/actions/get_requires.c
  soc2013/mattbw/backend/pk-backend-pkgng.c

Modified: soc2013/mattbw/backend/actions/get_depends.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_depends.c	Thu Aug 15 20:33:17 2013	(r255995)
+++ soc2013/mattbw/backend/actions/get_depends.c	Thu Aug 15 21:16:03 2013	(r255996)
_at__at_ -19,9 +19,16 _at__at_
  */
 #include <assert.h>		/* assert */
 #include <glib.h>		/* gboolean */
+#include <stdbool.h>		/* bool */
+#include "pkg.h"		/* PKG_..., struct pkg, etc. */
 #include "../pk-backend.h"	/* PkBackend */
 
 #include "../actions.h"		/* Prototype */
+#include "../query.h"		/* query_... */
+
+static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_DEPS;
+
+static bool	emit(struct pkg *pkg, const gchar *id, struct query *q);
 
 /*
  * The thread that performs a GetDepends operation. Should be invoked by the
_at__at_ -30,7 +37,27 _at__at_
 gboolean
 get_depends_thread(PkBackend *backend)
 {
+	bool		success;
 
 	assert(backend != NULL);
-	return FALSE;
+
+	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
+	success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit);
+
+	(void)pk_backend_finished(backend);
+	return success ? TRUE : FALSE;
+}
+
+static bool
+emit(struct pkg *pkg, const gchar *id, struct query *q)
+{
+
+	bool		success;
+
+	assert(pkg != NULL);
+	assert(id != NULL);
+	assert(q != NULL);
+
+	success = false;
+	return success;
 }

Modified: soc2013/mattbw/backend/actions/get_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_files.c	Thu Aug 15 20:33:17 2013	(r255995)
+++ soc2013/mattbw/backend/actions/get_files.c	Thu Aug 15 21:16:03 2013	(r255996)
_at__at_ -39,7 +39,7 _at__at_
 gboolean
 get_files_thread(PkBackend *backend)
 {
-	gboolean success;
+	bool		success;
 
 	assert(backend != NULL);
 

Modified: soc2013/mattbw/backend/actions/get_requires.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_requires.c	Thu Aug 15 20:33:17 2013	(r255995)
+++ soc2013/mattbw/backend/actions/get_requires.c	Thu Aug 15 21:16:03 2013	(r255996)
_at__at_ -20,9 +20,16 _at__at_
 
 #include <assert.h>		/* assert */
 #include <glib.h>		/* gboolean */
+#include <stdbool.h>		/* bool */
+#include "pkg.h"		/* PKG_..., struct pkg, etc. */
 #include "../pk-backend.h"	/* PkBackend */
 
 #include "../actions.h"		/* Prototype */
+#include "../query.h"		/* query_... */
+
+static const unsigned int LOAD_FLAGS = PKG_LOAD_BASIC | PKG_LOAD_RDEPS;
+
+static bool	emit(struct pkg *pkg, const gchar *id, struct query *q);
 
 /*
  * The thread that performs a GetRequires operation. Should be invoked by the
_at__at_ -31,7 +38,27 _at__at_
 gboolean
 get_requires_thread(PkBackend *backend)
 {
+	bool		success;
 
 	assert(backend != NULL);
-	return FALSE;
+
+	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
+	success = query_match_id_to_emitter(backend, LOAD_FLAGS, emit);
+
+	(void)pk_backend_finished(backend);
+	return success ? TRUE : FALSE;
+}
+
+static bool
+emit(struct pkg *pkg, const gchar *id, struct query *q)
+{
+
+	bool		success;
+
+	assert(pkg != NULL);
+	assert(id != NULL);
+	assert(q != NULL);
+
+	success = false;
+	return success;
 }

Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c	Thu Aug 15 20:33:17 2013	(r255995)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c	Thu Aug 15 21:16:03 2013	(r255996)
_at__at_ -87,6 +87,18 _at__at_
  */
 
 void
+pk_backend_get_depends(PkBackend *backend, PkBitfield filters,
+    gchar **package_ids, gboolean recursive)
+{
+
+	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
+	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
+	INTENTIONALLY_IGNORE(recursive);	/* retrieved from backend */
+	assert(backend != NULL);
+	THREAD(backend, get_depends_thread);
+}
+
+void
 pk_backend_get_details(PkBackend *backend, gchar **package_ids)
 {
 
_at__at_ -104,6 +116,18 _at__at_
 	THREAD(backend, get_files_thread);
 }
 
+void
+pk_backend_get_requires(PkBackend *backend, PkBitfield filters,
+    gchar **package_ids, gboolean recursive)
+{
+
+	INTENTIONALLY_IGNORE(filters);		/* retrieved from backend */
+	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
+	INTENTIONALLY_IGNORE(recursive);	/* retrieved from backend */
+	assert(backend != NULL);
+	THREAD(backend, get_requires_thread);
+}
+
 PkBitfield
 pk_backend_get_filters(PkBackend *backend)
 {
Received on Thu Aug 15 2013 - 21:16:04 UTC