changeset 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 1f95b6308195
children a66ee70c614c
files src/gtksavedstatuses.c src/protocols/oscar/oscar.c src/savedstatuses.c src/savedstatuses.h src/status.h
diffstat 5 files changed, 103 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtksavedstatuses.c	Thu Oct 13 00:53:01 2005 +0000
+++ b/src/gtksavedstatuses.c	Thu Oct 13 01:29:43 2005 +0000
@@ -230,6 +230,9 @@
 	const char *type;
 	char *message;
 
+	if (gaim_savedstatus_is_transient(saved_status))
+		return;
+
 	title = gaim_savedstatus_get_title(saved_status);
 	type = gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved_status));
 	message = gaim_markup_strip_html(gaim_savedstatus_get_message(saved_status));
--- a/src/protocols/oscar/oscar.c	Thu Oct 13 00:53:01 2005 +0000
+++ b/src/protocols/oscar/oscar.c	Thu Oct 13 01:29:43 2005 +0000
@@ -105,7 +105,7 @@
 	gboolean chpass;
 	char *oldp;
 	char *newp;
-	
+
 	GSList *oscar_chats;
 	GSList *direct_ims;
 	GSList *file_transfers;
@@ -170,8 +170,10 @@
 
 /*
  * Various PRPL-specific buddy info that we want to keep track of
- * Some other info is maintained by locate.c, and I'd like to move 
+ * Some other info is maintained by locate.c, and I'd like to move
  * the rest of this to libfaim, mostly im.c
+ *
+ * TODO: I think all of this should use the status API.
  */
 struct buddyinfo {
 	gboolean typingnot;
--- 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)
 {
--- a/src/savedstatuses.h	Thu Oct 13 00:53:01 2005 +0000
+++ b/src/savedstatuses.h	Thu Oct 13 01:29:43 2005 +0000
@@ -32,6 +32,12 @@
  * to the settings of that state.
  */
 
+/*
+ * TODO: Hmm.  We should probably just be saving GaimPresences.  That's
+ *       something we should look into once the status box gets fleshed
+ *       out more.
+ */
+
 typedef struct _GaimSavedStatus     GaimSavedStatus;
 typedef struct _GaimSavedStatusSub  GaimSavedStatusSub;
 
@@ -46,8 +52,9 @@
  * Create a new saved status.  This will add the saved status to the
  * list of saved statuses and writes the revised list to status.xml.
  *
- * @param title The title of the saved status.  This must be unique.
- * @param type  The type of saved status.
+ * @param title     The title of the saved status.  This must be
+ *                  unique.
+ * @param type      The type of saved status.
  *
  * @return The newly created saved status, or NULL if the title you
  *         used was already taken.
@@ -56,6 +63,15 @@
 									  GaimStatusPrimitive type);
 
 /**
+ * Set the type for the given saved status.
+ *
+ * @param status  The saved status.
+ * @param type    The type of saved status.
+ */
+void gaim_savedstatus_set_type(GaimSavedStatus *status,
+							   GaimStatusPrimitive type);
+
+/**
  * Set the message for the given saved status.
  *
  * @param status  The saved status.
@@ -94,6 +110,25 @@
 GaimSavedStatus *gaim_savedstatus_find(const char *title);
 
 /**
+ * Determines if a given saved status is "transient."
+ * A transient saved status is one that was not
+ * explicitly added by the user.  Transient statuses
+ * are automatically removed if they are not used
+ * for a period of time.
+ *
+ * A transient saved statuses is automatically
+ * created by the status box when the user sets himself
+ * to one of the generic primitive statuses.  The reason
+ * we need to save this status information is so we can
+ * restore it when Gaim restarts.
+ *
+ * @param saved_status The saved status.
+ *
+ * @return TRUE if the saved status is transient.
+ */
+gboolean gaim_savedstatus_is_transient(const GaimSavedStatus *saved_status);
+
+/**
  * Return the name of a given saved status.
  *
  * @param saved_status The saved status.
@@ -121,6 +156,18 @@
 const char *gaim_savedstatus_get_message(const GaimSavedStatus *saved_status);
 
 /**
+ * Determine if a given saved status has "substatuses,"
+ * or if it is a simple status (the same for all
+ * accounts).
+ *
+ * @param saved_status The saved status.
+ *
+ * @return TRUE if the saved_status has substatuses.
+ *         FALSE otherwise.
+ */
+gboolean gaim_savedstatus_has_substatuses(const GaimSavedStatus *saved_status);
+
+/**
  * Get the handle for the status subsystem.
  *
  * @return the handle to the status subsystem
--- a/src/status.h	Thu Oct 13 00:53:01 2005 +0000
+++ b/src/status.h	Thu Oct 13 01:29:43 2005 +0000
@@ -947,6 +947,8 @@
  * @param presence The presence.
  *
  * @return TRUE if the presence is idle, or FALSE otherwise.
+ *         If the presence is offline (gaim_presence_is_online()
+ *         returns FALSE) then FALSE is returned.
  */
 gboolean gaim_presence_is_idle(const GaimPresence *presence);