comparison plugins/tcl/tcl_cmds.c @ 10829:dae370949a39

[gaim-migrate @ 12495] This is the Right Fix for a quick fix KingAnt posted to Tcl in HEAD the other day. This changes gaim::conversation find to take a mandatory account argument, to reflect changes in the availability of gaim_find_conversation_30chars_here functions. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Sat, 16 Apr 2005 16:10:29 +0000
parents a5a937a18b9b
children 17142948653e
comparison
equal deleted inserted replaced
10828:9cf14a87eedc 10829:dae370949a39
457 Tcl_Obj *list, *elem, *result = Tcl_GetObjResult(interp); 457 Tcl_Obj *list, *elem, *result = Tcl_GetObjResult(interp);
458 const char *cmds[] = { "find", "handle", "list", "new", "write", NULL }; 458 const char *cmds[] = { "find", "handle", "list", "new", "write", NULL };
459 enum { CMD_CONV_FIND, CMD_CONV_HANDLE, CMD_CONV_LIST, CMD_CONV_NEW, CMD_CONV_WRITE } cmd; 459 enum { CMD_CONV_FIND, CMD_CONV_HANDLE, CMD_CONV_LIST, CMD_CONV_NEW, CMD_CONV_WRITE } cmd;
460 const char *styles[] = { "send", "recv", "system", NULL }; 460 const char *styles[] = { "send", "recv", "system", NULL };
461 enum { CMD_CONV_WRITE_SEND, CMD_CONV_WRITE_RECV, CMD_CONV_WRITE_SYSTEM } style; 461 enum { CMD_CONV_WRITE_SEND, CMD_CONV_WRITE_RECV, CMD_CONV_WRITE_SYSTEM } style;
462 const char *findopts[] = { "-account", NULL };
463 enum { CMD_CONV_FIND_ACCOUNT } findopt;
464 const char *newopts[] = { "-chat", "-im" }; 462 const char *newopts[] = { "-chat", "-im" };
465 enum { CMD_CONV_NEW_CHAT, CMD_CONV_NEW_IM } newopt; 463 enum { CMD_CONV_NEW_CHAT, CMD_CONV_NEW_IM } newopt;
466 GaimConversation *convo; 464 GaimConversation *convo;
467 GaimAccount *account; 465 GaimAccount *account;
468 GaimConversationType type; 466 GaimConversationType type;
478 if ((error = Tcl_GetIndexFromObj(interp, objv[1], cmds, "subcommand", 0, (int *)&cmd)) != TCL_OK) 476 if ((error = Tcl_GetIndexFromObj(interp, objv[1], cmds, "subcommand", 0, (int *)&cmd)) != TCL_OK)
479 return error; 477 return error;
480 478
481 switch (cmd) { 479 switch (cmd) {
482 case CMD_CONV_FIND: 480 case CMD_CONV_FIND:
483 if (objc < 3) { 481 if (objc != 4) {
484 Tcl_WrongNumArgs(interp, 2, objv, "?options? name"); 482 Tcl_WrongNumArgs(interp, 2, objv, "account name");
485 return TCL_ERROR; 483 return TCL_ERROR;
486 } 484 }
487 argsused = 2;
488 account = NULL; 485 account = NULL;
489 while (argsused < objc) { 486 if ((error = Tcl_GetIntFromObj(interp, objv[2],
490 opt = Tcl_GetString(objv[argsused]); 487 (int *)&account)) != TCL_OK)
491 if (*opt == '-') {
492 if ((error = Tcl_GetIndexFromObj(interp, objv[argsused], findopts,
493 "option", 0, (int *)&findopt)) != TCL_OK)
494 return error;
495 argsused++;
496 switch (findopt) {
497 case CMD_CONV_FIND_ACCOUNT:
498 if (argsused == objc - 1) {
499 Tcl_SetStringObj(result, "-account requires an argument", -1);
500 return TCL_ERROR;
501 }
502 if ((error = Tcl_GetIntFromObj(interp, objv[argsused],
503 (int *)&account)) != TCL_OK)
504 return error;
505 if (!tcl_validate_account(account, interp))
506 return TCL_ERROR;
507 argsused++;
508 break;
509 }
510 } else {
511 break;
512 }
513 }
514 if (objc - argsused != 1) {
515 Tcl_WrongNumArgs(interp, 2, objv, "?options? name");
516 return error; 488 return error;
517 } 489 if (!tcl_validate_account(account, interp))
518 if (account != NULL) { 490 return TCL_ERROR;
519 convo = gaim_find_conversation_with_account(GAIM_CONV_ANY, Tcl_GetString(objv[argsused]), account); 491 convo = gaim_find_conversation_with_account(GAIM_CONV_ANY,
520 } else { 492 Tcl_GetString(objv[3]),
521 /* TODO: What should we do here? */ 493 account);
522 convo = gaim_find_conversation_with_account(GAIM_CONV_ANY, Tcl_GetString(objv[argsused]), NULL);
523 }
524 Tcl_SetIntObj(result, (int)convo); 494 Tcl_SetIntObj(result, (int)convo);
525 break; 495 break;
526 case CMD_CONV_HANDLE: 496 case CMD_CONV_HANDLE:
527 if (objc != 2) { 497 if (objc != 2) {
528 Tcl_WrongNumArgs(interp, 2, objv, ""); 498 Tcl_WrongNumArgs(interp, 2, objv, "");