[packagekit] packagekit: Branch 'master' - 2 commits

Richard Hughes hughsient at kemper.freedesktop.org
Sat Oct 13 11:30:25 PDT 2007


 TODO                          |    3 
 client/pk-monitor.c           |    2 
 libpackagekit/Makefile.am     |    6 -
 libpackagekit/pk-client.c     |    2 
 libpackagekit/pk-common.c     |  235 ++++++++++++++++++++++++++++++++++++++++++
 libpackagekit/pk-common.h     |   37 ++++++
 libpackagekit/pk-connection.c |    2 
 libpackagekit/pk-job-list.c   |    2 
 libpackagekit/pk-task-list.c  |    2 
 src/pk-engine.c               |    4 
 tools/rpmbuild.sh             |    1 
 11 files changed, 283 insertions(+), 13 deletions(-)

New commits:
diff-tree a5423c9989f746aeb3448f5844a3736bbf53bf29 (from 7cead68670fc43c60980ab55bc0ea82df3d20495)
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Oct 13 19:29:00 2007 +0100

    rename pk-task-common to pk-common as I want to abstract some stuff later

diff --git a/client/pk-monitor.c b/client/pk-monitor.c
index 2a19321..ae6f4e9 100644
--- a/client/pk-monitor.c
+++ b/client/pk-monitor.c
@@ -29,7 +29,7 @@
 #include <dbus/dbus-glib.h>
 
 #include <pk-debug.h>
-#include <pk-task-common.h>
+#include <pk-common.h>
 #include <pk-task-list.h>
 #include <pk-connection.h>
 
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index e2bae47..9249292 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -33,7 +33,7 @@ libpackagekit_include_HEADERS =					\
 	pk-package-list.h					\
 	pk-enum-list.h						\
 	pk-enum.h						\
-	pk-task-common.h					\
+	pk-common.h						\
 	pk-client.h						\
 	pk-task-list.h						\
 	pk-job-list.h						\
@@ -57,8 +57,8 @@ libpackagekit_la_SOURCES =					\
 	pk-enum-list.h						\
 	pk-enum.h						\
 	pk-enum.c						\
-	pk-task-common.c					\
-	pk-task-common.h					\
+	pk-common.c						\
+	pk-common.h						\
 	pk-client.c						\
 	pk-client.h						\
 	pk-task-list.c						\
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 4e625c4..a5ef61d 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -40,7 +40,7 @@
 #include "pk-debug.h"
 #include "pk-marshal.h"
 #include "pk-polkit-client.h"
-#include "pk-task-common.h"
+#include "pk-common.h"
 
 static void     pk_client_class_init	(PkClientClass *klass);
 static void     pk_client_init		(PkClient      *client);
diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
new file mode 100644
index 0000000..8b4e2a5
--- /dev/null
+++ b/libpackagekit/pk-common.c
@@ -0,0 +1,235 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <string.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h>
+
+#include "pk-debug.h"
+#include "pk-common.h"
+
+/**
+ * pk_filter_check_part:
+ **/
+gboolean
+pk_filter_check_part (const gchar *filter)
+{
+	if (filter == NULL) {
+		return FALSE;
+	}
+	if (strlen (filter) == 0) {
+		return FALSE;
+	}
+	if (strcmp (filter, "none") == 0) {
+		return TRUE;
+	}
+	if (strcmp (filter, "installed") == 0) {
+		return TRUE;
+	}
+	if (strcmp (filter, "~installed") == 0) {
+		return TRUE;
+	}
+	if (strcmp (filter, "devel") == 0) {
+		return TRUE;
+	}
+	if (strcmp (filter, "~devel") == 0) {
+		return TRUE;
+	}
+	if (strcmp (filter, "gui") == 0) {
+		return TRUE;
+	}
+	if (strcmp (filter, "~gui") == 0) {
+		return TRUE;
+	}
+	return FALSE;
+}
+
+/**
+ * pk_filter_check:
+ **/
+gboolean
+pk_filter_check (const gchar *filter)
+{
+	gchar **sections;
+	guint i;
+	guint length;
+	gboolean ret;
+
+	if (filter == NULL) {
+		pk_warning ("filter null");
+		return FALSE;
+	}
+	if (strlen (filter) == 0) {
+		pk_warning ("filter zero length");
+		return FALSE;
+	}
+
+	/* split by delimeter ';' */
+	sections = g_strsplit (filter, ";", 0);
+	length = g_strv_length (sections);
+	ret = FALSE;
+	for (i=0; i<length; i++) {
+		/* only one wrong part is enough to fail the filter */
+		if (strlen (sections[i]) == 0) {
+			goto out;
+		}
+		if (pk_filter_check_part (sections[i]) == FALSE) {
+			goto out;
+		}
+	}
+	ret = TRUE;
+out:
+	g_strfreev (sections);
+	return ret;
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_task_common (LibSelfTest *test)
+{
+	gboolean ret;
+	gchar *text;
+	const gchar *temp;
+
+	if (libst_start (test, "PkTaskCommon", CLASS_AUTO) == FALSE) {
+		return;
+	}
+
+	/************************************************************
+	 ****************          FILTERS         ******************
+	 ************************************************************/
+	temp = NULL;
+	libst_title (test, "test a fail filter (null)");
+	ret = pk_filter_check (temp);
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "passed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "";
+	libst_title (test, "test a fail filter ()");
+	ret = pk_filter_check (temp);
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "passed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = ";";
+	libst_title (test, "test a fail filter (;)");
+	ret = pk_filter_check (temp);
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "passed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "moo";
+	libst_title (test, "test a fail filter (invalid)");
+	ret = pk_filter_check (temp);
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "passed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "moo;foo";
+	libst_title (test, "test a fail filter (invalid, multiple)");
+	ret = pk_filter_check (temp);
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "passed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "gui;;";
+	libst_title (test, "test a fail filter (valid then zero length)");
+	ret = pk_filter_check (temp);
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "passed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "none";
+	libst_title (test, "test a pass filter (none)");
+	ret = pk_filter_check (temp);
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "failed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "gui";
+	libst_title (test, "test a pass filter (single)");
+	ret = pk_filter_check (temp);
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "failed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "devel;~gui";
+	libst_title (test, "test a pass filter (multiple)");
+	ret = pk_filter_check (temp);
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "failed the filter '%s'", temp);
+	}
+
+	/************************************************************/
+	temp = "~gui;~installed";
+	libst_title (test, "test a pass filter (multiple2)");
+	ret = pk_filter_check (temp);
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "failed the filter '%s'", temp);
+	}
+
+	libst_end (test);
+}
+#endif
+
diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
new file mode 100644
index 0000000..7cffabd
--- /dev/null
+++ b/libpackagekit/pk-common.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PK_TASK_COMMON_H
+#define __PK_TASK_COMMON_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define	PK_DBUS_SERVICE			"org.freedesktop.PackageKit"
+#define	PK_DBUS_PATH			"/org/freedesktop/PackageKit"
+#define	PK_DBUS_INTERFACE		"org.freedesktop.PackageKit"
+
+gboolean	 pk_filter_check			(const gchar	*filter);
+
+G_END_DECLS
+
+#endif /* __PK_TASK_COMMON_H */
diff --git a/libpackagekit/pk-connection.c b/libpackagekit/pk-connection.c
index e557363..df16135 100644
--- a/libpackagekit/pk-connection.c
+++ b/libpackagekit/pk-connection.c
@@ -36,7 +36,7 @@
 #include <libgbus.h>
 
 #include "pk-debug.h"
-#include "pk-task-common.h"
+#include "pk-common.h"
 #include "pk-connection.h"
 
 #define PK_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_CONNECTION, PkConnectionPrivate))
diff --git a/libpackagekit/pk-job-list.c b/libpackagekit/pk-job-list.c
index 0b5a1db..18aeb28 100644
--- a/libpackagekit/pk-job-list.c
+++ b/libpackagekit/pk-job-list.c
@@ -35,7 +35,7 @@
 
 #include "pk-debug.h"
 #include "pk-marshal.h"
-#include "pk-task-common.h"
+#include "pk-common.h"
 #include "pk-connection.h"
 #include "pk-job-list.h"
 
diff --git a/libpackagekit/pk-task-list.c b/libpackagekit/pk-task-list.c
index d1f0ea0..88ac84f 100644
--- a/libpackagekit/pk-task-list.c
+++ b/libpackagekit/pk-task-list.c
@@ -36,7 +36,7 @@
 #include "pk-debug.h"
 #include "pk-marshal.h"
 #include "pk-client.h"
-#include "pk-task-common.h"
+#include "pk-common.h"
 #include "pk-task-list.h"
 #include "pk-job-list.h"
 
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 40a57f4..334e1b8 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -42,7 +42,7 @@
 #include <pk-package-list.h>
 
 #include <pk-debug.h>
-#include <pk-task-common.h>
+#include <pk-common.h>
 #include <pk-package-list.h>
 #include <pk-enum.h>
 
@@ -909,7 +909,7 @@ pk_engine_filter_check (const gchar *fil
 	gboolean ret;
 
 	/* check for invalid filter */
-	ret = pk_task_filter_check (filter);
+	ret = pk_filter_check (filter);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_FILTER_INVALID,
 			     "Filter '%s' is invalid", filter);
diff-tree 7cead68670fc43c60980ab55bc0ea82df3d20495 (from d03576b966664299169148eb4819952d80a03882)
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Oct 13 18:39:51 2007 +0100

    update TODO

diff --git a/TODO b/TODO
index 556bdfc..a18fb9a 100644
--- a/TODO
+++ b/TODO
@@ -23,6 +23,3 @@ To do rollbacks sanely in PK we need a f
  * write pk_transaction_id_equal to not compare data
  * allow transaction data to be changed in _db
 
-*** Integrate with gnome-power-manager to prevent shutdown ***
-do the g-p-m client stuff ALSO in the client program (for nice error message)
-
diff --git a/tools/rpmbuild.sh b/tools/rpmbuild.sh
index dbeca1f..28787f3 100755
--- a/tools/rpmbuild.sh
+++ b/tools/rpmbuild.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+sudo echo "Build!"
 #autobuild.sh all PolicyKit
 #sudo auto_refresh_from_repo.sh
 #autobuild.sh all PolicyKit-gnome



More information about the PackageKit mailing list