[Galago-commits] r2818 - in branches/libgalago/push-presence: . libgalago

galago-commits at freedesktop.org galago-commits at freedesktop.org
Fri May 26 00:36:38 PDT 2006


Author: chipx86
Date: 2006-05-26 00:36:34 -0700 (Fri, 26 May 2006)
New Revision: 2818

Added:
   branches/libgalago/push-presence/libgalago/galago-status-attr.c
   branches/libgalago/push-presence/libgalago/galago-status-attr.h
Modified:
   branches/libgalago/push-presence/ChangeLog
   branches/libgalago/push-presence/libgalago/Makefile.am
   branches/libgalago/push-presence/libgalago/galago-status-type.h
Log:
Add GalagoStatusAttr.


Modified: branches/libgalago/push-presence/ChangeLog
===================================================================
--- branches/libgalago/push-presence/ChangeLog	2006-05-26 07:21:33 UTC (rev 2817)
+++ branches/libgalago/push-presence/ChangeLog	2006-05-26 07:36:34 UTC (rev 2818)
@@ -1,3 +1,11 @@
+Fri May 26 00:36:24 PDT 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	A libgalago/galago-status-attr.c:
+	A libgalago/galago-status-attr.h:
+	* libgalago/galago-status-type.h:
+	* libgalago/Makefile.am:
+	  - Add GalagoStatusAttr.
+
 Fri May 26 00:20:38 PDT 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* libgalago/galago-dbus.c:

Modified: branches/libgalago/push-presence/libgalago/Makefile.am
===================================================================
--- branches/libgalago/push-presence/libgalago/Makefile.am	2006-05-26 07:21:33 UTC (rev 2817)
+++ branches/libgalago/push-presence/libgalago/Makefile.am	2006-05-26 07:36:34 UTC (rev 2818)
@@ -20,6 +20,7 @@
 	galago-person.h \
 	galago-presence.h \
 	galago-service.h \
+	galago-status-attr.h \
 	galago-status-type.h \
 	galago-value.h
 
@@ -51,6 +52,7 @@
 	galago-presence.c \
 	galago-private.h \
 	galago-service.c \
+	galago-status-attr.c \
 	galago-status-type.c \
 	galago-value.c
 

Added: branches/libgalago/push-presence/libgalago/galago-status-attr.c
===================================================================
--- branches/libgalago/push-presence/libgalago/galago-status-attr.c	2006-05-26 07:21:33 UTC (rev 2817)
+++ branches/libgalago/push-presence/libgalago/galago-status-attr.c	2006-05-26 07:36:34 UTC (rev 2818)
@@ -0,0 +1,138 @@
+/*
+ * Galago Status Type Attribute API
+ *
+ * Copyright (C) 2006 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-status-attr.h>
+
+struct _GalagoStatusAttr
+{
+	char *id;
+	char *name;
+	GType type;
+};
+
+/**
+ * galago_status_attr_new:
+ * @id: The attribute ID.
+ * @name: The displayed attribute name.
+ * @type: Type of attribute (%G_TYPE_INT, %G_TYPE_BOOLEAN,
+ *                           %G_TYPE_STRING, or %G_TYPE_DOUBLE).
+ *
+ * Created a new #GalagoStatusAttr with the specified ID, display name,
+ * and value type.
+ *
+ * Returns: A new #GalagoStatusAttr.
+ */
+GalagoStatusAttr *
+galago_status_attr_new(const char *id, const char *name, GType type)
+{
+	GalagoStatusAttr *attr;
+
+	g_return_val_if_fail(id != NULL, NULL);
+	g_return_val_if_fail(*id != '\0', NULL);
+	g_return_val_if_fail(type == G_TYPE_INT ||
+						 type == G_TYPE_BOOLEAN ||
+						 type == G_TYPE_STRING ||
+						 type == G_TYPE_DOUBLE,
+						 NULL);
+
+	attr = g_new0(GalagoStatusAttr, 1);
+	attr->id = g_strdup(id);
+	attr->type = type;
+
+	if (name == NULL || *name == '\0')
+	{
+		/*
+		 * TODO: Make this a table when we start to support more
+		 *       standard attribute IDs.
+		 */
+		if (!strcmp(id, GALAGO_STATUS_ATTR_MESSAGE))
+			name = "Message";
+		else
+			name = id;
+	}
+
+	attr->name = g_strdup(name);
+
+	return attr;
+}
+
+/**
+ * galago_status_attr_destroy:
+ * @attr: The #GalagoStatusAttr to destroy.
+ *
+ * Destroys the specified #GalagoStatusAttr.
+ */
+void
+galago_status_attr_destroy(GalagoStatusAttr *attr)
+{
+	g_return_if_fail(attr != NULL);
+
+	g_free(attr->id);
+	g_free(attr->name);
+	g_free(attr);
+}
+
+/**
+ * galago_status_attr_get_id:
+ * @attr: The #GalagoStatusAttr.
+ *
+ * Returns the ID of @attr.
+ *
+ * Returns: The ID of @attr.
+ */
+const char *
+galago_status_attr_get_id(const GalagoStatusAttr *attr)
+{
+	g_return_val_if_fail(attr != NULL, NULL);
+
+	return attr->id;
+}
+
+/**
+ * galago_status_attr_get_name:
+ * @attr: The #GalagoStatusAttr.
+ *
+ * Returns the name of @attr.
+ *
+ * Returns: The name of @attr.
+ */
+const char *
+galago_status_attr_get_name(const GalagoStatusAttr *attr)
+{
+	g_return_val_if_fail(attr != NULL, NULL);
+
+	return attr->name;
+}
+
+/**
+ * galago_status_attr_get_type:
+ * @attr: The #GalagoStatusAttr.
+ *
+ * Returns the value type of @attr.
+ *
+ * Returns: The value type of @attr.
+ */
+GType
+galago_status_attr_get_type(const GalagoStatusAttr *attr)
+{
+	g_return_val_if_fail(attr != NULL, G_TYPE_NONE);
+
+	return attr->type;
+}

Added: branches/libgalago/push-presence/libgalago/galago-status-attr.h
===================================================================
--- branches/libgalago/push-presence/libgalago/galago-status-attr.h	2006-05-26 07:21:33 UTC (rev 2817)
+++ branches/libgalago/push-presence/libgalago/galago-status-attr.h	2006-05-26 07:36:34 UTC (rev 2818)
@@ -0,0 +1,36 @@
+/*
+ * Galago Status Type Attribute API
+ *
+ * Copyright (C) 2006 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 _GALAGO_STATUS_ATTR_H_
+#define _GALAGO_STATUS_ATTR_H_
+
+typedef struct _GalagoStatusAttr GalagoStatusAttr;
+
+#define GALAGO_STATUS_ATTR_MESSAGE "message"
+
+GalagoStatusAttr *galago_status_attr_new(const char *id, const char *name,
+										 GType type);
+void galago_status_attr_destroy(GalagoStatusAttr *attr);
+
+const char *galago_status_attr_get_id(const GalagoStatusAttr *attr);
+const char *galago_status_attr_get_name(const GalagoStatusAttr *attr);
+GType galago_status_attr_get_type(const GalagoStatusAttr *attr);
+
+#endif /* _GALAGO_STATUS_ATTR_H_ */

Modified: branches/libgalago/push-presence/libgalago/galago-status-type.h
===================================================================
--- branches/libgalago/push-presence/libgalago/galago-status-type.h	2006-05-26 07:21:33 UTC (rev 2817)
+++ branches/libgalago/push-presence/libgalago/galago-status-type.h	2006-05-26 07:36:34 UTC (rev 2818)
@@ -38,6 +38,7 @@
 
 #include <libgalago/galago-presence.h>
 #include <libgalago/galago-object.h>
+#include <libgalago/galago-status-attr.h>
 
 /**************************************************************************/
 /** Common Status Definitions                                             */
@@ -52,15 +53,7 @@
 #define GALAGO_STATUS_ID_HIDDEN          "hidden"
 #define GALAGO_STATUS_ID_OFFLINE         "offline"
 
-/**************************************************************************/
-/** Common Status Attributes                                              */
-/**************************************************************************/
 
-/**
- * A message attribute, typically used for custom away and available messages.
- */
-#define GALAGO_STATUS_ATTR_MESSAGE "message"
-
 /**************************************************************************/
 /** Status API                                                            */
 /**************************************************************************/



More information about the galago-commits mailing list