diff src/savedstatuses.c @ 11651:723487d07aa0

[gaim-migrate @ 13935] Getting some stuff out of my tree. I think I mostly just added a "transient" boolean to savedstatuses. If a savedstatus is transient, it means it was created on the fly by Gaim when the user set himself to "away." Transient statuses will hang around for a few days in case the user wants to use it again, but eventually it'll disappear. They should also not appear in the saved status editor. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 13 Oct 2005 01:29:43 +0000
parents 519dc2186438
children a8ec0a291d14
line wrap: on
line diff
--- a/src/savedstatuses.c	Thu Oct 13 00:53:01 2005 +0000
+++ b/src/savedstatuses.c	Thu Oct 13 01:29:43 2005 +0000
@@ -46,6 +46,15 @@
  */
 struct _GaimSavedStatus
 {
+	/**
+	 * A "transient" status is one that was used recently by
+	 * a Gaim user, but was not explicitly created using the
+	 * saved status UI.  For example, Gaim's previous status
+	 * is saved in the status.xml file, but should not show
+	 * up in the UI.
+	 */
+	gboolean transient;
+
 	char *title;
 	GaimStatusPrimitive type;
 	char *message;
@@ -133,16 +142,23 @@
 status_to_xmlnode(GaimSavedStatus *status)
 {
 	xmlnode *node, *child;
+	char transient[2];
 	GList *cur;
 
+	snprintf(transient, sizeof(transient), "%d", status->transient);
+
 	node = xmlnode_new("status");
+	xmlnode_set_attrib(node, "transient", transient);
 	xmlnode_set_attrib(node, "name", status->title);
 
 	child = xmlnode_new_child(node, "state");
 	xmlnode_insert_data(child, gaim_primitive_get_id_from_type(status->type), -1);
 
-	child = xmlnode_new_child(node, "message");
-	xmlnode_insert_data(child, status->message, -1);
+	if (status->message != NULL)
+	{
+		child = xmlnode_new_child(node, "message");
+		xmlnode_insert_data(child, status->message, -1);
+	}
 
 	for (cur = status->substatuses; cur != NULL; cur = cur->next)
 	{
@@ -293,6 +309,11 @@
 
 	ret = g_new0(GaimSavedStatus, 1);
 
+	/* Read the transient property */
+	attrib = xmlnode_get_attrib(status, "transient");
+	if ((attrib != NULL) && (attrib[0] == '1'))
+		ret->transient = TRUE;
+
 	/* Read the title */
 	attrib = xmlnode_get_attrib(status, "name");
 	if (attrib == NULL)
@@ -387,6 +408,16 @@
 }
 
 void
+gaim_savedstatus_set_type(GaimSavedStatus *status, GaimStatusPrimitive type)
+{
+	g_return_if_fail(status != NULL);
+
+	status->type = type;
+
+	schedule_save();
+}
+
+void
 gaim_savedstatus_set_message(GaimSavedStatus *status, const char *message)
 {
 	g_return_if_fail(status != NULL);
@@ -437,6 +468,12 @@
 	return NULL;
 }
 
+gboolean
+gaim_savedstatus_is_transient(const GaimSavedStatus *saved_status)
+{
+	return saved_status->transient;
+}
+
 const char *
 gaim_savedstatus_get_title(const GaimSavedStatus *saved_status)
 {
@@ -455,6 +492,12 @@
 	return saved_status->message;
 }
 
+gboolean
+gaim_savedstatus_has_substatuses(const GaimSavedStatus *saved_status)
+{
+	return (saved_status->substatuses != NULL);
+}
+
 void *
 gaim_savedstatuses_get_handle(void)
 {