changeset 15696:31a6bfedf7be

Tcl savedstatus command, again from Dossy Shiobara. Dossy is on fire.
author Ethan Blanton <elb@pidgin.im>
date Sun, 25 Feb 2007 02:48:52 +0000
parents 79808b1a237f
children 43c7071878de
files libpurple/plugins/tcl/signal-test.tcl libpurple/plugins/tcl/tcl_cmds.c libpurple/plugins/tcl/tcl_gaim.h
diffstat 3 files changed, 47 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/tcl/signal-test.tcl	Sun Feb 25 01:09:40 2007 +0000
+++ b/libpurple/plugins/tcl/signal-test.tcl	Sun Feb 25 02:48:52 2007 +0000
@@ -108,6 +108,11 @@
 	gaim::debug -info "tcl signal" "plugin-unload [list $args]"
 }
 
+gaim::signal connect [gaim::savedstatuses handle] savedstatus-changed args {
+	gaim::debug -info "tcl signal" "savedstatus-changed [list $args]"
+	gaim::debug -info "tcl signal" "gaim::savedstatus current = [gaim::savedstatus current]"
+}
+
 proc plugin_init { } {
 	list "Tcl Signal Test" \
              "$gaim::version" \
--- a/libpurple/plugins/tcl/tcl_cmds.c	Sun Feb 25 01:09:40 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_cmds.c	Sun Feb 25 02:48:52 2007 +0000
@@ -29,6 +29,7 @@
 #include "server.h"
 #include "notify.h"
 #include "blist.h"
+#include "savedstatuses.h"
 #include "debug.h"
 #include "prefs.h"
 #include "core.h"
@@ -1274,6 +1275,46 @@
 	return TCL_OK;
 }
 
+int tcl_cmd_savedstatus(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	Tcl_Obj *result = Tcl_GetObjResult(interp);
+	const char *cmds[] = { "current", "handle", NULL };
+	enum { CMD_SAVEDSTATUS_CURRENT, CMD_SAVEDSTATUS_HANDLE } cmd;
+	int error;
+	GaimSavedStatus *saved_status;
+
+	if (objc < 2) {
+		Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
+		return TCL_ERROR;
+	}
+
+	if ((error = Tcl_GetIndexFromObj(interp, objv[1], cmds, "subcommand", 0, (int *)&cmd)) != TCL_OK)
+		return error;
+
+	switch (cmd) {
+	case CMD_SAVEDSTATUS_CURRENT:
+		if (objc != 2) {
+			Tcl_WrongNumArgs(interp, 2, objv, "");
+			return TCL_ERROR;
+		}
+		if ((saved_status = gaim_savedstatus_get_current()) == NULL)
+			return TCL_ERROR;
+		Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(gaim_savedstatus_get_title(saved_status), -1));
+		Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(gaim_savedstatus_get_type(saved_status)));
+		Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(gaim_savedstatus_get_message(saved_status), -1));
+		break;
+	case CMD_SAVEDSTATUS_HANDLE:
+		if (objc != 2) {
+			Tcl_WrongNumArgs(interp, 2, objv, "");
+			return TCL_ERROR;
+		}
+		Tcl_SetIntObj(result, (int)gaim_savedstatuses_get_handle());
+		break;
+	}
+
+	return TCL_OK;
+}
+
 int tcl_cmd_send_im(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	GaimConnection *gc;
--- a/libpurple/plugins/tcl/tcl_gaim.h	Sun Feb 25 01:09:40 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_gaim.h	Sun Feb 25 02:48:52 2007 +0000
@@ -107,6 +107,7 @@
 Tcl_ObjCmdProc tcl_cmd_plugins;
 Tcl_ObjCmdProc tcl_cmd_prefs;
 Tcl_ObjCmdProc tcl_cmd_presence;
+Tcl_ObjCmdProc tcl_cmd_savedstatus;
 Tcl_ObjCmdProc tcl_cmd_send_im;
 Tcl_ObjCmdProc tcl_cmd_signal;
 Tcl_ObjCmdProc tcl_cmd_status;