comparison plugins/tcl/tcl.c @ 13845:d0ff520f87da

[gaim-migrate @ 16301] This is tcl /cmd support. It doesn't currently let tcl plugins return error message (I couldn't ever get that to work). But other than that it works. Ethan please look over this when you get a chance. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Wed, 21 Jun 2006 04:57:27 +0000
parents 140ffd4934a0
children 4d577b63299a
comparison
equal deleted inserted replaced
13844:597beb5c9de1 13845:d0ff520f87da
124 Tcl_SetVar(interp, "::gaim::tk_available", "0", TCL_GLOBAL_ONLY); 124 Tcl_SetVar(interp, "::gaim::tk_available", "0", TCL_GLOBAL_ONLY);
125 #endif /* HAVE_TK */ 125 #endif /* HAVE_TK */
126 126
127 Tcl_CreateObjCommand(interp, "::gaim::account", tcl_cmd_account, (ClientData)NULL, NULL); 127 Tcl_CreateObjCommand(interp, "::gaim::account", tcl_cmd_account, (ClientData)NULL, NULL);
128 Tcl_CreateObjCommand(interp, "::gaim::buddy", tcl_cmd_buddy, (ClientData)NULL, NULL); 128 Tcl_CreateObjCommand(interp, "::gaim::buddy", tcl_cmd_buddy, (ClientData)NULL, NULL);
129 Tcl_CreateObjCommand(interp, "::gaim::cmd", tcl_cmd_cmd, (ClientData)NULL, NULL);
129 Tcl_CreateObjCommand(interp, "::gaim::connection", tcl_cmd_connection, (ClientData)NULL, NULL); 130 Tcl_CreateObjCommand(interp, "::gaim::connection", tcl_cmd_connection, (ClientData)NULL, NULL);
130 Tcl_CreateObjCommand(interp, "::gaim::conversation", tcl_cmd_conversation, (ClientData)NULL, NULL); 131 Tcl_CreateObjCommand(interp, "::gaim::conversation", tcl_cmd_conversation, (ClientData)NULL, NULL);
131 Tcl_CreateObjCommand(interp, "::gaim::core", tcl_cmd_core, (ClientData)NULL, NULL); 132 Tcl_CreateObjCommand(interp, "::gaim::core", tcl_cmd_core, (ClientData)NULL, NULL);
132 Tcl_CreateObjCommand(interp, "::gaim::debug", tcl_cmd_debug, (ClientData)NULL, NULL); 133 Tcl_CreateObjCommand(interp, "::gaim::debug", tcl_cmd_debug, (ClientData)NULL, NULL);
133 Tcl_CreateObjCommand(interp, "::gaim::notify", tcl_cmd_notify, (ClientData)NULL, NULL); 134 Tcl_CreateObjCommand(interp, "::gaim::notify", tcl_cmd_notify, (ClientData)NULL, NULL);
282 283
283 Tcl_SourceRCFile(interp); 284 Tcl_SourceRCFile(interp);
284 285
285 if (Tcl_EvalFile(interp, plugin->path) != TCL_OK) { 286 if (Tcl_EvalFile(interp, plugin->path) != TCL_OK) {
286 result = Tcl_GetObjResult(interp); 287 result = Tcl_GetObjResult(interp);
287 gaim_debug(GAIM_DEBUG_ERROR, "tcl", "Error evaluating %s: %s\n", plugin->path, Tcl_GetString(result)); 288 gaim_debug(GAIM_DEBUG_ERROR, "tcl",
289 "Error evaluating %s: %s\n", plugin->path,
290 Tcl_GetString(result));
288 Tcl_DeleteInterp(interp); 291 Tcl_DeleteInterp(interp);
289 return FALSE; 292 return FALSE;
290 } 293 }
291 294
292 Tcl_Preserve((ClientData)interp); 295 Tcl_Preserve((ClientData)interp);
311 data = plugin->extra; 314 data = plugin->extra;
312 315
313 if (data != NULL) { 316 if (data != NULL) {
314 g_hash_table_remove(tcl_plugins, (gpointer)(data->interp)); 317 g_hash_table_remove(tcl_plugins, (gpointer)(data->interp));
315 gaim_signals_disconnect_by_handle(data->interp); 318 gaim_signals_disconnect_by_handle(data->interp);
319 tcl_cmd_cleanup(data->interp);
316 tcl_signal_cleanup(data->interp); 320 tcl_signal_cleanup(data->interp);
317 Tcl_Release((ClientData)data->interp); 321 Tcl_Release((ClientData)data->interp);
318 Tcl_DeleteInterp(data->interp); 322 Tcl_DeleteInterp(data->interp);
319 g_free(data); 323 g_free(data);
320 } 324 }
339 static gboolean tcl_load(GaimPlugin *plugin) 343 static gboolean tcl_load(GaimPlugin *plugin)
340 { 344 {
341 if(!tcl_loaded) 345 if(!tcl_loaded)
342 return FALSE; 346 return FALSE;
343 tcl_glib_init(); 347 tcl_glib_init();
348 tcl_cmd_init();
344 tcl_signal_init(); 349 tcl_signal_init();
345 gaim_tcl_ref_init(); 350 gaim_tcl_ref_init();
346 351
347 GaimTclRefAccount = gaim_stringref_new("Account"); 352 GaimTclRefAccount = gaim_stringref_new("Account");
348 GaimTclRefConnection = gaim_stringref_new("Connection"); 353 GaimTclRefConnection = gaim_stringref_new("Connection");