changeset 10801:39b5a5e30f47

[gaim-migrate @ 12447] Make SILC able to connect with the new status stuff committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 09 Apr 2005 14:28:47 +0000
parents 8002e95c0809
children 0edc30641f4b
files src/protocols/silc/silc.c src/protocols/silc/silcgaim.h
diffstat 2 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/silc/silc.c	Sat Apr 09 14:12:38 2005 +0000
+++ b/src/protocols/silc/silc.c	Sat Apr 09 14:28:47 2005 +0000
@@ -43,9 +43,11 @@
 	GaimStatusType *type;
 	GList *types = NULL;
 
-	type = gaim_status_type_new(GAIM_STATUS_OFFLINE, SILCGAIM_STATUS_ID_OFFLINE, _("Offline"), FALSE);
+	type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, SILCGAIM_STATUS_ID_OFFLINE, _("Offline"), FALSE, FALSE, FALSE);
 	types = g_list_append(types, type);
-	type = gaim_status_type_new(GAIM_STATUS_ONLINE, SILCGAIM_STATUS_ID_ONLINE, _("Online"), FALSE);
+	type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, SILCGAIM_STATUS_ID_ONLINE, _("Online"), FALSE, FALSE, FALSE);
+	types = g_list_append(types, type);
+	type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, SILCGAIM_STATUS_ID_AVAILABLE, _("Available"), FALSE, TRUE, FALSE);
 	types = g_list_append(types, type);
 	type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, SILCGAIM_STATUS_ID_HYPER, _("Hyper Active"), FALSE, TRUE, FALSE);
 	types = g_list_append(types, type);
@@ -65,17 +67,29 @@
 silcgaim_set_status(GaimAccount *account, GaimStatus *status)
 {
 	GaimConnection *gc = gaim_account_get_connection(account);
-	SilcGaim sg;
+	SilcGaim sg = NULL;
 	SilcUInt32 mode;
 	SilcBuffer idp;
 	unsigned char mb[4];
 	const char *state;
 
-	g_return_if_fail(gc != NULL);
+	if (gc != NULL)
+		sg = gc->proto_data;
+
+	if (status == NULL)
+		return;
+
+	state = gaim_status_get_id(status);
 
-	sg = gc->proto_data;
+	if (state == NULL)
+		return;
 
-	if ((status == NULL) || (sg->conn == NULL))
+	if (strcmp(state, "offline") && !gc) {
+		gaim_account_connect(account);
+		return;
+	}
+
+	if ((sg == NULL) || (sg->conn == NULL))
 		return;
 
 	mode = sg->conn->local_entry->mode;
@@ -85,11 +99,6 @@
 		  SILC_UMODE_INDISPOSED |
 		  SILC_UMODE_PAGE);
 
-	state = gaim_status_get_id(status);
-
-	if (state == NULL)
-		return;
-
 	if (!strcmp(state, "hyper"))
 		mode |= SILC_UMODE_HYPER;
 	else if (!strcmp(state, "away"))
--- a/src/protocols/silc/silcgaim.h	Sat Apr 09 14:12:38 2005 +0000
+++ b/src/protocols/silc/silcgaim.h	Sat Apr 09 14:28:47 2005 +0000
@@ -48,6 +48,7 @@
 /* Status IDs */
 #define SILCGAIM_STATUS_ID_OFFLINE	"offline"
 #define SILCGAIM_STATUS_ID_ONLINE	"online"
+#define SILCGAIM_STATUS_ID_AVAILABLE "available"
 #define SILCGAIM_STATUS_ID_HYPER	"hyper"
 #define SILCGAIM_STATUS_ID_AWAY		"away"
 #define SILCGAIM_STATUS_ID_BUSY		"busy"