pidgin: 4b0e16d9: Add the Tcl command purple::connection s...

elb at pidgin.im elb at pidgin.im
Fri Apr 17 22:55:33 EDT 2009


-----------------------------------------------------------------
Revision: 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ancestor: 2e248a5affa62a888ecb076170dd36d05d02dc83
Author: elb at pidgin.im
Date: 2009-04-18T02:52:46
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4b0e16d96a9ee2554770c4400445bee7ceb49d9a

Modified files:
        doc/TCL-HOWTO.dox libpurple/plugins/tcl/tcl_cmds.c

ChangeLog: 

Add the Tcl command purple::connection state (purple_connection_get_state).

-------------- next part --------------
============================================================
--- doc/TCL-HOWTO.dox	e1051d949e17f2b837356039c1123d30966e0373
+++ doc/TCL-HOWTO.dox	e65aa73c1717bc156c5a02bc554e78e1b4b74794
@@ -173,6 +173,7 @@ purple::connection list
 purple::connection displayname gc
 purple::connection handle
 purple::connection list
+purple::connection state
 @endcode
 
   @c purple::connection is a collection of subcommands pertaining to
@@ -192,6 +193,9 @@ purple::connection list
   this list are appropriate as @c gc arguments to the other
   @c purple::connection subcommands or other commands requiring a gc.
 
+  @c state returns the PurpleConnectionState of this account as one of
+  the strings "connected", "disconnected", or "connecting".
+
 @code
 purple::conv_send account who text
 @endcode
============================================================
--- libpurple/plugins/tcl/tcl_cmds.c	1e4f4533618dd612e7c64e10aa160ae52f29f01a
+++ libpurple/plugins/tcl/tcl_cmds.c	87a48eacd2f667248f6d052716b93c7bba5fb539
@@ -683,8 +683,9 @@ int tcl_cmd_connection(ClientData unused
 int tcl_cmd_connection(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	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;
+	const char *cmds[] = { "account", "displayname", "handle", "list", "state", NULL };
+	enum { CMD_CONN_ACCOUNT, CMD_CONN_DISPLAYNAME, CMD_CONN_HANDLE,
+	       CMD_CONN_LIST, CMD_CONN_STATE } cmd;
 	int error;
 	GList *cur;
 	PurpleConnection *gc;
@@ -739,6 +740,25 @@ int tcl_cmd_connection(ClientData unused
 		}
 		Tcl_SetObjResult(interp, list);
 		break;
+	case CMD_CONN_STATE:
+		if (objc != 3) {
+			Tcl_WrongNumArgs(interp, 2, objv, "gc");
+			return TCL_ERROR;
+		}
+		if ((gc = tcl_validate_gc(objv[2], interp)) == NULL)
+			return TCL_ERROR;
+		switch (purple_connection_get_state(gc)) {
+		case PURPLE_DISCONNECTED:
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("disconnected", -1));
+			break;
+		case PURPLE_CONNECTED:
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("connected", -1));
+			break;
+		case PURPLE_CONNECTING:
+			Tcl_SetObjResult(interp, Tcl_NewStringObj("connecting", -1));
+			break;
+		}
+		break;
 	}
 
 	return TCL_OK;


More information about the Commits mailing list