diff libpurple/plugins/tcl/tcl_cmds.c @ 20166:3287445c05a8

The second in a series of Tcl-fixing patches from venks on irc.freenode.net. This replaces erroneous result returns (which used Tcl_Set*Obj on the result retrieved by Tcl_GetObjResult) with Tcl_SetObjResult and new objects.
author Ethan Blanton <elb@pidgin.im>
date Wed, 19 Sep 2007 02:38:09 +0000
parents 506f0f7f4f21
children 5b6d6ea542b8
line wrap: on
line diff
--- a/libpurple/plugins/tcl/tcl_cmds.c	Wed Sep 19 02:33:08 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_cmds.c	Wed Sep 19 02:38:09 2007 +0000
@@ -55,7 +55,7 @@
 			return account;
 	}
 	if (interp != NULL)
-		Tcl_SetStringObj(Tcl_GetObjResult(interp), "invalid account", -1);
+		Tcl_SetObjResult(interp, Tcl_NewStringObj("invalid account", -1));
 	return NULL;
 }
 
@@ -74,7 +74,7 @@
 			return convo;
 	}
 	if (interp != NULL)
-		Tcl_SetStringObj(Tcl_GetObjResult(interp), "invalid conversation", -1);
+		Tcl_SetObjResult(interp, Tcl_NewStringObj("invalid conversation", -1));
 	return NULL;
 }
 
@@ -97,7 +97,7 @@
 
 int tcl_cmd_account(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	Tcl_Obj *result = Tcl_GetObjResult(interp), *list, *elem;
+	Tcl_Obj *result, *list, *elem;
 	const char *cmds[] = { "alias", "connect", "connection", "disconnect",
 	                       "enabled", "find", "handle", "isconnected",
 	                       "list", "presence", "protocol", "status",
@@ -139,7 +139,7 @@
 		if ((account = tcl_validate_account(objv[2], interp)) == NULL)
 			return TCL_ERROR;
 		alias = purple_account_get_alias(account);
-		Tcl_SetStringObj(result, alias ? (char *)alias : "", -1);
+		Tcl_SetObjResult(interp, Tcl_NewStringObj(alias ? (char *)alias : "", -1));
 		break;
 	case CMD_ACCOUNT_CONNECT:
 		if (objc != 3) {
@@ -164,7 +164,7 @@
 			return TCL_ERROR;
 		Tcl_SetObjResult(interp,
 		                 purple_tcl_ref_new(PurpleTclRefConnection,
-		                                  purple_account_get_connection(account)));
+						    purple_account_get_connection(account)));
 		break;
 	case CMD_ACCOUNT_DISCONNECT:
 		if (objc != 3) {
@@ -183,9 +183,10 @@
 		if ((account = tcl_validate_account(objv[2], interp)) == NULL)
 			return TCL_ERROR;
 		if (objc == 3) {
-			Tcl_SetBooleanObj(result,
-					  purple_account_get_enabled(account,
-								   purple_core_get_ui()));
+			Tcl_SetObjResult(interp, 
+					 Tcl_NewBooleanObj(
+						 purple_account_get_enabled(account,
+									    purple_core_get_ui())));
 		} else {
 			if ((error = Tcl_GetBooleanFromObj(interp, objv[3], &b)) != TCL_OK)
 				return TCL_ERROR;
@@ -218,7 +219,9 @@
 		}
 		if ((account = tcl_validate_account(objv[2], interp)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_account_is_connected(account));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(
+					 purple_account_is_connected(account)));
 		break;
 	case CMD_ACCOUNT_LIST:
 		listopt = CMD_ACCOUNTLIST_ALL;
@@ -257,7 +260,7 @@
 		}
 		if ((account = tcl_validate_account(objv[2], interp)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, (char *)purple_account_get_protocol_id(account), -1);
+		Tcl_SetObjResult(interp, Tcl_NewStringObj((char *)purple_account_get_protocol_id(account), -1));
 		break;
 	case CMD_ACCOUNT_STATUS:
 		if (objc < 3) {
@@ -273,19 +276,19 @@
 		} else {
 			GList *l = NULL;
 			if (objc % 2) {
-				Tcl_SetStringObj(result, "name without value setting status", -1);
+				Tcl_SetObjResult(interp, Tcl_NewStringObj("name without value setting status", -1));
 				return TCL_ERROR;
 			}
 			status = purple_account_get_status(account, Tcl_GetString(objv[3]));
 			if (status == NULL) {
-				Tcl_SetStringObj(result, "invalid status for account", -1);
+				Tcl_SetObjResult(interp, Tcl_NewStringObj("invalid status for account", -1));
 				return TCL_ERROR;
 			}
 			for (i = 4; i < objc; i += 2) {
 				attr_id = Tcl_GetString(objv[i]);
 				value = purple_status_get_attr_value(status, attr_id);
 				if (value == NULL) {
-					Tcl_SetStringObj(result, "invalid attribute for account", -1);
+					Tcl_SetObjResult(interp, Tcl_NewStringObj("invalid attribute for account", -1));
 					return TCL_ERROR;
 				}
 				switch (purple_value_get_type(value)) {
@@ -308,7 +311,7 @@
 					l = g_list_append(l, Tcl_GetString(objv[i + 1]));
 					break;
 				default:
-					Tcl_SetStringObj(result, "unknown PurpleValue type", -1);
+					Tcl_SetObjResult(interp, Tcl_NewStringObj("unknown PurpleValue type", -1));
 					return TCL_ERROR;
 				}
 			}
@@ -329,10 +332,10 @@
 		} else {
 			PurpleStatusPrimitive primitive;
 			if (strcmp(Tcl_GetString(objv[3]), "-primitive")) {
-				Tcl_SetStringObj(result, "bad option \"", -1);
+				result = Tcl_NewStringObj("bad option \"", -1);
 				Tcl_AppendObjToObj(result, objv[3]);
-				Tcl_AppendToObj(result,
-						"\": should be -primitive", -1);
+				Tcl_AppendToObj(result, "\": should be -primitive", -1);
+				Tcl_SetObjResult(interp,result);
 				return TCL_ERROR;
 			}
 			primitive = purple_primitive_get_type_from_id(Tcl_GetString(objv[4]));
@@ -340,7 +343,7 @@
 										  primitive);
 		}
 		if (status_type == NULL) {
-			Tcl_SetStringObj(result, "status type not found", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("status type not found", -1));
 			return TCL_ERROR;
 		}
 		Tcl_SetObjResult(interp,
@@ -370,7 +373,8 @@
 		}
 		if ((account = tcl_validate_account(objv[2], interp)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, (char *)purple_account_get_username(account), -1);
+		Tcl_SetObjResult(interp, 
+				 Tcl_NewStringObj((char *)purple_account_get_username(account), -1));
 		break;
 	}
 
@@ -385,7 +389,8 @@
 	char *type;
 
 	if (count < 3) {
-		Tcl_SetStringObj(Tcl_GetObjResult(interp), "list too short", -1);
+		Tcl_SetObjResult(interp,
+                                 Tcl_NewStringObj("list too short", -1));
 		return NULL;
 	}
 
@@ -422,8 +427,6 @@
 	if ((error = Tcl_GetIndexFromObj(interp, objv[1], cmds, "subcommand", 0, (int *)&cmd)) != TCL_OK)
 		return error;
 
-	result = Tcl_GetObjResult(interp);
-
 	switch (cmd) {
 	case CMD_BUDDY_ALIAS:
 		if (objc != 3) {
@@ -435,9 +438,11 @@
 		if ((node = tcl_list_to_buddy(interp, count, elems)) == NULL)
 			return TCL_ERROR;
 		if (node->type == PURPLE_BLIST_CHAT_NODE)
-			Tcl_SetStringObj(result, ((PurpleChat *)node)->alias, -1);
+			Tcl_SetObjResult(interp,
+					 Tcl_NewStringObj(((PurpleChat *)node)->alias, -1));
 		else if (node->type == PURPLE_BLIST_BUDDY_NODE)
-			Tcl_SetStringObj(result, (char *)purple_buddy_get_alias((PurpleBuddy *)node), -1);
+			Tcl_SetObjResult(interp,
+                                         Tcl_NewStringObj((char *)purple_buddy_get_alias((PurpleBuddy *)node), -1));
 		return TCL_OK;
 		break;
 	case CMD_BUDDY_HANDLE:
@@ -458,11 +463,13 @@
 			if ((error = Tcl_ListObjGetElements(interp, objv[2], &count, &elems)) != TCL_OK)
 				return error;
 			if (count < 3) {
-				Tcl_SetStringObj(result, "buddy too short", -1);
+				Tcl_SetObjResult(interp,
+						 Tcl_NewStringObj("buddy too short", -1));
 				return TCL_ERROR;
 			}
 			if (strcmp("buddy", Tcl_GetString(elems[0]))) {
-				Tcl_SetStringObj(result, "invalid buddy", -1);
+				Tcl_SetObjResult(interp,
+						 Tcl_NewStringObj("invalid buddy", -1));
 				return TCL_ERROR;
 			}
 			if ((account = tcl_validate_account(elems[2], interp)) == NULL)
@@ -479,8 +486,9 @@
 			if (!strcmp("-all", Tcl_GetString(objv[2]))) {
 				all = 1;
 			} else {
-				Tcl_SetStringObj(result, "", -1);
+				result = Tcl_NewStringObj("",-1);
 				Tcl_AppendStringsToObj(result, "unknown option: ", Tcl_GetString(objv[2]), NULL);
+				Tcl_SetObjResult(interp,result);
 				return TCL_ERROR;
 			}
 		}
@@ -551,7 +559,7 @@
 	const char *cmds[] = { "do", "help", "list", "register", "unregister", NULL };
 	enum { CMD_CMD_DO, CMD_CMD_HELP, CMD_CMD_LIST, CMD_CMD_REGISTER, CMD_CMD_UNREGISTER } cmd;
 	struct tcl_cmd_handler *handler;
-	Tcl_Obj *list, *elem, *result = Tcl_GetObjResult(interp);
+	Tcl_Obj *list, *elem;
 	PurpleConversation *convo;
 	PurpleCmdId id;
 	PurpleCmdStatus status;
@@ -579,7 +587,8 @@
 		status = purple_cmd_do_command(convo, Tcl_GetString(objv[3]),
 				escaped, &errstr);
 		g_free(escaped);
-		Tcl_SetStringObj(result, errstr ? (char *)errstr : "", -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(errstr ? (char *)errstr : "", -1));
 		g_free(errstr);
 		if (status != PURPLE_CMD_STATUS_OK) {
 			return TCL_ERROR;
@@ -644,10 +653,10 @@
 		handler->interp = interp;
 		if ((id = tcl_cmd_register(handler)) == 0) {
 			tcl_cmd_handler_free(handler);
-			Tcl_SetIntObj(result, 0);
+			Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
 		} else {
 			handler->id = id;
-			Tcl_SetIntObj(result, id);
+			Tcl_SetObjResult(interp, Tcl_NewIntObj(id));
 		}
 		break;
 	case CMD_CMD_UNREGISTER:
@@ -667,7 +676,7 @@
 
 int tcl_cmd_connection(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	Tcl_Obj *result = Tcl_GetObjResult(interp), *list, *elem;
+	Tcl_Obj *list, *elem;
 	const char *cmds[] = { "account", "displayname", "handle", "list", NULL };
 	enum { CMD_CONN_ACCOUNT, CMD_CONN_DISPLAYNAME, CMD_CONN_HANDLE, CMD_CONN_LIST } cmd;
 	int error;
@@ -701,7 +710,8 @@
 		}
 		if ((gc = tcl_validate_gc(objv[2], interp)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, (char *)purple_connection_get_display_name(gc), -1);
+		Tcl_SetObjResult(interp,
+                                 Tcl_NewStringObj(purple_connection_get_display_name(gc), -1));
 		break;
 	case CMD_CONN_HANDLE:
 		if (objc != 2) {
@@ -730,7 +740,7 @@
 
 int tcl_cmd_conversation(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	Tcl_Obj *list, *elem, *result = Tcl_GetObjResult(interp);
+	Tcl_Obj *list, *elem;
 	const char *cmds[] = { "find", "handle", "list", "new", "write", "name", "title", "send", NULL };
 	enum { CMD_CONV_FIND, CMD_CONV_HANDLE, CMD_CONV_LIST, CMD_CONV_NEW, CMD_CONV_WRITE , CMD_CONV_NAME, CMD_CONV_TITLE, CMD_CONV_SEND } cmd;
 	const char *styles[] = { "send", "recv", "system", NULL };
@@ -854,7 +864,8 @@
 
 		if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, (char *)purple_conversation_get_name(convo), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj((char *)purple_conversation_get_name(convo), -1));
 		break;
 	case CMD_CONV_TITLE:
 		if (objc != 3) {
@@ -864,7 +875,8 @@
 
 		if ((convo = tcl_validate_conversation(objv[2], interp)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, (char *)purple_conversation_get_title(convo), -1);
+		Tcl_SetObjResult(interp,
+                                 Tcl_NewStringObj((char *)purple_conversation_get_title(convo), -1));
 		break;
 	case CMD_CONV_SEND:
 		if (objc != 4) {
@@ -1007,7 +1019,7 @@
 
 int tcl_cmd_prefs(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	Tcl_Obj *result, *list, *elem, **elems;
+	Tcl_Obj *list, *elem, **elems;
 	const char *cmds[] = { "get", "set", "type", NULL };
 	enum { CMD_PREFS_GET, CMD_PREFS_SET, CMD_PREFS_TYPE } cmd;
 	/* char *types[] = { "none", "boolean", "int", "string", "stringlist", NULL }; */
@@ -1024,7 +1036,6 @@
 	if ((error = Tcl_GetIndexFromObj(interp, objv[1], cmds, "subcommand", 0, (int *)&cmd)) != TCL_OK)
 		return error;
 
-	result = Tcl_GetObjResult(interp);
 	switch (cmd) {
 	case CMD_PREFS_GET:
 		if (objc != 3) {
@@ -1034,17 +1045,21 @@
 		preftype = purple_prefs_get_type(Tcl_GetString(objv[2]));
 		switch (preftype) {
 		case PURPLE_PREF_NONE:
-			Tcl_SetStringObj(result, "pref type none", -1);
+			Tcl_SetObjResult(interp,
+					 Tcl_NewStringObj("pref type none", -1));
 			return TCL_ERROR;
 			break;
 		case PURPLE_PREF_BOOLEAN:
-			Tcl_SetBooleanObj(result, purple_prefs_get_bool(Tcl_GetString(objv[2])));
+			Tcl_SetObjResult(interp,
+					 Tcl_NewBooleanObj(
+						 purple_prefs_get_bool(Tcl_GetString(objv[2]))));
 			break;
 		case PURPLE_PREF_INT:
-			Tcl_SetIntObj(result, purple_prefs_get_int(Tcl_GetString(objv[2])));
+			Tcl_SetObjResult(interp, Tcl_NewIntObj(purple_prefs_get_int(Tcl_GetString(objv[2]))));
 			break;
 		case PURPLE_PREF_STRING:
-			Tcl_SetStringObj(result, (char *)purple_prefs_get_string(Tcl_GetString(objv[2])), -1);
+			Tcl_SetObjResult(interp,
+					 Tcl_NewStringObj((char *)purple_prefs_get_string(Tcl_GetString(objv[2])), -1));
 			break;
 		case PURPLE_PREF_STRING_LIST:
 			cur = purple_prefs_get_string_list(Tcl_GetString(objv[2]));
@@ -1058,7 +1073,8 @@
 			break;
 		default:
 			purple_debug(PURPLE_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype);
-			Tcl_SetStringObj(result, "unknown pref type", -1);
+			Tcl_SetObjResult(interp,
+					 Tcl_NewStringObj("unknown pref type", -1));
 			return TCL_ERROR;
 		}
 		break;
@@ -1070,7 +1086,8 @@
 		preftype = purple_prefs_get_type(Tcl_GetString(objv[2]));
 		switch (preftype) {
 		case PURPLE_PREF_NONE:
-			Tcl_SetStringObj(result, "bad path or pref type none", -1);
+			Tcl_SetObjResult(interp,
+					 Tcl_NewStringObj("bad path or pref type none", -1));
 			return TCL_ERROR;
 			break;
 		case PURPLE_PREF_BOOLEAN:
@@ -1109,23 +1126,23 @@
 		preftype = purple_prefs_get_type(Tcl_GetString(objv[2]));
 		switch (preftype) {
 		case PURPLE_PREF_NONE:
-			Tcl_SetStringObj(result, "none", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
 			break;
 		case PURPLE_PREF_BOOLEAN:
-			Tcl_SetStringObj(result, "boolean", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("boolean", -1));
 			break;
 		case PURPLE_PREF_INT:
-			Tcl_SetStringObj(result, "int", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("int", -1));
 			break;
 		case PURPLE_PREF_STRING:
-			Tcl_SetStringObj(result, "string", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("string", -1));
 			break;
 		case PURPLE_PREF_STRING_LIST:
-			Tcl_SetStringObj(result, "stringlist", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("stringlist", -1));
 			break;
 		default:
 			purple_debug(PURPLE_DEBUG_ERROR, "tcl", "tcl does not know about pref type %d\n", preftype);
-			Tcl_SetStringObj(result, "unknown", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("unknown", -1));
 		}
 		break;
 	}
@@ -1143,7 +1160,7 @@
 	       CMD_PRESENCE_CONTEXT, CMD_PRESENCE_CONVERSATION,
 	       CMD_PRESENCE_IDLE, CMD_PRESENCE_LOGIN, CMD_PRESENCE_ONLINE,
 	       CMD_PRESENCE_STATUS, CMD_PRESENCE_STATUSES } cmd;
-	Tcl_Obj *result = Tcl_GetObjResult(interp);
+	Tcl_Obj *result;
 	Tcl_Obj *list, *elem;
 	PurplePresence *presence;
 	GList *cur;
@@ -1180,25 +1197,30 @@
 					 purple_tcl_ref_new(PurpleTclRefStatus,
 							  purple_presence_get_active_status(presence)));
 		} else if (objc == 4) {
-			Tcl_SetBooleanObj(result,
-					  purple_presence_is_status_active(presence,
-									 Tcl_GetString(objv[3])));
+			Tcl_SetObjResult(interp,
+                                         Tcl_NewBooleanObj(
+						 purple_presence_is_status_active(presence,
+										  Tcl_GetString(objv[3]))));
 		} else {
 			PurpleStatusPrimitive primitive;
 			if (strcmp(Tcl_GetString(objv[3]), "-primitive")) {
-				Tcl_SetStringObj(result, "bad option \"", -1);
+				result = Tcl_NewStringObj("bad option \"", -1);
 				Tcl_AppendObjToObj(result, objv[3]);
 				Tcl_AppendToObj(result,
 						"\": should be -primitive", -1);
+				Tcl_SetObjResult(interp,result);
 				return TCL_ERROR;
 			}
 			primitive = purple_primitive_get_type_from_id(Tcl_GetString(objv[4]));
 			if (primitive == PURPLE_STATUS_UNSET) {
-				Tcl_SetStringObj(result, "invalid primitive ", -1);
+				result = Tcl_NewStringObj("invalid primitive ", -1);
 				Tcl_AppendObjToObj(result, objv[4]);
+				Tcl_SetObjResult(interp,result);
 				return TCL_ERROR;
 			}
-			Tcl_SetBooleanObj(result, purple_presence_is_status_primitive_active(presence, primitive));
+			Tcl_SetObjResult(interp,
+                                         Tcl_NewBooleanObj(
+						 purple_presence_is_status_primitive_active(presence, primitive)));
 			break;
 		}
 		break;
@@ -1209,7 +1231,8 @@
 		}
 		if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_presence_is_available(presence));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(purple_presence_is_available(presence)));
 		break;
 	case CMD_PRESENCE_CHAT_USER:
 		if (objc != 3) {
@@ -1218,7 +1241,8 @@
 		}
 		if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, purple_presence_get_chat_user(presence), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(purple_presence_get_chat_user(presence), -1));
 		break;
 	case CMD_PRESENCE_CONTEXT:
 		if (objc != 3) {
@@ -1229,16 +1253,16 @@
 			return TCL_ERROR;
 		switch (purple_presence_get_context(presence)) {
 		case PURPLE_PRESENCE_CONTEXT_UNSET:
-			Tcl_SetStringObj(result, "unset", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("unset", -1));
 			break;
 		case PURPLE_PRESENCE_CONTEXT_ACCOUNT:
-			Tcl_SetStringObj(result, "account", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("account", -1));
 			break;
 		case PURPLE_PRESENCE_CONTEXT_CONV:
-			Tcl_SetStringObj(result, "conversation", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("conversation", -1));
 			break;
 		case PURPLE_PRESENCE_CONTEXT_BUDDY:
-			Tcl_SetStringObj(result, "buddy", -1);
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("buddy", -1));
 			break;
 		}
 		break;
@@ -1262,7 +1286,7 @@
 		if (objc == 3) {
 			if (purple_presence_is_idle(presence)) {
 				idle_time = purple_presence_get_idle_time (presence);
-				Tcl_SetIntObj(result, idle_time);
+				Tcl_SetObjResult(interp, Tcl_NewIntObj(idle_time));
 			} else {
 				result = Tcl_NewListObj(0, NULL);
 				Tcl_SetObjResult(interp, result);
@@ -1289,7 +1313,7 @@
 		if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
 			return TCL_ERROR;
 		if (objc == 3) {
-			Tcl_SetIntObj(result, purple_presence_get_login_time(presence));
+			Tcl_SetObjResult(interp, Tcl_NewIntObj(purple_presence_get_login_time(presence)));
 		} else {
 			if ((error == Tcl_GetIntFromObj(interp,
 			                                objv[3],
@@ -1305,7 +1329,9 @@
 		}
 		if ((presence = purple_tcl_ref_get(interp, objv[2], PurpleTclRefPresence)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_presence_is_online(presence));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(
+					 purple_presence_is_online(presence)));
 		break;
 	case CMD_PRESENCE_STATUS:
 		if (objc != 4) {
@@ -1341,7 +1367,7 @@
 
 int tcl_cmd_savedstatus(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	Tcl_Obj *result = Tcl_GetObjResult(interp);
+	Tcl_Obj *result;
 	const char *cmds[] = { "current", "handle", NULL };
 	enum { CMD_SAVEDSTATUS_CURRENT, CMD_SAVEDSTATUS_HANDLE } cmd;
 	int error;
@@ -1363,9 +1389,11 @@
 		}
 		if ((saved_status = purple_savedstatus_get_current()) == NULL)
 			return TCL_ERROR;
+		result = Tcl_NewListObj(0, NULL);
 		Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(purple_savedstatus_get_title(saved_status), -1));
 		Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(purple_savedstatus_get_type(saved_status)));
 		Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(purple_savedstatus_get_message(saved_status), -1));
+		Tcl_SetObjResult(interp,result);
 		break;
 	case CMD_SAVEDSTATUS_HANDLE:
 		if (objc != 2) {
@@ -1407,7 +1435,6 @@
 	const char *cmds[] = { "connect", "disconnect", NULL };
 	enum { CMD_SIGNAL_CONNECT, CMD_SIGNAL_DISCONNECT } cmd;
 	struct tcl_signal_handler *handler;
-	Tcl_Obj *result = Tcl_GetObjResult(interp);
 	void *instance;
 	int error;
 
@@ -1437,9 +1464,9 @@
 		handler->interp = interp;
 		if (!tcl_signal_connect(handler)) {
 			tcl_signal_handler_free(handler);
-			Tcl_SetIntObj(result, 1);
+			Tcl_SetObjResult(interp, Tcl_NewIntObj(1));
 		} else {
-			Tcl_SetIntObj(result, 0);
+			Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
 		}
 		break;
 	case CMD_SIGNAL_DISCONNECT:
@@ -1460,7 +1487,6 @@
 {
 	const char *cmds[] = { "attr", "type", NULL };
 	enum { CMD_STATUS_ATTR, CMD_STATUS_TYPE } cmd;
-	Tcl_Obj *result = Tcl_GetObjResult(interp);
 	PurpleStatus *status;
 	PurpleStatusType *status_type;
 	PurpleValue *value;
@@ -1486,13 +1512,15 @@
 		attr = Tcl_GetString(objv[3]);
 		value = purple_status_get_attr_value(status, attr);
 		if (value == NULL) {
-			Tcl_SetStringObj(result, "no such attribute", -1);
+			Tcl_SetObjResult(interp,
+					 Tcl_NewStringObj("no such attribute", -1));
 			return TCL_ERROR;
 		}
 		switch (purple_value_get_type(value)) {
 		case PURPLE_TYPE_BOOLEAN:
 			if (objc == 4) {
-				Tcl_SetBooleanObj(result, purple_value_get_boolean(value));
+				Tcl_SetObjResult(interp,
+						 Tcl_NewBooleanObj(purple_value_get_boolean(value)));
 			} else {
 				if ((error = Tcl_GetBooleanFromObj(interp, objv[4], &v)) != TCL_OK)
 					return error;
@@ -1501,7 +1529,7 @@
 			break;
 		case PURPLE_TYPE_INT:
 			if (objc == 4) {
-				Tcl_SetIntObj(result, purple_value_get_int(value));
+				Tcl_SetObjResult(interp, Tcl_NewIntObj(purple_value_get_int(value)));
 			} else {
 				if ((error = Tcl_GetIntFromObj(interp, objv[4], &v)) != TCL_OK)
 					return error;
@@ -1510,12 +1538,14 @@
 			break;
 		case PURPLE_TYPE_STRING:
 			if (objc == 4)
-				Tcl_SetStringObj(result, purple_value_get_string(value), -1);
+				Tcl_SetObjResult(interp,
+						 Tcl_NewStringObj(purple_value_get_string(value), -1));
 			else
 				purple_status_set_attr_string(status, attr, Tcl_GetString(objv[4]));
 			break;
 		default:
-			Tcl_SetStringObj(result, "attribute has unknown type", -1);
+			Tcl_SetObjResult(interp,
+                                         Tcl_NewStringObj("attribute has unknown type", -1));
 			return TCL_ERROR;
 		}
 		break;
@@ -1539,7 +1569,6 @@
 {
 	const char *cmds[] = { "id", "name", NULL };
 	enum { CMD_STATUS_ATTR_ID, CMD_STATUS_ATTR_NAME } cmd;
-	Tcl_Obj *result = Tcl_GetObjResult(interp);
 	PurpleStatusAttr *attr;
 	int error;
 
@@ -1559,7 +1588,8 @@
 		}
 		if ((attr = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusAttr)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, purple_status_attr_get_id(attr), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(purple_status_attr_get_id(attr), -1));
 		break;
 	case CMD_STATUS_ATTR_NAME:
 		if (objc != 3) {
@@ -1568,7 +1598,8 @@
 		}
 		if ((attr = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusAttr)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, purple_status_attr_get_name(attr), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(purple_status_attr_get_name(attr), -1));
 		break;
 	}
 
@@ -1587,7 +1618,6 @@
 	       CMD_STATUS_TYPE_NAME, CMD_STATUS_TYPE_PRIMARY_ATTR,
 	       CMD_STATUS_TYPE_PRIMITIVE, CMD_STATUS_TYPE_SAVEABLE,
 	       CMD_STATUS_TYPE_USER_SETTABLE } cmd;
-	Tcl_Obj *result = Tcl_GetObjResult(interp);
 	PurpleStatusType *status_type;
 	Tcl_Obj *list, *elem;
 	GList *cur;
@@ -1609,7 +1639,8 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_status_type_is_available(status_type));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(purple_status_type_is_available(status_type)));
 		break;
 	case CMD_STATUS_TYPE_ATTR:
 		if (objc != 4) {
@@ -1645,7 +1676,8 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_status_type_is_exclusive(status_type));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(purple_status_type_is_exclusive(status_type)));
 		break;
 	case CMD_STATUS_TYPE_ID:
 		if (objc != 3) {
@@ -1654,7 +1686,8 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, purple_status_type_get_id(status_type), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(purple_status_type_get_id(status_type), -1));
 		break;
 	case CMD_STATUS_TYPE_INDEPENDENT:
 		if (objc != 3) {
@@ -1663,7 +1696,8 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_status_type_is_independent(status_type));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(purple_status_type_is_independent(status_type)));
 		break;
 	case CMD_STATUS_TYPE_NAME:
 		if (objc != 3) {
@@ -1672,7 +1706,8 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, purple_status_type_get_name(status_type), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(purple_status_type_get_name(status_type), -1));
 		break;
 	case CMD_STATUS_TYPE_PRIMITIVE:
 		if (objc != 3) {
@@ -1681,7 +1716,9 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, purple_primitive_get_id_from_type(purple_status_type_get_primitive(status_type)), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(purple_primitive_get_id_from_type
+						  (purple_status_type_get_primitive(status_type)), -1));
 		break;
 	case CMD_STATUS_TYPE_PRIMARY_ATTR:
 		if (objc != 3) {
@@ -1690,7 +1727,8 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetStringObj(result, purple_status_type_get_primary_attr(status_type), -1);
+		Tcl_SetObjResult(interp,
+				 Tcl_NewStringObj(purple_status_type_get_primary_attr(status_type), -1));
 		break;
 	case CMD_STATUS_TYPE_SAVEABLE:
 		if (objc != 3) {
@@ -1699,7 +1737,9 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_status_type_is_saveable(status_type));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(
+					 purple_status_type_is_saveable(status_type)));
 		break;
 	case CMD_STATUS_TYPE_USER_SETTABLE:
 		if (objc != 3) {
@@ -1708,7 +1748,9 @@
 		}
 		if ((status_type = purple_tcl_ref_get(interp, objv[2], PurpleTclRefStatusType)) == NULL)
 			return TCL_ERROR;
-		Tcl_SetBooleanObj(result, purple_status_type_is_user_settable(status_type));
+		Tcl_SetObjResult(interp,
+				 Tcl_NewBooleanObj(
+					 purple_status_type_is_user_settable(status_type)));
 		break;
 	}