changeset 15687:d79c9952f6bb

gaim::plugin Tcl command, thanks to Dossy Shiobara
author Ethan Blanton <elb@pidgin.im>
date Fri, 23 Feb 2007 16:49:32 +0000
parents 7639029f1bf4
children dc01798f4c96
files COPYRIGHT libpurple/plugins/tcl/signal-test.tcl libpurple/plugins/tcl/tcl.c libpurple/plugins/tcl/tcl_cmds.c libpurple/plugins/tcl/tcl_gaim.h
diffstat 5 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Fri Feb 23 16:45:42 2007 +0000
+++ b/COPYRIGHT	Fri Feb 23 16:49:32 2007 +0000
@@ -297,6 +297,7 @@
 Jim Seymour
 Joe Shaw
 Scott Shedden
+Dossy Shiobara
 Ettore Simone
 John Silvestri
 Craig Slusher
--- a/libpurple/plugins/tcl/signal-test.tcl	Fri Feb 23 16:45:42 2007 +0000
+++ b/libpurple/plugins/tcl/signal-test.tcl	Fri Feb 23 16:49:32 2007 +0000
@@ -100,6 +100,14 @@
 }
 }
 
+gaim::signal connect [gaim::plugins handle] plugin-load args {
+	gaim::debug -info "tcl signal" "plugin-load [list $args]"
+}
+
+gaim::signal connect [gaim::plugins handle] plugin-unload args {
+	gaim::debug -info "tcl signal" "plugin-unload [list $args]"
+}
+
 proc plugin_init { } {
 	list "Tcl Signal Test" \
              "$gaim::version" \
--- a/libpurple/plugins/tcl/tcl.c	Fri Feb 23 16:45:42 2007 +0000
+++ b/libpurple/plugins/tcl/tcl.c	Fri Feb 23 16:49:32 2007 +0000
@@ -134,6 +134,7 @@
 	Tcl_CreateObjCommand(interp, "::gaim::core", tcl_cmd_core, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::debug", tcl_cmd_debug, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::notify", tcl_cmd_notify, (ClientData)NULL, NULL);
+	Tcl_CreateObjCommand(interp, "::gaim::plugins", tcl_cmd_plugins, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::prefs", tcl_cmd_prefs, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::presence", tcl_cmd_presence, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::send_im", tcl_cmd_send_im, (ClientData)NULL, NULL);
--- a/libpurple/plugins/tcl/tcl_cmds.c	Fri Feb 23 16:45:42 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_cmds.c	Fri Feb 23 16:49:32 2007 +0000
@@ -912,6 +912,34 @@
 	return TCL_OK;
 }
 
+int tcl_cmd_plugins(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	Tcl_Obj *result = Tcl_GetObjResult(interp);
+	const char *cmds[] = { "handle", NULL };
+	enum { CMD_PLUGINS_HANDLE } cmd;
+	int error;
+
+	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_PLUGINS_HANDLE:
+		if (objc != 2) {
+			Tcl_WrongNumArgs(interp, 2, objv, "");
+			return TCL_ERROR;
+		}
+		Tcl_SetIntObj(result, (int)gaim_plugins_get_handle());
+		break;
+	}
+
+	return TCL_OK;
+}
+
 int tcl_cmd_prefs(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	Tcl_Obj *result, *list, *elem, **elems;
--- a/libpurple/plugins/tcl/tcl_gaim.h	Fri Feb 23 16:45:42 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_gaim.h	Fri Feb 23 16:49:32 2007 +0000
@@ -104,6 +104,7 @@
 Tcl_ObjCmdProc tcl_cmd_core;
 Tcl_ObjCmdProc tcl_cmd_debug;
 Tcl_ObjCmdProc tcl_cmd_notify;
+Tcl_ObjCmdProc tcl_cmd_plugins;
 Tcl_ObjCmdProc tcl_cmd_prefs;
 Tcl_ObjCmdProc tcl_cmd_presence;
 Tcl_ObjCmdProc tcl_cmd_send_im;