Mercurial > pidgin
changeset 13824:3b8dc44ff25f
[gaim-migrate @ 16268]
Shut up a useless warning, fix a return bug, and allow setting of status attrs
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Fri, 16 Jun 2006 03:42:34 +0000 |
parents | 4a1debda969d |
children | 140ffd4934a0 |
files | plugins/tcl/tcl_cmds.c plugins/tcl/tcl_gaim.h |
diffstat | 2 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/tcl/tcl_cmds.c Mon Jun 12 13:24:10 2006 +0000 +++ b/plugins/tcl/tcl_cmds.c Fri Jun 16 03:42:34 2006 +0000 @@ -252,7 +252,7 @@ } if ((account = tcl_validate_account(objv[2], interp)) == NULL) return TCL_ERROR; - Tcl_SetObjResult(result, gaim_tcl_ref_new(GaimTclRefPresence, + Tcl_SetObjResult(interp, gaim_tcl_ref_new(GaimTclRefPresence, gaim_account_get_presence(account))); break; case CMD_ACCOUNT_PROTOCOL: @@ -1183,7 +1183,8 @@ GaimStatus *status; GaimStatusType *status_type; GaimValue *value; - int error; + const char *attr; + int error, v; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?"); @@ -1195,26 +1196,42 @@ switch (cmd) { case CMD_STATUS_ATTR: - if (objc != 4) { - Tcl_WrongNumArgs(interp, 2, objv, "status attr_id"); + if (objc != 4 && objc != 5) { + Tcl_WrongNumArgs(interp, 2, objv, "status attr_id ?value?"); return TCL_ERROR; } if ((status = gaim_tcl_ref_get(interp, objv[2], GaimTclRefStatus)) == NULL) return TCL_ERROR; - value = gaim_status_get_attr_value(status, Tcl_GetString(objv[3])); + attr = Tcl_GetString(objv[3]); + value = gaim_status_get_attr_value(status, attr); if (value == NULL) { Tcl_SetStringObj(result, "no such attribute", -1); return TCL_ERROR; } switch (gaim_value_get_type(value)) { case GAIM_TYPE_BOOLEAN: - Tcl_SetBooleanObj(result, gaim_value_get_boolean(value)); + if (objc == 4) { + Tcl_SetBooleanObj(result, gaim_value_get_boolean(value)); + } else { + if ((error = Tcl_GetBooleanFromObj(interp, objv[4], &v)) != TCL_OK) + return error; + gaim_status_set_attr_boolean(status, attr, v); + } break; case GAIM_TYPE_INT: - Tcl_SetIntObj(result, gaim_value_get_int(value)); + if (objc == 4) { + Tcl_SetIntObj(result, gaim_value_get_int(value)); + } else { + if ((error = Tcl_GetIntFromObj(interp, objv[4], &v)) != TCL_OK) + return error; + gaim_status_set_attr_int(status, attr, v ); + } break; case GAIM_TYPE_STRING: - Tcl_SetStringObj(result, gaim_value_get_string(value), -1); + if (objc == 4) + Tcl_SetStringObj(result, gaim_value_get_string(value), -1); + else + gaim_status_set_attr_string(status, attr, Tcl_GetString(objv[4])); break; default: Tcl_SetStringObj(result, "attribute has unknown type", -1);
--- a/plugins/tcl/tcl_gaim.h Mon Jun 12 13:24:10 2006 +0000 +++ b/plugins/tcl/tcl_gaim.h Fri Jun 16 03:42:34 2006 +0000 @@ -65,7 +65,7 @@ gboolean tcl_signal_connect(struct tcl_signal_handler *handler); void tcl_signal_disconnect(void *instance, const char *signal, Tcl_Interp *interp); -void gaim_tcl_ref_init(); +void gaim_tcl_ref_init(void); void *gaim_tcl_ref_get(Tcl_Interp *interp, Tcl_Obj *obj, GaimStringref *type); Tcl_Obj *gaim_tcl_ref_new(GaimStringref *type, void *value);