[Galago-commits] r2346 - in trunk/libgalago: . libgalago tests

galago-commits at freedesktop.org galago-commits at freedesktop.org
Sun Nov 27 21:01:49 PST 2005


Author: chipx86
Date: 2005-11-27 21:00:32 -0800 (Sun, 27 Nov 2005)
New Revision: 2346

Removed:
   trunk/libgalago/libgalago/galago-log.c
   trunk/libgalago/libgalago/galago-log.h
Modified:
   trunk/libgalago/ChangeLog
   trunk/libgalago/NEWS
   trunk/libgalago/libgalago/Makefile.am
   trunk/libgalago/libgalago/galago-account.c
   trunk/libgalago/libgalago/galago-assert.h
   trunk/libgalago/libgalago/galago-context.c
   trunk/libgalago/libgalago/galago-core.c
   trunk/libgalago/libgalago/galago-dbus.c
   trunk/libgalago/libgalago/galago-object.c
   trunk/libgalago/libgalago/galago-person.c
   trunk/libgalago/libgalago/galago-presence.c
   trunk/libgalago/libgalago/galago-service.c
   trunk/libgalago/libgalago/galago-status.c
   trunk/libgalago/libgalago/galago.h
   trunk/libgalago/tests/check-libgalago.c
Log:
Some updates from this week and on the train:
- Move to an idle model where you record the time the idle state began instead of constantly updating the idle time length. This is untested due to lack of time, but should work :) Yay massive development trees.
- Update the NEWS with what's been done so far for 0.5.0.
- Use the glib logging functions instead of our own. The old galago_log_* functions have been removed.


Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/ChangeLog	2005-11-28 05:00:32 UTC (rev 2346)
@@ -1,3 +1,27 @@
+Sun Nov 27 15:17:27 PST 2005  Christian Hammond <chipx86 at chipx86.com>
+
+	* libgalago/Makefile.am:
+	D libgalago/galago-log.c:
+	D libgalago/galago-log.h:
+	* libgalago/galago-account.c:
+	* libgalago/galago-assert.h:
+	* libgalago/galago-context.c:
+	* libgalago/galago-core.c:
+	* libgalago/galago-dbus.c:
+	* libgalago/galago.h:
+	* libgalago/galago-object.c:
+	* libgalago/galago-person.c:
+	* libgalago/galago-presence.c:
+	* libgalago/galago-service.c:
+	* libgalago/galago-status.c:
+	* tests/check-libgalago.c:
+	  - Use the glib logging functions instead of our own.
+
+Sun Nov 27 14:51:52 PST 2005  Christian Hammond <chipx86 at chipx86.com>
+
+	* NEWS:
+	  - Update the NEWS with what's been done so far for 0.5.0.
+
 Thu Nov 24 17:20:00 PST 2005  Christian Hammond <chipx86 at chipx86.com>
 
 	* libgalago/galago-core.c:
@@ -605,6 +629,8 @@
 	* libgalago/galago-object.c:
 	  - Include galago-log.h so we don't warn when using galago_log_*.
 
+==================== 0.3.3 ====================
+
 Sat Aug 27 21:28:51 PDT 2005  Christian Hammond <chipx86 at gnupdate.org>
 
 	* debian/changelog:

Modified: trunk/libgalago/NEWS
===================================================================
--- trunk/libgalago/NEWS	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/NEWS	2005-11-28 05:00:32 UTC (rev 2346)
@@ -1,3 +1,84 @@
+version 0.5.0:
+	* Significantly rewrote libgalago to be glib-based.
+	* Now requires D-BUS 0.36 or higher.
+	* Improved the unit tests a little bit. This still needs a lot of work.
+	* "Added" signals are no longer blocked when retrieving a list of new
+	  objects. Updated the docs to warn about potential problems in the users'
+	  code that they should know about.
+
+	GLib port:
+		- Replaced the home-brewn object model with GObject.
+		- Removed several utility functions and data structures in favor of
+		  the glib equivalents.
+		- Replaced many custom or D-BUS data types with glib equivalents.
+		- Worked to make the library easily bindable in most languages.
+		- galago_glib_init() is no longer needed.
+		- Removed galago_init_with_mainloop(). Users of toolkits with other
+		  mainloops should integrate the glib mainloop for now.
+		- Removed the logging API. The glib logging API is now being used
+		  instead.
+
+	Object model:
+		- Gave most objects GObject properties.
+		- Added support for D-BUS signatures to the objects.
+		- Removed the "native" and "foreign" terms and replaced them with
+		  the more politically correct and easier to understand "local" and
+		  "remote." Objects that took a "native" boolean now take either
+		  a GALAGO_LOCAL or GALAGO_REMOTE flag. This is called its "origin."
+		- Every object now has an origin set, which can be retrieved with
+		  galago_object_get_origin().
+
+	Protocol:
+		- Switched to requiring D-BUS 0.36.
+		- Moved from our hacky fake arrays to true D-BUS arrays.
+		- Encased such data as property values into VARIANT types.
+		- Removed Avatar and Photo objects.
+		- Added an Image object.
+
+	GalagoAccount:
+		- galago_account_new() has been removed.
+		  galago_service_create_account() should now be used.
+		- galago_account_{set,get}_avatar() now takes/returns a GalagoImage *.
+		- Merged the "connected" and "disconnected" signals into a
+		  "connection-state-changed" signal.
+
+	GalagoAvatar:
+		- Removed in favor of GalagoImage.
+
+	GalagoImage:
+		- Added galago_image_new_from_file() and galago_image_new_from_data().
+		- Renamed galago_image_{set,get}_image_data() to
+		  galago_image_{set,get}_data().
+
+	GalagoPerson:
+		- galago_person_new() has been removed. galago_create_person()
+		  should now be used.
+		- galago_person_me_new() has been removed. The "me" person is
+		  persistent and can always be retrieved with galago_get_me().
+		- Clients can no longer create a foreign person.
+		- Added a UID property. All feeds must set this property.
+		- Removed the concept of unique persistent person IDs. Now the UID
+		  property should be used,
+		- Re-implemented the "account-added" and "account-removed" signals.
+		- galago_person_{set,get}_photo() now takes/returns a GalagoImage *.
+
+	GalagoPhoto:
+		- Removed in favor of GalagoImage.
+
+	GalagoPresence:
+		- galago_presence_new() has been removed.
+		  galago_account_create_presence() should now be used.
+		- Moved to an idle model where instead of constantly updating the
+		  idle time length, we simply set the time the idle state began.
+		  This requires less work from the feed's side, reduces noise on the
+		  bus, and provides for more accurate idle time length calculations
+		  (since it's just current_time - began_idle_time).
+
+	GalagoService:
+		- galago_service_new() has been removed.
+		  galago_create_service() should now be used.
+		- Clients can no longer create a foreign service.
+
 version 0.3.3 (August 27, 2005):
 	* Confirmed to work with D-BUS 0.22.
 	* Fixes several D-BUS 0.3x issues with array iterators. This closes bugs

Modified: trunk/libgalago/libgalago/Makefile.am
===================================================================
--- trunk/libgalago/libgalago/Makefile.am	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/Makefile.am	2005-11-28 05:00:32 UTC (rev 2346)
@@ -15,7 +15,6 @@
 	galago-context-base.h \
 	galago-dbus.h \
 	galago-image.h \
-	galago-log.h \
 	galago-object.h \
 	galago-person.h \
 	galago-presence.h \
@@ -45,7 +44,6 @@
 	galago-dbus.c \
 	galago-enum-types.c \
 	galago-image.c \
-	galago-log.c \
 	galago-object.c \
 	galago-person.c \
 	galago-presence.c \
@@ -98,6 +96,7 @@
 
 INCLUDES = \
 	-I$(top_srcdir) \
+	-DG_LOG_DOMAIN=\"Galago\" \
 	$(PACKAGE_CFLAGS)
 
 EXTRA_DIST = \

Modified: trunk/libgalago/libgalago/galago-account.c
===================================================================
--- trunk/libgalago/libgalago/galago-account.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-account.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -656,9 +656,9 @@
 	if (galago_account_get_contact(account, username, FALSE) != NULL)
 	{
 #if 0
-		galago_log_warning("A contact with username %s has already been "
-		                   "added to account %s\n",
-		                   username, galago_account_get_username(account));
+		g_warning("A contact with username %s has already been "
+				  "added to account %s",
+				  username, galago_account_get_username(account));
 #endif
 		return;
 	}

Modified: trunk/libgalago/libgalago/galago-assert.h
===================================================================
--- trunk/libgalago/libgalago/galago-assert.h	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-assert.h	2005-11-28 05:00:32 UTC (rev 2346)
@@ -21,40 +21,30 @@
 #ifndef _GALAGO_ASSERT_H_
 #define _GALAGO_ASSERT_H_
 
-#include <libgalago/galago-log.h>
 #include <glib.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+G_BEGIN_DECLS
 
 #ifdef __GNUC__
 # define galago_goto_if_fail(cond, label) \
 	if (G_UNLIKELY(!(cond))) \
 	{ \
-		galago_log(GALAGO_LOG_ASSERT, \
-				   "file %s: line %d (%s): assertion `%s' failed\n", \
-				   __FILE__, \
-				   __LINE__, \
-				   __PRETTY_FUNCTION__, \
-				   #cond); \
+		g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
+			  "file %s: line %d (%s): assertion `%s' failed\n", \
+			  __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond); \
 		goto label; \
 	}
 #else /* !__GNUC__ */
 # define galago_goto_if_fail(cond, label) \
 	if (G_UNLIKELY(!(cond))) \
 	{ \
-		galago_log(GALAGO_LOG_ASSERT, \
-				   "file %s: line %d: assertion `%s' failed\n", \
-				   __FILE__, \
-				   __LINE__, \
-				   #cond); \
+		g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
+			  "file %s: line %d: assertion `%s' failed\n", \
+			  __FILE__, __LINE__, #cond); \
 		goto label; \
 	}
 #endif /* !__GNUC__ */
 
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
 
 #endif /* _GALAGO_ASSERT_H_ */

Modified: trunk/libgalago/libgalago/galago-context.c
===================================================================
--- trunk/libgalago/libgalago/galago-context.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-context.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -247,15 +247,13 @@
 		switch (key->origin)
 		{
 			case GALAGO_LOCAL:
-				galago_log_warning("A local service with ID %s has "
-								   "already been added.\n",
-								   key->id);
+				g_warning("A local service with ID %s has already been added.",
+						  key->id);
 				break;
 
 			case GALAGO_REMOTE:
-				galago_log_warning("A remote service with ID %s has "
-								   "already been added.\n",
-								   key->id);
+				g_warning("A remote service with ID %s has already been added.",
+						  key->id);
 				break;
 
 			default:
@@ -406,15 +404,13 @@
 		switch (key->origin)
 		{
 			case GALAGO_LOCAL:
-				galago_log_warning("A local person with ID %s has "
-								   "already been added.\n",
-								   key->id);
+				g_warning("A local person with ID %s has already been added.",
+						  key->id);
 				break;
 
 			case GALAGO_REMOTE:
-				galago_log_warning("A remote person with ID %s has "
-								   "already been added.\n",
-								   key->id);
+				g_warning("A remote person with ID %s has already been added.",
+						  key->id);
 				break;
 
 			default:

Modified: trunk/libgalago/libgalago/galago-core.c
===================================================================
--- trunk/libgalago/libgalago/galago-core.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-core.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -27,7 +27,6 @@
 #include <libgalago/galago-assert.h>
 #include <libgalago/galago-context.h>
 #include <libgalago/galago-context-priv.h>
-#include <libgalago/galago-log.h>
 #include <libgalago/galago-marshal.h>
 #include <string.h>
 
@@ -239,7 +238,7 @@
 
 	if (!_galago_dbus_register_connection())
 	{
-		galago_log_error("Unable to re-establish registration\n");
+		g_warning("Unable to re-establish registration");
 
 		return;
 	}
@@ -295,8 +294,8 @@
 											GALAGO_DBUS_SERVICE, 0, NULL,
 											&error))
 		{
-			galago_log_error("Received ServiceDoesNotExist, and cannot "
-							 "re-activate daemon. Disconnecting for now.\n");
+			g_warning("Received ServiceDoesNotExist, and cannot "
+					  "re-activate daemon. Disconnecting for now.");
 			dbus_error_free(&error);
 		}
 
@@ -310,12 +309,12 @@
 		dbus_message_iter_init(message, &iter);
 		dbus_message_iter_get_basic(&iter, &str);
 
-		galago_log_error("Received LimitsExceeded: %s\n", str);
+		g_critical("Received LimitsExceeded: %s", str);
 
 		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 	}
 
-	galago_log_error("D-BUS Error: %s\n", error_name);
+	g_warning("D-BUS Error: %s", error_name);
 
 	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
@@ -345,20 +344,12 @@
 			gboolean old_owner_good = (old_owner && *old_owner != '\0');
 			gboolean new_owner_good = (new_owner && *new_owner != '\0');
 
-			galago_log_info("Service owner changed.\n");
-
 			if (!old_owner_good && new_owner_good)
 			{
 				if (galago_get_exit_with_daemon())
-				{
-					galago_log_info("Exitting with daemon\n");
 					exit(0);
-				}
 				else
-				{
-					galago_log_info("Reregistering connection.\n");
 					reregister_client();
-				}
 			}
 		}
 	}
@@ -605,8 +596,8 @@
 				}
 
 				default:
-					galago_log_warning("Invalid property type %d passed to "
-									   "SetProperty\n", arg_type);
+					g_warning("Invalid property type %d passed to "
+							  "SetProperty", arg_type);
 					break;
 			}
 		}
@@ -661,8 +652,7 @@
 
 	if (_core->dbus_conn == NULL)
 	{
-		galago_log_error("Error connecting to session bus: %s\n",
-						 error.message);
+		g_error("Unable to connect to session bus: %s", error.message);
 		dbus_error_free(&error);
 
 		return FALSE;
@@ -681,8 +671,7 @@
 	if (!dbus_bus_start_service_by_name(_core->dbus_conn, GALAGO_DBUS_SERVICE,
 										0, NULL, &error))
 	{
-		galago_log_error("Error activating Galago service: %s\n",
-						 error.message);
+		g_error("Unable to activate Galago service: %s", error.message);
 		dbus_error_free(&error);
 
 		dbus_error_init(&error);
@@ -693,7 +682,7 @@
 	if (!dbus_connection_add_filter(_core->dbus_conn,
 									filter_func, NULL, NULL))
 	{
-		galago_log_error("Error creating core handler\n");
+		g_error("Unable to create core D-BUS handler");
 		dbus_error_free(&error);
 
 		return FALSE;
@@ -707,7 +696,7 @@
 
 	if (dbus_error_is_set(&error))
 	{
-		galago_log_error("Error subscribing to signals: %s\n", error.message);
+		g_error("Unable to subscribe to signals: %s", error.message);
 
 		dbus_error_free(&error);
 
@@ -819,8 +808,7 @@
 #ifdef HAVE_SIGNAL_H
 		if (signal(SIGINT, _sigint_cb) == SIG_ERR)
 		{
-			galago_log_warning("Unable to register SIGINT "
-							   "signal handler\n");
+			g_warning("Unable to register SIGINT signal handler");
 		}
 #endif /* HAVE_SIGNAL_H_ */
 
@@ -916,8 +904,8 @@
 					   &error); \
 	if (dbus_error_is_set(&error)) \
 	{ \
-		galago_log_error("Error subscribing to %s signal: %s\n", \
-						 (iface), error.message); \
+		g_error("Unable to subscribe to %s signal: %s", \
+				(iface), error.message); \
 		return; \
 	}
 #define REMOVE_SIGNAL_MATCH(iface) \
@@ -928,8 +916,8 @@
 					   &error); \
 	if (dbus_error_is_set(&error)) \
 	{ \
-		galago_log_error("Error unsubscribing from %s signal: %s\n", \
-						 (iface), error.message); \
+		g_error("Unable to unsubscribe from %s signal: %s", \
+				(iface), error.message); \
 		return; \
 	}
 
@@ -1224,7 +1212,7 @@
 
 	if (list == NULL)
 	{
-		galago_log_error("Error registering local Galago connection.\n");
+		g_error("Unable to register local Galago connection.");
 
 		_core->daemon_active = FALSE;
 

Modified: trunk/libgalago/libgalago/galago-dbus.c
===================================================================
--- trunk/libgalago/libgalago/galago-dbus.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-dbus.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -74,10 +74,10 @@
 	}
 	else
 	{
-		galago_log_error("Class type %s passed to "
-						 "galago_dbus_message_iter_append_object does not "
-						 "implement dbus_message_append!\n",
-						 g_type_name(G_OBJECT_CLASS_TYPE(klass)));
+		g_warning("Class type %s passed to "
+				  "galago_dbus_message_iter_append_object does not "
+				  "implement dbus_message_append!",
+				  g_type_name(G_OBJECT_CLASS_TYPE(klass)));
 	}
 }
 
@@ -123,10 +123,10 @@
 
 	if (klass->dbus_message_get == NULL)
 	{
-		galago_log_error("Class type %s passed to "
-						 "galago_dbus_message_iter_get_object does not "
-						 "implement dbus_message_get!\n",
-						 g_type_name(type));
+		g_warning("Class type %s passed to "
+				  "galago_dbus_message_iter_get_object does not "
+				  "implement dbus_message_get!",
+				  g_type_name(type));
 
 		g_type_class_unref(klass);
 		return NULL;
@@ -184,9 +184,8 @@
 			break;
 
 		default:
-			galago_log_warning("Unsupported list type %d appended to "
-							   "message\n",
-							   galago_value_get_type(value));
+			g_warning("Unsupported list type %d appended to message",
+					  galago_value_get_type(value));
 			break;
 	}
 }
@@ -236,8 +235,8 @@
 			break;
 
 		default:
-			galago_log_warning("Invalid array type %d appended to message\n",
-							   galago_value_get_subtype(value));
+			g_warning("Invalid array type %d appended to message",
+					  galago_value_get_subtype(value));
 			return;
 	}
 
@@ -312,8 +311,8 @@
 			break;
 
 		default:
-			galago_log_warning("Invalid type %d appended to message\n",
-							   galago_value_get_type(value));
+			g_warning("Invalid type %d appended to message",
+					  galago_value_get_type(value));
 			break;
 	}
 
@@ -362,8 +361,8 @@
 		}
 
 		default:
-			galago_log_warning("Unsupported type %d retrieved from message\n",
-							   dbus_message_iter_get_arg_type(iter));
+			g_warning("Unsupported type %d retrieved from message",
+					  dbus_message_iter_get_arg_type(iter));
 			break;
 	}
 
@@ -394,20 +393,18 @@
 
 	if (obj_path == NULL)
 	{
-		galago_log_error(
-			"No object path was registered for class '%s'. "
-			"Please report this.\n",
-			g_type_name(G_OBJECT_CLASS_TYPE(klass)));
+		g_warning("No object path was registered for class '%s'. "
+				  "Please report this.",
+				  g_type_name(G_OBJECT_CLASS_TYPE(klass)));
 
 		return NULL;
 	}
 
 	if (iface == NULL)
 	{
-		galago_log_error(
-			"No D-BUS interface was registered for class '%s'. "
-			"Please report this.\n",
-			g_type_name(G_OBJECT_CLASS_TYPE(klass)));
+		g_warning("No D-BUS interface was registered for class '%s'. "
+				  "Please report this.",
+				  g_type_name(G_OBJECT_CLASS_TYPE(klass)));
 
 		return NULL;
 	}
@@ -515,9 +512,9 @@
 					break;
 
 				default:
-					galago_log_warning(
-						"Unsupported list type %d returned from message\n",
-						galago_value_get_subtype(value));
+					g_warning("Unsupported list type %d returned from "
+							  "message",
+							  galago_value_get_subtype(value));
 					break;
 			}
 			break;
@@ -542,9 +539,8 @@
 					break;
 
 				default:
-					galago_log_warning(
-						"Unsupported type %d retrieved from message\n",
-						dbus_message_iter_get_arg_type(iter));
+					g_warning("Unsupported type %d retrieved from message",
+							  dbus_message_iter_get_arg_type(iter));
 					break;
 			}
 			break;
@@ -590,9 +586,9 @@
 	{
 		if (!dbus_error_has_name(&error, GALAGO_DBUS_ERROR_OBJECT_NOT_FOUND))
 		{
-			galago_log_error("Error sending %s.%s: %s\n",
-							 g_type_name(G_OBJECT_TYPE(object)),
-							 name, error.message);
+			g_warning("Error sending %s.%s: %s",
+					  g_type_name(G_OBJECT_TYPE(object)),
+					  name, error.message);
 		}
 
 		goto exit;
@@ -675,10 +671,9 @@
 		klass->dbus_push_full(object);
 	else
 	{
-		galago_log_error("Class type %s passed to "
-						 "galago_dbus_object_push_full does not "
-						 "implement dbus_push_full!\n",
-						 g_type_name(G_OBJECT_CLASS_TYPE(klass)));
+		g_warning("Class type %s passed to galago_dbus_object_push_full "
+				  "does not implement dbus_push_full!",
+				  g_type_name(G_OBJECT_CLASS_TYPE(klass)));
 	}
 }
 

Deleted: trunk/libgalago/libgalago/galago-log.c
===================================================================
--- trunk/libgalago/libgalago/galago-log.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-log.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -1,200 +0,0 @@
-/**
- * @file libgalago/galago-log.c Log API
- *
- * @Copyright (C) 2004-2005 Christian Hammond
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA  02111-1307, USA.
- */
-#include <libgalago/galago-log.h>
-#include <libgalago/galago-assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-static gboolean log_enabled[GALAGO_LOG_NUM_LEVELS] =
-{
-	0, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE
-	/* 0, FALSE, FALSE, FALSE, TRUE, FALSE */
-};
-
-static const char *level_names[] =
-{
-	NULL, "MISC", "INFO", "WARNING", "ERROR", "FATAL", "ASSERT"
-};
-
-static struct
-{
-	GalagoLogHandlerFunc func;
-	void *data;
-
-} log_handlers[GALAGO_LOG_NUM_LEVELS] =
-{
-	{ NULL, NULL }, /* ALL     */
-	{ NULL, NULL }, /* MISC    */
-	{ NULL, NULL }, /* INFO    */
-	{ NULL, NULL }, /* WARNING */
-	{ NULL, NULL }, /* ERROR   */
-	{ NULL, NULL }, /* FATAL   */
-	{ NULL, NULL }  /* ASSERT  */
-};
-
-void
-galago_log_set_enabled(GalagoLogLevel level, gboolean enabled)
-{
-	g_return_if_fail(level != GALAGO_LOG_NUM_LEVELS);
-
-	if (level == GALAGO_LOG_ALL)
-	{
-		log_enabled[GALAGO_LOG_MISC]    = enabled;
-		log_enabled[GALAGO_LOG_INFO]    = enabled;
-		log_enabled[GALAGO_LOG_WARNING] = enabled;
-		log_enabled[GALAGO_LOG_ERROR]   = enabled;
-		log_enabled[GALAGO_LOG_FATAL]   = enabled;
-		log_enabled[GALAGO_LOG_ASSERT]  = enabled;
-	}
-	else
-		log_enabled[level] = enabled;
-}
-
-void
-galago_log_set_handler(GalagoLogLevel level, GalagoLogHandlerFunc func,
-					   void *user_data)
-{
-	g_return_if_fail(level >= GALAGO_LOG_ALL &&
-						  level <  GALAGO_LOG_NUM_LEVELS);
-
-	if (level == GALAGO_LOG_ALL)
-	{
-		galago_log_set_handler(GALAGO_LOG_MISC,    func, user_data);
-		galago_log_set_handler(GALAGO_LOG_INFO,    func, user_data);
-		galago_log_set_handler(GALAGO_LOG_WARNING, func, user_data);
-		galago_log_set_handler(GALAGO_LOG_ERROR,   func, user_data);
-		galago_log_set_handler(GALAGO_LOG_FATAL,   func, user_data);
-		galago_log_set_handler(GALAGO_LOG_ASSERT,  func, user_data);
-	}
-	else
-	{
-		log_handlers[level].func = func;
-		log_handlers[level].data = (func == NULL ? NULL : user_data);
-	}
-}
-
-void
-galago_log_unset_handler(GalagoLogLevel level)
-{
-	g_return_if_fail(level >= GALAGO_LOG_ALL &&
-						  level <  GALAGO_LOG_NUM_LEVELS);
-
-	galago_log_set_handler(level, NULL, NULL);
-}
-
-void
-galago_log(GalagoLogLevel level, const char *format, ...)
-{
-	va_list args;
-
-	g_return_if_fail(level  != GALAGO_LOG_ALL);
-	g_return_if_fail(level  != GALAGO_LOG_NUM_LEVELS);
-	g_return_if_fail(format != NULL);
-
-	va_start(args, format);
-	galago_log_args(level, format, args);
-	va_end(args);
-}
-
-void
-galago_log_args(GalagoLogLevel level, const char *format, va_list args)
-{
-	g_return_if_fail(level  != GALAGO_LOG_ALL);
-	g_return_if_fail(level  != GALAGO_LOG_NUM_LEVELS);
-	g_return_if_fail(format != NULL);
-
-	if (log_enabled[level])
-	{
-		if (log_handlers[level].func == NULL)
-		{
-			fprintf(stderr, "D:%s: ", level_names[level]);
-			vfprintf(stderr, format, args);
-		}
-		else
-		{
-			log_handlers[level].func(level, format, args,
-									 log_handlers[level].data);
-		}
-
-		if (level == GALAGO_LOG_FATAL)
-			exit(EXIT_FAILURE);
-	}
-}
-
-void
-galago_log_misc(const char *format, ...)
-{
-	va_list args;
-
-	g_return_if_fail(format != NULL);
-
-	va_start(args, format);
-	galago_log_args(GALAGO_LOG_MISC, format, args);
-	va_end(args);
-}
-
-void
-galago_log_info(const char *format, ...)
-{
-	va_list args;
-
-	g_return_if_fail(format != NULL);
-
-	va_start(args, format);
-	galago_log_args(GALAGO_LOG_INFO, format, args);
-	va_end(args);
-}
-
-void
-galago_log_warning(const char *format, ...)
-{
-	va_list args;
-
-	g_return_if_fail(format != NULL);
-
-	va_start(args, format);
-	galago_log_args(GALAGO_LOG_WARNING, format, args);
-	va_end(args);
-}
-
-void
-galago_log_error(const char *format, ...)
-{
-	va_list args;
-
-	g_return_if_fail(format != NULL);
-
-	va_start(args, format);
-	galago_log_args(GALAGO_LOG_ERROR, format, args);
-	va_end(args);
-}
-
-void
-galago_log_fatal(const char *format, ...)
-{
-	va_list args;
-
-	g_return_if_fail(format != NULL);
-
-	va_start(args, format);
-	galago_log_args(GALAGO_LOG_FATAL, format, args);
-	va_end(args);
-}

Deleted: trunk/libgalago/libgalago/galago-log.h
===================================================================
--- trunk/libgalago/libgalago/galago-log.h	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-log.h	2005-11-28 05:00:32 UTC (rev 2346)
@@ -1,168 +0,0 @@
-/**
- * @file libgalago/galago-log.h Log API
- *
- * @Copyright (C) 2004-2005 Christian Hammond
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA  02111-1307, USA.
- */
-#ifndef _LIBGALAGO_LOG_H_
-#define _LIBGALAGO_LOG_H_
-
-#include <glib.h>
-#include <stdarg.h>
-
-/**
- * Log levels.
- */
-typedef enum
-{
-	GALAGO_LOG_ALL = 0,    /**< All log levels.                */
-	GALAGO_LOG_MISC,       /**< General chatter.               */
-	GALAGO_LOG_INFO,       /**< General operation information. */
-	GALAGO_LOG_WARNING,    /**< Warnings.                      */
-	GALAGO_LOG_ERROR,      /**< Errors.                        */
-	GALAGO_LOG_FATAL,      /**< Fatal errors.                  */
-	GALAGO_LOG_ASSERT,     /**< Assertion errors.              */
-	GALAGO_LOG_NUM_LEVELS  /**< The number of log levels.      */
-
-} GalagoLogLevel;
-
-typedef void (*GalagoLogHandlerFunc)(GalagoLogLevel, const char *,
-									 va_list args, void *);
-
-#ifndef __GNUC__
-# define __attribute__(x)
-#endif
-
-G_BEGIN_DECLS
-
-/**
- * Sets whether or not log output is enabled for a level.
- *
- * If @a level is GALAGO_LOG_ALL, the enabled state will be set for
- * all levels. The other levels may then be enabled or disabled on
- * a per-level basis.
- *
- * @param level   The log level.
- * @param enabled Whether or not log output is enabled.
- */
-void galago_log_set_enabled(GalagoLogLevel level, gboolean enabled);
-
-/**
- * Sets up a handler for logging information.
- *
- * @param level     The log level.
- * @param func      The handler function.
- * @param user_data Optional user-specific data.
- */
-void galago_log_set_handler(GalagoLogLevel level, GalagoLogHandlerFunc func,
-							void *user_data);
-
-/**
- * Unsets a logging handler.
- *
- * This is equivalent to calling galago_log_set_handler(level, func, NULL);
- *
- * @param level The log level.
- */
-void galago_log_unset_handler(GalagoLogLevel level);
-
-/**
- * Outputs log information.
- *
- * @param level  The log level.
- * @param format The format string.
- * @param ...    The format parameters.
- */
-void galago_log(GalagoLogLevel level, const char *format, ...)
-	__attribute__((format(printf, 2, 3)));
-
-/**
- * Outpus log information.
- *
- * This is different from galagoLog() in that it takes a va_list.
- *
- * @param level  The log level.
- * @param format The format string.
- * @param args   The format parameters.
- *
- * @see galago_log()
- */
-void galago_log_args(GalagoLogLevel level, const char *format, va_list args);
-
-/**
- * Outputs misc. level log information.
- *
- * This is a wrapper for galago_log(), and uses GALAGO_LOG_MISC as
- * the level.
- *
- * @param format The format string.
- * @param ...    The format parameters.
- */
-void galago_log_misc(const char *format, ...)
-	__attribute__((format(printf, 1, 2)));
-
-/**
- * Outputs info level log information.
- *
- * This is a wrapper for galago_log(), and uses GALAGO_LOG_INFO as
- * the level.
- *
- * @param format The format string.
- * @param ...    The format parameters.
- */
-void galago_log_info(const char *format, ...)
-	__attribute__((format(printf, 1, 2)));
-
-/**
- * Outputs warning level log information.
- *
- * This is a wrapper for galago_log(), and uses GALAGO_LOG_WARNING as
- * the level.
- *
- * @param format The format string.
- * @param ...    The format parameters.
- */
-void galago_log_warning(const char *format, ...)
-	__attribute__((format(printf, 1, 2)));
-
-/**
- * Outputs error level log information.
- *
- * This is a wrapper for galago_log(), and uses GALAGO_LOG_ERROR as
- * the level.
- *
- * @param format The format string.
- * @param ...    The format parameters.
- */
-void galago_log_error(const char *format, ...)
-	__attribute__((format(printf, 1, 2)));
-
-/**
- * Outputs fatal level log information.
- *
- * This is a wrapper for galago_log(), and uses GALAGO_LOG_FATAL as
- * the level.
- *
- * @param format The format string.
- * @param ...    The format parameters.
- */
-void galago_log_fatal(const char *format, ...)
-	__attribute__((format(printf, 1, 2)));
-
-G_END_DECLS
-
-#endif /* _LIBGALAGO_LOG_H_ */

Modified: trunk/libgalago/libgalago/galago-object.c
===================================================================
--- trunk/libgalago/libgalago/galago-object.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-object.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -23,7 +23,6 @@
 #include <libgalago/galago-context-priv.h>
 #include <libgalago/galago-core.h>
 #include <libgalago/galago-enum-types.h>
-#include <libgalago/galago-log.h>
 #include <stdio.h>
 #include <string.h>
 

Modified: trunk/libgalago/libgalago/galago-person.c
===================================================================
--- trunk/libgalago/libgalago/galago-person.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-person.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -630,10 +630,10 @@
 	if (galago_person_get_account(person, service, username, FALSE) != NULL)
 	{
 #if 0
-		galago_log_warning("An account with username %s on service %s has "
-						   "already been added to person %s\n",
-						   username, galago_service_get_id(service),
-						   galago_person_get_id(person));
+		g_warning("An account with username %s on service %s has "
+				  "already been added to person %s",
+				  username, galago_service_get_id(service),
+				  galago_person_get_id(person));
 #endif
 
 		return;
@@ -984,8 +984,8 @@
 		}
 
 		default:
-			galago_log_error("Unknown property type %d for property %s\n",
-							 type, name);
+			g_warning("Unknown property type %d for property %s",
+					  type, name);
 			success = FALSE;
 			return;
 	}
@@ -1028,9 +1028,8 @@
 	{
 		if (!dbus_error_has_name(&error, GALAGO_DBUS_ERROR_INVALID_PROPERTY))
 		{
-			galago_log_error("Error sending Person.GetProperty(%s, %s): %s\n",
-							 galago_person_get_id(person), name,
-							 error.message);
+			g_warning("Error sending Person.GetProperty(%s, %s): %s",
+					  galago_person_get_id(person), name, error.message);
 		}
 
 		goto exit;
@@ -1068,8 +1067,8 @@
 		}
 
 		default:
-			galago_log_fatal("Unknown property type %d for property %s\n",
-							 type, name);
+			g_warning("Unknown property type %d for property %s",
+					  type, name);
 			break;
 	}
 

Modified: trunk/libgalago/libgalago/galago-presence.c
===================================================================
--- trunk/libgalago/libgalago/galago-presence.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-presence.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -21,7 +21,6 @@
 #include <libgalago/galago-presence.h>
 #include <libgalago/galago-context.h>
 #include <libgalago/galago-core.h>
-#include <libgalago/galago-log.h>
 #include <libgalago/galago-marshal.h>
 #include <stdio.h>
 #include <string.h>
@@ -408,9 +407,9 @@
 	{
 		GalagoAccount *account = galago_presence_get_account(presence);
 
-		galago_log_warning("A status with ID %s has already been added "
-						   "to the presence for account %s\n",
-						   status_id, galago_account_get_username(account));
+		g_warning("A status with ID %s has already been added "
+				  "to the presence for account %s",
+				  status_id, galago_account_get_username(account));
 
 		g_object_unref(status);
 
@@ -499,9 +498,9 @@
 	{
 		GalagoAccount *account = galago_presence_get_account(presence);
 
-		galago_log_warning("Attempted to remove an unknown status %s from "
-						   "the presence for account %s\n",
-						   status_id, galago_account_get_username(account));
+		g_warning("Attempted to remove an unknown status %s from "
+				  "the presence for account %s",
+				  status_id, galago_account_get_username(account));
 
 		return;
 	}

Modified: trunk/libgalago/libgalago/galago-service.c
===================================================================
--- trunk/libgalago/libgalago/galago-service.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-service.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -602,9 +602,9 @@
 
 	if (galago_service_get_account(service, username, FALSE) != NULL)
 	{
-		galago_log_warning("An account with username %s has already been "
-						   "added to service %s\n",
-						   username, galago_service_get_id(service));
+		g_warning("An account with username %s has already been "
+				  "added to service %s",
+				  username, galago_service_get_id(service));
 		return;
 	}
 

Modified: trunk/libgalago/libgalago/galago-status.c
===================================================================
--- trunk/libgalago/libgalago/galago-status.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago-status.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -21,7 +21,6 @@
 #include <libgalago/galago-private.h>
 #include <libgalago/galago-core.h>
 #include <libgalago/galago-enum-types.h>
-#include <libgalago/galago-log.h>
 #include <libgalago/galago-status.h>
 #include <stdio.h>
 #include <string.h>
@@ -653,9 +652,9 @@
 	}
 	else if (attr->type != type)
 	{
-		galago_log_error("Attempted to set existing attribute ID %s with "
-						 "invalid type: %s\n",
-						 attr_id, attr_type_strings[type]);
+		g_warning("Attempted to set existing attribute ID %s with "
+				  "invalid type %s",
+				  attr_id, attr_type_strings[type]);
 		return NULL;
 	}
 
@@ -756,8 +755,7 @@
 
 	if (attr != NULL)
 	{
-		galago_log_error("Attempting to remove invalid attribute %s\n",
-						 attr_id);
+		g_warning("Attempting to remove invalid attribute %s", attr_id);
 		return;
 	}
 
@@ -778,9 +776,9 @@
 
 	if (attr->type != type)
 	{
-		galago_log_error("Attempted to retrieve existing attribute ID %s with "
-						 "invalid type: %s\n",
-						 attr_id, attr_type_strings[type]);
+		g_warning("Attempted to retrieve existing attribute ID %s with "
+				  "invalid type: %s",
+				  attr_id, attr_type_strings[type]);
 		return NULL;
 	}
 

Modified: trunk/libgalago/libgalago/galago.h
===================================================================
--- trunk/libgalago/libgalago/galago.h	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/libgalago/galago.h	2005-11-28 05:00:32 UTC (rev 2346)
@@ -27,7 +27,6 @@
 #include <libgalago/galago-context.h>
 #include <libgalago/galago-dbus.h>
 #include <libgalago/galago-enum-types.h>
-#include <libgalago/galago-log.h>
 #include <libgalago/galago-object.h>
 #include <libgalago/galago-person.h>
 #include <libgalago/galago-presence.h>

Modified: trunk/libgalago/tests/check-libgalago.c
===================================================================
--- trunk/libgalago/tests/check-libgalago.c	2005-11-25 01:25:03 UTC (rev 2345)
+++ trunk/libgalago/tests/check-libgalago.c	2005-11-28 05:00:32 UTC (rev 2346)
@@ -222,13 +222,10 @@
 }
 
 static void
-error_handler(GalagoLogLevel level, const char *fmt, va_list args,
-			  void *user_data)
+error_handler(const gchar *log_domain, GLogLevelFlags log_level,
+			  const gchar *message, gpointer user_data)
 {
-	char buf[BUFSIZ];
-
-	vsnprintf(buf, sizeof(buf), fmt, args);
-	fail(buf);
+	fail(message);
 }
 
 int
@@ -238,13 +235,21 @@
 	SRunner *sr;
 	int nf;
 
-	galago_log_set_handler(GALAGO_LOG_WARNING, error_handler, NULL);
-	galago_log_set_handler(GALAGO_LOG_ERROR,   error_handler, NULL);
-	galago_log_set_handler(GALAGO_LOG_FATAL,   error_handler, NULL);
-	galago_log_set_handler(GALAGO_LOG_ASSERT,  error_handler, NULL);
-
 	g_type_init();
 
+	g_log_set_handler(NULL,
+					  G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+					  G_LOG_FLAG_RECURSION,
+					  error_handler, NULL);
+	g_log_set_handler("GLib",
+					  G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+					  G_LOG_FLAG_RECURSION,
+					  error_handler, NULL);
+	g_log_set_handler("Galago",
+					  G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
+					  G_LOG_FLAG_RECURSION,
+					  error_handler, NULL);
+
 	s = make_libgalago_suite();
 	sr = srunner_create(s);
 



More information about the galago-commits mailing list