Mercurial > hg
comparison mcabber/src/commands.c @ 681:8dc602a246a4
Improve messages in commands.c
author | Philip M. White <pmw@qnan.org> |
---|---|
date | Sun, 29 Jan 2006 12:00:04 +0100 |
parents | 633a0522bd37 |
children | e98abd3ce28c |
comparison
equal
deleted
inserted
replaced
680:1f8987e0e56c | 681:8dc602a246a4 |
---|---|
91 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); | 91 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
92 cmd_add("del", "Delete the current buddy", 0, 0, &do_del); | 92 cmd_add("del", "Delete the current buddy", 0, 0, &do_del); |
93 cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); | 93 cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); |
94 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); | 94 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); |
95 //cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); | 95 //cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); |
96 cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info); | 96 cmd_add("info", "Show basic info on current buddy", 0, 0, &do_info); |
97 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, | 97 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
98 0, &do_move); | 98 0, &do_move); |
99 cmd_add("msay", "Send a multi-lines message to the selected buddy", | 99 cmd_add("msay", "Send a multi-lines message to the selected buddy", |
100 COMPL_MULTILINE, 0, &do_msay); | 100 COMPL_MULTILINE, 0, &do_msay); |
101 cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); | 101 cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); |
253 static void send_message(const char *msg) | 253 static void send_message(const char *msg) |
254 { | 254 { |
255 const char *jid; | 255 const char *jid; |
256 | 256 |
257 if (!jb_getonline()) { | 257 if (!jb_getonline()) { |
258 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | 258 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
259 return; | 259 return; |
260 } | 260 } |
261 | 261 |
262 if (!current_buddy) { | 262 if (!current_buddy) { |
263 scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); | 263 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
264 return; | 264 return; |
265 } | 265 } |
266 | 266 |
267 jid = CURRENT_JID; | 267 jid = CURRENT_JID; |
268 if (!jid) { | 268 if (!jid) { |
269 scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); | 269 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
270 return; | 270 return; |
271 } | 271 } |
272 | 272 |
273 if (buddy_gettype(BUDDATA(current_buddy)) != ROSTER_TYPE_ROOM) { | 273 if (buddy_gettype(BUDDATA(current_buddy)) != ROSTER_TYPE_ROOM) { |
274 // local part (UI, logging, etc.) | 274 // local part (UI, logging, etc.) |
314 | 314 |
315 // Commands handling | 315 // Commands handling |
316 curcmd = cmd_get(xpline); | 316 curcmd = cmd_get(xpline); |
317 | 317 |
318 if (!curcmd) { | 318 if (!curcmd) { |
319 scr_LogPrint(LPRINT_NORMAL, "Unrecognized command, sorry."); | 319 scr_LogPrint(LPRINT_NORMAL, "Unrecognized command. " |
320 "Please see the manual for a list of known commands."); | |
320 if (xpline != line) g_free(xpline); | 321 if (xpline != line) g_free(xpline); |
321 return 0; | 322 return 0; |
322 } | 323 } |
323 if (!curcmd->func) { | 324 if (!curcmd->func) { |
324 scr_LogPrint(LPRINT_NORMAL, "Not yet implemented, sorry."); | 325 scr_LogPrint(LPRINT_NORMAL, |
326 "This functionality is not yet implemented, sorry."); | |
325 if (xpline != line) g_free(xpline); | 327 if (xpline != line) g_free(xpline); |
326 return 0; | 328 return 0; |
327 } | 329 } |
328 // Lets go to the command parameters | 330 // Lets go to the command parameters |
329 for (p = xpline+1; *p && (*p != ' ') ; p++) | 331 for (p = xpline+1; *p && (*p != ' ') ; p++) |
408 return; | 410 return; |
409 } | 411 } |
410 while (*string == ' ') | 412 while (*string == ' ') |
411 string++; | 413 string++; |
412 if (!*string) { | 414 if (!*string) { |
413 scr_LogPrint(LPRINT_NORMAL, "What name or jid are you looking for?"); | 415 scr_LogPrint(LPRINT_NORMAL, "What name or JID are you looking for?"); |
414 return; | 416 return; |
415 } | 417 } |
416 scr_RosterSearch(string); | 418 scr_RosterSearch(string); |
417 update_roster = TRUE; | 419 update_roster = TRUE; |
418 } else if (!strcasecmp(arg, "up")) { | 420 } else if (!strcasecmp(arg, "up")) { |
433 char *status; | 435 char *status; |
434 char *msg; | 436 char *msg; |
435 enum imstatus st; | 437 enum imstatus st; |
436 | 438 |
437 if (!jb_getonline()) { | 439 if (!jb_getonline()) { |
438 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | 440 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
439 return; | 441 return; |
440 } | 442 } |
441 | 443 |
442 paramlst = split_arg(arg, 2, 0); // status, message | 444 paramlst = split_arg(arg, 2, 0); // status, message |
443 status = *paramlst; | 445 status = *paramlst; |
497 jid = *paramlst; | 499 jid = *paramlst; |
498 st = *(paramlst+1); | 500 st = *(paramlst+1); |
499 msg = *(paramlst+2); | 501 msg = *(paramlst+2); |
500 | 502 |
501 if (!jid || !st) { | 503 if (!jid || !st) { |
502 scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); | 504 scr_LogPrint(LPRINT_NORMAL, |
505 "Please specify both a Jabber ID and a status."); | |
503 free_arg_lst(paramlst); | 506 free_arg_lst(paramlst); |
504 return; | 507 return; |
505 } | 508 } |
506 | 509 |
507 // Allow things like /status_to "" away | 510 // Allow things like /status_to "" away |
509 jid = NULL; | 512 jid = NULL; |
510 | 513 |
511 if (jid) { | 514 if (jid) { |
512 // The JID has been specified. Quick check... | 515 // The JID has been specified. Quick check... |
513 if (check_jid_syntax(jid)) { | 516 if (check_jid_syntax(jid)) { |
514 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", jid); | 517 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", jid); |
515 jid = NULL; | 518 jid = NULL; |
516 } else { | 519 } else { |
517 mc_strtolower(jid); | 520 mc_strtolower(jid); |
518 } | 521 } |
519 } else { | 522 } else { |
520 // Add the current buddy | 523 // Add the current buddy |
521 if (current_buddy) | 524 if (current_buddy) |
522 jid = (char*)buddy_getjid(BUDDATA(current_buddy)); | 525 jid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
523 if (!jid) | 526 if (!jid) |
524 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber id"); | 527 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
525 } | 528 } |
526 | 529 |
527 if (jid) { | 530 if (jid) { |
528 char *cmd; | 531 char *cmd; |
529 if (!msg) | 532 if (!msg) |
541 { | 544 { |
542 char **paramlst; | 545 char **paramlst; |
543 char *id, *nick; | 546 char *id, *nick; |
544 | 547 |
545 if (!jb_getonline()) { | 548 if (!jb_getonline()) { |
546 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | 549 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
547 return; | 550 return; |
548 } | 551 } |
549 | 552 |
550 paramlst = split_arg(arg, 2, 0); // jid, [nickname] | 553 paramlst = split_arg(arg, 2, 0); // jid, [nickname] |
551 id = *paramlst; | 554 id = *paramlst; |
557 id = NULL; | 560 id = NULL; |
558 | 561 |
559 if (id) { | 562 if (id) { |
560 // The JID has been specified. Quick check... | 563 // The JID has been specified. Quick check... |
561 if (check_jid_syntax(id)) { | 564 if (check_jid_syntax(id)) { |
562 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", id); | 565 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", id); |
563 id = NULL; | 566 id = NULL; |
564 } else { | 567 } else { |
565 mc_strtolower(id); | 568 mc_strtolower(id); |
566 } | 569 } |
567 } else { | 570 } else { |
568 // Add the current buddy | 571 // Add the current buddy |
569 if (current_buddy) | 572 if (current_buddy) |
570 id = (char*)buddy_getjid(BUDDATA(current_buddy)); | 573 id = (char*)buddy_getjid(BUDDATA(current_buddy)); |
571 if (!id) | 574 if (!id) |
572 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber id"); | 575 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
573 } | 576 } |
574 | 577 |
575 if (id) { | 578 if (id) { |
576 // 2nd parameter = optional nickname | 579 // 2nd parameter = optional nickname |
577 jb_addbuddy(id, nick, NULL); | 580 jb_addbuddy(id, nick, NULL); |
578 scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>", | 581 scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>.", |
579 id); | 582 id); |
580 } | 583 } |
581 free_arg_lst(paramlst); | 584 free_arg_lst(paramlst); |
582 } | 585 } |
583 | 586 |
584 static void do_del(char *arg) | 587 static void do_del(char *arg) |
585 { | 588 { |
586 const char *jid; | 589 const char *jid; |
587 | 590 |
588 if (*arg) { | 591 if (*arg) { |
589 scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); | 592 scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter; " |
593 "the currently-selected buddy will be deleted."); | |
590 return; | 594 return; |
591 } | 595 } |
592 | 596 |
593 if (!current_buddy) return; | 597 if (!current_buddy) return; |
594 jid = buddy_getjid(BUDDATA(current_buddy)); | 598 jid = buddy_getjid(BUDDATA(current_buddy)); |
612 { | 616 { |
613 gpointer group; | 617 gpointer group; |
614 guint leave_windowbuddy; | 618 guint leave_windowbuddy; |
615 | 619 |
616 if (!*arg) { | 620 if (!*arg) { |
617 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 621 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
618 return; | 622 return; |
619 } | 623 } |
620 | 624 |
621 if (!current_buddy) return; | 625 if (!current_buddy) return; |
622 | 626 |
625 // entry itself, because it means we'll have to leave the current buddy | 629 // entry itself, because it means we'll have to leave the current buddy |
626 // chat window. | 630 // chat window. |
627 leave_windowbuddy = (group != BUDDATA(current_buddy)); | 631 leave_windowbuddy = (group != BUDDATA(current_buddy)); |
628 | 632 |
629 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { | 633 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
630 scr_LogPrint(LPRINT_NORMAL, "You need to select a group"); | 634 scr_LogPrint(LPRINT_NORMAL, "You need to select a group."); |
631 return; | 635 return; |
632 } | 636 } |
633 | 637 |
634 if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) { | 638 if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) { |
635 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); | 639 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); |
651 static int send_message_to(const char *jid, const char *msg) | 655 static int send_message_to(const char *jid, const char *msg) |
652 { | 656 { |
653 char *bare_jid, *rp; | 657 char *bare_jid, *rp; |
654 | 658 |
655 if (!jid || !*jid) { | 659 if (!jid || !*jid) { |
656 scr_LogPrint(LPRINT_NORMAL, "JID is missing"); | 660 scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID."); |
657 return 1; | 661 return 1; |
658 } | 662 } |
659 if (!msg || !*msg) { | 663 if (!msg || !*msg) { |
660 scr_LogPrint(LPRINT_NORMAL, "Message is missing"); | 664 scr_LogPrint(LPRINT_NORMAL, "You must specify a message."); |
661 return 1; | 665 return 1; |
662 } | 666 } |
663 if (check_jid_syntax((char*)jid)) { | 667 if (check_jid_syntax((char*)jid)) { |
664 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", jid); | 668 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", jid); |
665 return 1; | 669 return 1; |
666 } | 670 } |
667 | 671 |
668 // We must use the bare jid in hk_message_out() | 672 // We must use the bare jid in hk_message_out() |
669 rp = strchr(jid, '/'); | 673 rp = strchr(jid, '/'); |
695 gpointer bud; | 699 gpointer bud; |
696 | 700 |
697 scr_set_chatmode(TRUE); | 701 scr_set_chatmode(TRUE); |
698 | 702 |
699 if (!current_buddy) { | 703 if (!current_buddy) { |
700 scr_LogPrint(LPRINT_NORMAL, "Who are you talking to??"); | 704 scr_LogPrint(LPRINT_NORMAL, |
705 "Whom are you talking to? Please select a buddy."); | |
701 return; | 706 return; |
702 } | 707 } |
703 | 708 |
704 bud = BUDDATA(current_buddy); | 709 bud = BUDDATA(current_buddy); |
705 if (!(buddy_gettype(bud) & | 710 if (!(buddy_gettype(bud) & |
706 (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM))) { | 711 (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM))) { |
707 scr_LogPrint(LPRINT_NORMAL, "This is not a user"); | 712 scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
708 return; | 713 return; |
709 } | 714 } |
710 | 715 |
711 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | 716 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
712 send_message(arg); | 717 send_message(arg); |
721 paramlst = split_arg(arg, 2, 1); // subcmd, arg | 726 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
722 subcmd = *paramlst; | 727 subcmd = *paramlst; |
723 arg = *(paramlst+1); | 728 arg = *(paramlst+1); |
724 | 729 |
725 if (!subcmd || !*subcmd) { | 730 if (!subcmd || !*subcmd) { |
726 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 731 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
727 scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " | 732 scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " |
728 "the /msay command."); | 733 "the /msay command."); |
729 scr_LogPrint(LPRINT_NORMAL, "(Use \"/msay begin\" to enter " | 734 scr_LogPrint(LPRINT_NORMAL, "(Use \"/msay begin\" to enter " |
730 "multi-line mode...)"); | 735 "multi-line mode...)"); |
731 free_arg_lst(paramlst); | 736 free_arg_lst(paramlst); |
732 return; | 737 return; |
733 } | 738 } |
734 | 739 |
735 if (!strcasecmp(subcmd, "abort")) { | 740 if (!strcasecmp(subcmd, "abort")) { |
736 if (scr_get_multimode()) | 741 if (scr_get_multimode()) |
737 scr_LogPrint(LPRINT_NORMAL, "Leaving multi-line message mode"); | 742 scr_LogPrint(LPRINT_NORMAL, "Leaving multi-line message mode."); |
738 scr_set_multimode(FALSE); | 743 scr_set_multimode(FALSE); |
739 return; | 744 return; |
740 } else if ((!strcasecmp(subcmd, "begin")) || | 745 } else if ((!strcasecmp(subcmd, "begin")) || |
741 (!strcasecmp(subcmd, "verbatim"))) { | 746 (!strcasecmp(subcmd, "verbatim"))) { |
742 if (!strcasecmp(subcmd, "verbatim")) | 747 if (!strcasecmp(subcmd, "verbatim")) |
770 return; | 775 return; |
771 } else { // Send to currently selected buddy | 776 } else { // Send to currently selected buddy |
772 gpointer bud; | 777 gpointer bud; |
773 | 778 |
774 if (!current_buddy) { | 779 if (!current_buddy) { |
775 scr_LogPrint(LPRINT_NORMAL, "Who are you talking to??"); | 780 scr_LogPrint(LPRINT_NORMAL, "Whom are you talking to?"); |
776 return; | 781 return; |
777 } | 782 } |
778 | 783 |
779 bud = BUDDATA(current_buddy); | 784 bud = BUDDATA(current_buddy); |
780 if (!(buddy_gettype(bud) & (ROSTER_TYPE_USER|ROSTER_TYPE_ROOM))) { | 785 if (!(buddy_gettype(bud) & (ROSTER_TYPE_USER|ROSTER_TYPE_ROOM))) { |
781 scr_LogPrint(LPRINT_NORMAL, "This is not a user"); | 786 scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
782 return; | 787 return; |
783 } | 788 } |
784 | 789 |
785 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | 790 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
786 send_message(scr_get_multiline()); | 791 send_message(scr_get_multiline()); |
792 { | 797 { |
793 char **paramlst; | 798 char **paramlst; |
794 char *jid, *msg; | 799 char *jid, *msg; |
795 | 800 |
796 if (!jb_getonline()) { | 801 if (!jb_getonline()) { |
797 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | 802 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
798 return; | 803 return; |
799 } | 804 } |
800 | 805 |
801 paramlst = split_arg(arg, 2, 1); // jid, message | 806 paramlst = split_arg(arg, 2, 1); // jid, message |
802 jid = *paramlst; | 807 jid = *paramlst; |
803 msg = *(paramlst+1); | 808 msg = *(paramlst+1); |
804 | 809 |
805 if (!jid) { | 810 if (!jid) { |
806 scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); | 811 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
807 free_arg_lst(paramlst); | 812 free_arg_lst(paramlst); |
808 return; | 813 return; |
809 } | 814 } |
810 | 815 |
811 send_message_to(jid, msg); | 816 send_message_to(jid, msg); |
828 } | 833 } |
829 | 834 |
830 static void buffer_search(int direction, char *arg) | 835 static void buffer_search(int direction, char *arg) |
831 { | 836 { |
832 if (!arg || !*arg) { | 837 if (!arg || !*arg) { |
833 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 838 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
834 return; | 839 return; |
835 } | 840 } |
836 | 841 |
837 scr_BufferSearch(direction, arg); | 842 scr_BufferSearch(direction, arg); |
838 } | 843 } |
840 static void buffer_date(char *date) | 845 static void buffer_date(char *date) |
841 { | 846 { |
842 time_t t; | 847 time_t t; |
843 | 848 |
844 if (!date || !*date) { | 849 if (!date || !*date) { |
845 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 850 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
846 return; | 851 return; |
847 } | 852 } |
848 | 853 |
849 strip_arg_special_chars(date); | 854 strip_arg_special_chars(date); |
850 | 855 |
851 t = from_iso8601(date, 0); | 856 t = from_iso8601(date, 0); |
852 if (t) | 857 if (t) |
853 scr_BufferDate(t); | 858 scr_BufferDate(t); |
854 else | 859 else |
855 scr_LogPrint(LPRINT_NORMAL, "Wrong parameter"); | 860 scr_LogPrint(LPRINT_NORMAL, "The date you specified is " |
861 "not correctly formatted or invalid."); | |
856 } | 862 } |
857 | 863 |
858 static void buffer_percent(char *arg1, char *arg2) | 864 static void buffer_percent(char *arg1, char *arg2) |
859 { | 865 { |
860 // Basically, user has typed "%arg1 arg2" | 866 // Basically, user has typed "%arg1 arg2" |
861 // "%50" -> arg1 = 50, arg2 null pointer | 867 // "%50" -> arg1 = 50, arg2 null pointer |
862 // "% 50" -> arg1 = \0, arg2 = 50 | 868 // "% 50" -> arg1 = \0, arg2 = 50 |
863 | 869 |
864 if (!*arg1 && (!arg2 || !*arg2)) { // No value | 870 if (!*arg1 && (!arg2 || !*arg2)) { // No value |
865 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 871 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
866 return; | 872 return; |
867 } | 873 } |
868 | 874 |
869 if (*arg1 && arg2 && *arg2) { // Two values | 875 if (*arg1 && arg2 && *arg2) { // Two values |
870 scr_LogPrint(LPRINT_NORMAL, "Wrong parameters"); | 876 scr_LogPrint(LPRINT_NORMAL, "Wrong parameters."); |
871 return; | 877 return; |
872 } | 878 } |
873 | 879 |
874 scr_BufferPercent(atoi((*arg1 ? arg1 : arg2))); | 880 scr_BufferPercent(atoi((*arg1 ? arg1 : arg2))); |
875 } | 881 } |
880 char *subcmd; | 886 char *subcmd; |
881 | 887 |
882 if (!current_buddy) return; | 888 if (!current_buddy) return; |
883 | 889 |
884 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) { | 890 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) { |
885 scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer"); | 891 scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer."); |
886 return; | 892 return; |
887 } | 893 } |
888 | 894 |
889 paramlst = split_arg(arg, 2, 1); // subcmd, arg | 895 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
890 subcmd = *paramlst; | 896 subcmd = *paramlst; |
891 arg = *(paramlst+1); | 897 arg = *(paramlst+1); |
892 | 898 |
893 if (!subcmd || !*subcmd) { | 899 if (!subcmd || !*subcmd) { |
894 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 900 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
895 free_arg_lst(paramlst); | 901 free_arg_lst(paramlst); |
896 return; | 902 return; |
897 } | 903 } |
898 | 904 |
899 if (!strcasecmp(subcmd, "top")) { | 905 if (!strcasecmp(subcmd, "top")) { |
1016 const char *jid; | 1022 const char *jid; |
1017 char *buffer; | 1023 char *buffer; |
1018 GSList *resources; | 1024 GSList *resources; |
1019 | 1025 |
1020 if (*arg) { | 1026 if (*arg) { |
1021 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter"); | 1027 scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter."); |
1022 return; | 1028 return; |
1023 } | 1029 } |
1024 | 1030 |
1025 // Enter chat mode | 1031 // Enter chat mode |
1026 scr_set_chatmode(TRUE); | 1032 scr_set_chatmode(TRUE); |
1058 const char *jid, *group; | 1064 const char *jid, *group; |
1059 guint type; | 1065 guint type; |
1060 char *newname, *p; | 1066 char *newname, *p; |
1061 | 1067 |
1062 if (!*arg) { | 1068 if (!*arg) { |
1063 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1069 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID to rename."); |
1064 return; | 1070 return; |
1065 } | 1071 } |
1066 | 1072 |
1067 if (!current_buddy) return; | 1073 if (!current_buddy) return; |
1068 bud = BUDDATA(current_buddy); | 1074 bud = BUDDATA(current_buddy); |
1070 jid = buddy_getjid(bud); | 1076 jid = buddy_getjid(bud); |
1071 group = buddy_getgroupname(bud); | 1077 group = buddy_getgroupname(bud); |
1072 type = buddy_gettype(bud); | 1078 type = buddy_gettype(bud); |
1073 | 1079 |
1074 if (type & ROSTER_TYPE_GROUP) { | 1080 if (type & ROSTER_TYPE_GROUP) { |
1075 scr_LogPrint(LPRINT_NORMAL, "You can't rename groups"); | 1081 scr_LogPrint(LPRINT_NORMAL, "You can't rename groups."); |
1076 return; | 1082 return; |
1077 } | 1083 } |
1078 | 1084 |
1079 newname = g_strdup(arg); | 1085 newname = g_strdup(arg); |
1080 // Remove trailing space | 1086 // Remove trailing space |
1133 guint assign; | 1139 guint assign; |
1134 const gchar *option, *value; | 1140 const gchar *option, *value; |
1135 | 1141 |
1136 assign = parse_assigment(arg, &option, &value); | 1142 assign = parse_assigment(arg, &option, &value); |
1137 if (!option) { | 1143 if (!option) { |
1138 scr_LogPrint(LPRINT_NORMAL, "Huh?"); | 1144 scr_LogPrint(LPRINT_NORMAL, "Set what option?"); |
1139 return; | 1145 return; |
1140 } | 1146 } |
1141 if (!assign) { | 1147 if (!assign) { |
1142 // This is a query | 1148 // This is a query |
1143 value = settings_opt_get(option); | 1149 value = settings_opt_get(option); |
1163 guint assign; | 1169 guint assign; |
1164 const gchar *alias, *value; | 1170 const gchar *alias, *value; |
1165 | 1171 |
1166 assign = parse_assigment(arg, &alias, &value); | 1172 assign = parse_assigment(arg, &alias, &value); |
1167 if (!alias) { | 1173 if (!alias) { |
1168 scr_LogPrint(LPRINT_NORMAL, "Huh?"); | 1174 scr_LogPrint(LPRINT_NORMAL, "Alias what?"); |
1169 return; | 1175 return; |
1170 } | 1176 } |
1171 if (!assign) { | 1177 if (!assign) { |
1172 // This is a query | 1178 // This is a query |
1173 value = settings_get(SETTINGS_TYPE_ALIAS, alias); | 1179 value = settings_get(SETTINGS_TYPE_ALIAS, alias); |
1202 guint assign; | 1208 guint assign; |
1203 const gchar *keycode, *value; | 1209 const gchar *keycode, *value; |
1204 | 1210 |
1205 assign = parse_assigment(arg, &keycode, &value); | 1211 assign = parse_assigment(arg, &keycode, &value); |
1206 if (!keycode) { | 1212 if (!keycode) { |
1207 scr_LogPrint(LPRINT_NORMAL, "Huh?"); | 1213 scr_LogPrint(LPRINT_NORMAL, "Bind what keycode?"); |
1208 return; | 1214 return; |
1209 } | 1215 } |
1210 if (!assign) { | 1216 if (!assign) { |
1211 // This is a query | 1217 // This is a query |
1212 value = settings_get(SETTINGS_TYPE_BINDING, keycode); | 1218 value = settings_get(SETTINGS_TYPE_BINDING, keycode); |
1213 if (value) { | 1219 if (value) { |
1214 scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", keycode, value); | 1220 scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", keycode, value); |
1215 } else | 1221 } else |
1216 scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound", keycode); | 1222 scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound.", keycode); |
1217 return; | 1223 return; |
1218 } | 1224 } |
1219 // Update the key binding | 1225 // Update the key binding |
1220 if (!value) | 1226 if (!value) |
1221 settings_del(SETTINGS_TYPE_BINDING, keycode); | 1227 settings_del(SETTINGS_TYPE_BINDING, keycode); |
1227 { | 1233 { |
1228 char **paramlst; | 1234 char **paramlst; |
1229 char *subcmd; | 1235 char *subcmd; |
1230 | 1236 |
1231 if (!jb_getonline()) { | 1237 if (!jb_getonline()) { |
1232 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | 1238 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
1233 return; | 1239 return; |
1234 } | 1240 } |
1235 | 1241 |
1236 paramlst = split_arg(arg, 2, 1); // subcmd, arg | 1242 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
1237 subcmd = *paramlst; | 1243 subcmd = *paramlst; |
1246 | 1252 |
1247 if (!strcasecmp(subcmd, "send")) { | 1253 if (!strcasecmp(subcmd, "send")) { |
1248 gchar *buffer; | 1254 gchar *buffer; |
1249 | 1255 |
1250 if (!subcmd || !*subcmd) { | 1256 if (!subcmd || !*subcmd) { |
1251 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1257 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
1252 free_arg_lst(paramlst); | 1258 free_arg_lst(paramlst); |
1253 return; | 1259 return; |
1254 } | 1260 } |
1255 | 1261 |
1256 // We don't strip_arg_special_chars() here, because it would be a pain for | 1262 // We don't strip_arg_special_chars() here, because it would be a pain for |
1260 if (buffer) { | 1266 if (buffer) { |
1261 scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); | 1267 scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
1262 jb_send_raw(buffer); | 1268 jb_send_raw(buffer); |
1263 g_free(buffer); | 1269 g_free(buffer); |
1264 } else { | 1270 } else { |
1265 scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string"); | 1271 scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string."); |
1266 } | 1272 } |
1267 } else { | 1273 } else { |
1268 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | 1274 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
1269 } | 1275 } |
1270 | 1276 |
1279 static char *check_room_subcommand(char *arg, bool param_needed, | 1285 static char *check_room_subcommand(char *arg, bool param_needed, |
1280 gpointer buddy_must_be_a_room) | 1286 gpointer buddy_must_be_a_room) |
1281 { | 1287 { |
1282 if (buddy_must_be_a_room && | 1288 if (buddy_must_be_a_room && |
1283 !(buddy_gettype(buddy_must_be_a_room) & ROSTER_TYPE_ROOM)) { | 1289 !(buddy_gettype(buddy_must_be_a_room) & ROSTER_TYPE_ROOM)) { |
1284 scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); | 1290 scr_LogPrint(LPRINT_NORMAL, "This isn't a conference room."); |
1285 return NULL; | 1291 return NULL; |
1286 } | 1292 } |
1287 | 1293 |
1288 if (param_needed) { | 1294 if (param_needed) { |
1289 if (!arg) { | 1295 if (!arg) { |
1290 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1296 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
1291 return NULL; | 1297 return NULL; |
1292 } | 1298 } |
1293 } | 1299 } |
1294 | 1300 |
1295 if (arg) | 1301 if (arg) |
1308 roomname = *paramlst; | 1314 roomname = *paramlst; |
1309 nick = *(paramlst+1); | 1315 nick = *(paramlst+1); |
1310 | 1316 |
1311 | 1317 |
1312 if (!roomname || strchr(roomname, '/')) { | 1318 if (!roomname || strchr(roomname, '/')) { |
1313 scr_LogPrint(LPRINT_NORMAL, "Invalid room name"); | 1319 scr_LogPrint(LPRINT_NORMAL, "Invalid room name."); |
1314 free_arg_lst(paramlst); | 1320 free_arg_lst(paramlst); |
1315 return; | 1321 return; |
1316 } | 1322 } |
1317 | 1323 |
1318 // If no nickname is provided with the /join command, | 1324 // If no nickname is provided with the /join command, |
1329 } | 1335 } |
1330 } | 1336 } |
1331 } | 1337 } |
1332 // If we still have no nickname, give up | 1338 // If we still have no nickname, give up |
1333 if (!nick || !*nick) { | 1339 if (!nick || !*nick) { |
1334 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); | 1340 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1335 free_arg_lst(paramlst); | 1341 free_arg_lst(paramlst); |
1336 return; | 1342 return; |
1337 } | 1343 } |
1338 | 1344 |
1339 // Note that roomname is part of the array allocated by split_arg(), | 1345 // Note that roomname is part of the array allocated by split_arg(), |
1340 // so we can modify it. | 1346 // so we can modify it. |
1341 mc_strtolower(roomname); | 1347 mc_strtolower(roomname); |
1342 jb_room_join(roomname, nick); | 1348 jb_room_join(roomname, nick); |
1343 | 1349 |
1344 scr_LogPrint(LPRINT_LOGNORM, "Sent a join request to <%s>", roomname); | 1350 scr_LogPrint(LPRINT_LOGNORM, "Sent a join request to <%s>...", roomname); |
1345 | 1351 |
1346 buddylist_build(); | 1352 buddylist_build(); |
1347 update_roster = TRUE; | 1353 update_roster = TRUE; |
1348 free_arg_lst(paramlst); | 1354 free_arg_lst(paramlst); |
1349 if (tmpnick) | 1355 if (tmpnick) |
1362 // An empty reason is no reason... | 1368 // An empty reason is no reason... |
1363 if (arg && !*arg) | 1369 if (arg && !*arg) |
1364 arg = NULL; | 1370 arg = NULL; |
1365 | 1371 |
1366 if (!jid || !*jid) { | 1372 if (!jid || !*jid) { |
1367 scr_LogPrint(LPRINT_NORMAL, "Missing or incorrect parameter"); | 1373 scr_LogPrint(LPRINT_NORMAL, "Missing or incorrect Jabber ID."); |
1368 free_arg_lst(paramlst); | 1374 free_arg_lst(paramlst); |
1369 return; | 1375 return; |
1370 } | 1376 } |
1371 | 1377 |
1372 roomname = buddy_getjid(bud); | 1378 roomname = buddy_getjid(bud); |
1373 jb_room_invite(roomname, jid, arg); | 1379 jb_room_invite(roomname, jid, arg); |
1374 scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>", jid); | 1380 scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>...", jid); |
1375 free_arg_lst(paramlst); | 1381 free_arg_lst(paramlst); |
1376 } | 1382 } |
1377 | 1383 |
1378 static void room_affil(gpointer bud, char *arg) | 1384 static void room_affil(gpointer bud, char *arg) |
1379 { | 1385 { |
1386 jid = *paramlst; | 1392 jid = *paramlst; |
1387 rolename = *(paramlst+1); | 1393 rolename = *(paramlst+1); |
1388 arg = *(paramlst+2); | 1394 arg = *(paramlst+2); |
1389 | 1395 |
1390 if (!jid || !*jid || !rolename || !*rolename) { | 1396 if (!jid || !*jid || !rolename || !*rolename) { |
1391 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1397 scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role."); |
1392 free_arg_lst(paramlst); | 1398 free_arg_lst(paramlst); |
1393 return; | 1399 return; |
1394 } | 1400 } |
1395 | 1401 |
1396 ra.type = type_affil; | 1402 ra.type = type_affil; |
1400 break; | 1406 break; |
1401 | 1407 |
1402 if (ra.val.affil < imaffiliation_size) | 1408 if (ra.val.affil < imaffiliation_size) |
1403 jb_room_setattrib(roomid, jid, NULL, ra, arg); | 1409 jb_room_setattrib(roomid, jid, NULL, ra, arg); |
1404 else | 1410 else |
1405 scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter"); | 1411 scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter."); |
1406 | 1412 |
1407 free_arg_lst(paramlst); | 1413 free_arg_lst(paramlst); |
1408 } | 1414 } |
1409 | 1415 |
1410 static void room_role(gpointer bud, char *arg) | 1416 static void room_role(gpointer bud, char *arg) |
1418 jid = *paramlst; | 1424 jid = *paramlst; |
1419 rolename = *(paramlst+1); | 1425 rolename = *(paramlst+1); |
1420 arg = *(paramlst+2); | 1426 arg = *(paramlst+2); |
1421 | 1427 |
1422 if (!jid || !*jid || !rolename || !*rolename) { | 1428 if (!jid || !*jid || !rolename || !*rolename) { |
1423 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1429 scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role."); |
1424 free_arg_lst(paramlst); | 1430 free_arg_lst(paramlst); |
1425 return; | 1431 return; |
1426 } | 1432 } |
1427 | 1433 |
1428 ra.type = type_role; | 1434 ra.type = type_role; |
1432 break; | 1438 break; |
1433 | 1439 |
1434 if (ra.val.role < imrole_size) | 1440 if (ra.val.role < imrole_size) |
1435 jb_room_setattrib(roomid, jid, NULL, ra, arg); | 1441 jb_room_setattrib(roomid, jid, NULL, ra, arg); |
1436 else | 1442 else |
1437 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter"); | 1443 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); |
1438 | 1444 |
1439 free_arg_lst(paramlst); | 1445 free_arg_lst(paramlst); |
1440 } | 1446 } |
1441 | 1447 |
1442 | 1448 |
1451 paramlst = split_arg(arg, 2, 1); // jid, [reason] | 1457 paramlst = split_arg(arg, 2, 1); // jid, [reason] |
1452 jid = *paramlst; | 1458 jid = *paramlst; |
1453 arg = *(paramlst+1); | 1459 arg = *(paramlst+1); |
1454 | 1460 |
1455 if (!jid || !*jid) { | 1461 if (!jid || !*jid) { |
1456 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (Jabber id)"); | 1462 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
1457 free_arg_lst(paramlst); | 1463 free_arg_lst(paramlst); |
1458 return; | 1464 return; |
1459 } | 1465 } |
1460 | 1466 |
1461 ra.type = type_affil; | 1467 ra.type = type_affil; |
1477 paramlst = split_arg(arg, 2, 1); // nickname, [reason] | 1483 paramlst = split_arg(arg, 2, 1); // nickname, [reason] |
1478 nick = *paramlst; | 1484 nick = *paramlst; |
1479 arg = *(paramlst+1); | 1485 arg = *(paramlst+1); |
1480 | 1486 |
1481 if (!nick || !*nick) { | 1487 if (!nick || !*nick) { |
1482 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); | 1488 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1483 free_arg_lst(paramlst); | 1489 free_arg_lst(paramlst); |
1484 return; | 1490 return; |
1485 } | 1491 } |
1486 | 1492 |
1487 ra.type = type_role; | 1493 ra.type = type_role; |
1497 gchar *roomid, *utf8_nickname; | 1503 gchar *roomid, *utf8_nickname; |
1498 const char *nickname; | 1504 const char *nickname; |
1499 | 1505 |
1500 nickname = buddy_getnickname(bud); | 1506 nickname = buddy_getnickname(bud); |
1501 if (!nickname) { | 1507 if (!nickname) { |
1502 scr_LogPrint(LPRINT_NORMAL, "You are not in this room"); | 1508 scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
1503 return; | 1509 return; |
1504 } | 1510 } |
1505 | 1511 |
1506 utf8_nickname = to_utf8(nickname); | 1512 utf8_nickname = to_utf8(nickname); |
1507 roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), utf8_nickname); | 1513 roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), utf8_nickname); |
1511 } | 1517 } |
1512 | 1518 |
1513 static void room_nick(gpointer bud, char *arg) | 1519 static void room_nick(gpointer bud, char *arg) |
1514 { | 1520 { |
1515 if (!buddy_getinsideroom(bud)) { | 1521 if (!buddy_getinsideroom(bud)) { |
1516 scr_LogPrint(LPRINT_NORMAL, "You are not in this room"); | 1522 scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
1517 return; | 1523 return; |
1518 } | 1524 } |
1519 | 1525 |
1520 if (!arg || !*arg) { | 1526 if (!arg || !*arg) { |
1521 const char *nick = buddy_getnickname(bud); | 1527 const char *nick = buddy_getnickname(bud); |
1522 if (nick) | 1528 if (nick) |
1523 scr_LogPrint(LPRINT_NORMAL, "Your nickname is: %s", nick); | 1529 scr_LogPrint(LPRINT_NORMAL, "Your nickname is: %s", nick); |
1524 else | 1530 else |
1525 scr_LogPrint(LPRINT_NORMAL, "You have no nickname in this room"); | 1531 scr_LogPrint(LPRINT_NORMAL, "You have no nickname in this room."); |
1526 } else { | 1532 } else { |
1527 gchar *cmd; | 1533 gchar *cmd; |
1528 cmd = g_strdup_printf("%s %s", buddy_getjid(bud), arg); | 1534 cmd = g_strdup_printf("%s %s", buddy_getjid(bud), arg); |
1529 room_join(bud, cmd); | 1535 room_join(bud, cmd); |
1530 g_free(cmd); | 1536 g_free(cmd); |
1539 paramlst = split_arg(arg, 2, 0); // nickname, message | 1545 paramlst = split_arg(arg, 2, 0); // nickname, message |
1540 nick = *paramlst; | 1546 nick = *paramlst; |
1541 arg = *(paramlst+1); | 1547 arg = *(paramlst+1); |
1542 | 1548 |
1543 if (!nick || !*nick || !arg || !*arg) { | 1549 if (!nick || !*nick || !arg || !*arg) { |
1544 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1550 scr_LogPrint(LPRINT_NORMAL, |
1551 "Please specify both a Jabber ID and a message."); | |
1545 free_arg_lst(paramlst); | 1552 free_arg_lst(paramlst); |
1546 return; | 1553 return; |
1547 } | 1554 } |
1548 | 1555 |
1549 cmd = g_strdup_printf("%s/%s %s", buddy_getjid(bud), nick, arg); | 1556 cmd = g_strdup_printf("%s/%s %s", buddy_getjid(bud), nick, arg); |
1553 } | 1560 } |
1554 | 1561 |
1555 static void room_remove(gpointer bud, char *arg) | 1562 static void room_remove(gpointer bud, char *arg) |
1556 { | 1563 { |
1557 if (*arg) { | 1564 if (*arg) { |
1558 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter"); | 1565 scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter; " |
1566 "the currently-selected room will be removed."); | |
1559 return; | 1567 return; |
1560 } | 1568 } |
1561 | 1569 |
1562 // Quick check: if there are resources, we haven't left | 1570 // Quick check: if there are resources, we haven't left |
1563 if (buddy_getinsideroom(bud)) { | 1571 if (buddy_getinsideroom(bud)) { |
1574 static void room_topic(gpointer bud, char *arg) | 1582 static void room_topic(gpointer bud, char *arg) |
1575 { | 1583 { |
1576 gchar *msg; | 1584 gchar *msg; |
1577 | 1585 |
1578 if (!buddy_getinsideroom(bud)) { | 1586 if (!buddy_getinsideroom(bud)) { |
1579 scr_LogPrint(LPRINT_NORMAL, "You are not in this room"); | 1587 scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
1580 return; | 1588 return; |
1581 } | 1589 } |
1582 | 1590 |
1583 // If no parameter is given, display the current topic | 1591 // If no parameter is given, display the current topic |
1584 if (!*arg) { | 1592 if (!*arg) { |
1585 const char *topic = buddy_gettopic(bud); | 1593 const char *topic = buddy_gettopic(bud); |
1586 if (topic) | 1594 if (topic) |
1587 scr_LogPrint(LPRINT_NORMAL, "Topic: %s", topic); | 1595 scr_LogPrint(LPRINT_NORMAL, "Topic: %s", topic); |
1588 else | 1596 else |
1589 scr_LogPrint(LPRINT_NORMAL, "No topic has been set"); | 1597 scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); |
1590 return; | 1598 return; |
1591 } | 1599 } |
1592 | 1600 |
1593 // Set the topic | 1601 // Set the topic |
1594 msg = g_strdup_printf("/me has set the topic to: %s", arg); | 1602 msg = g_strdup_printf("/me has set the topic to: %s", arg); |
1609 } | 1617 } |
1610 | 1618 |
1611 static void room_unlock(gpointer bud, char *arg) | 1619 static void room_unlock(gpointer bud, char *arg) |
1612 { | 1620 { |
1613 if (*arg) { | 1621 if (*arg) { |
1614 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter"); | 1622 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter."); |
1615 return; | 1623 return; |
1616 } | 1624 } |
1617 | 1625 |
1618 jb_room_unlock(buddy_getjid(bud)); | 1626 jb_room_unlock(buddy_getjid(bud)); |
1619 } | 1627 } |
1635 | 1643 |
1636 paramlst = split_arg(arg, 1, 0); // nickname | 1644 paramlst = split_arg(arg, 1, 0); // nickname |
1637 nick = *paramlst; | 1645 nick = *paramlst; |
1638 | 1646 |
1639 if (!nick || !*nick) { | 1647 if (!nick || !*nick) { |
1640 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); | 1648 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1641 free_arg_lst(paramlst); | 1649 free_arg_lst(paramlst); |
1642 return; | 1650 return; |
1643 } | 1651 } |
1644 | 1652 |
1645 // Enter chat mode | 1653 // Enter chat mode |
1703 char **paramlst; | 1711 char **paramlst; |
1704 char *subcmd; | 1712 char *subcmd; |
1705 gpointer bud; | 1713 gpointer bud; |
1706 | 1714 |
1707 if (!jb_getonline()) { | 1715 if (!jb_getonline()) { |
1708 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | 1716 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
1709 return; | 1717 return; |
1710 } | 1718 } |
1711 | 1719 |
1712 if (!current_buddy) return; | 1720 if (!current_buddy) return; |
1713 bud = BUDDATA(current_buddy); | 1721 bud = BUDDATA(current_buddy); |
1715 paramlst = split_arg(arg, 2, 1); // subcmd, arg | 1723 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
1716 subcmd = *paramlst; | 1724 subcmd = *paramlst; |
1717 arg = *(paramlst+1); | 1725 arg = *(paramlst+1); |
1718 | 1726 |
1719 if (!subcmd || !*subcmd) { | 1727 if (!subcmd || !*subcmd) { |
1720 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1728 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
1721 free_arg_lst(paramlst); | 1729 free_arg_lst(paramlst); |
1722 return; | 1730 return; |
1723 } | 1731 } |
1724 | 1732 |
1725 if (!strcasecmp(subcmd, "join")) { | 1733 if (!strcasecmp(subcmd, "join")) { |
1778 { | 1786 { |
1779 char **paramlst; | 1787 char **paramlst; |
1780 char *subcmd; | 1788 char *subcmd; |
1781 | 1789 |
1782 if (!jb_getonline()) { | 1790 if (!jb_getonline()) { |
1783 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | 1791 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
1784 return; | 1792 return; |
1785 } | 1793 } |
1786 | 1794 |
1787 paramlst = split_arg(arg, 2, 0); // subcmd, [jid] | 1795 paramlst = split_arg(arg, 2, 0); // subcmd, [jid] |
1788 subcmd = *paramlst; | 1796 subcmd = *paramlst; |
1789 arg = *(paramlst+1); | 1797 arg = *(paramlst+1); |
1790 | 1798 |
1791 if (!subcmd || !*subcmd) { | 1799 if (!subcmd || !*subcmd) { |
1792 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | 1800 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
1793 free_arg_lst(paramlst); | 1801 free_arg_lst(paramlst); |
1794 return; | 1802 return; |
1795 } | 1803 } |
1796 | 1804 |
1797 // Use the provided jid, if it looks valid | 1805 // Use the provided jid, if it looks valid |
1799 if (!*arg) { | 1807 if (!*arg) { |
1800 // If no jid is provided, we use the current selected buddy | 1808 // If no jid is provided, we use the current selected buddy |
1801 arg = NULL; | 1809 arg = NULL; |
1802 } else { | 1810 } else { |
1803 if (check_jid_syntax(arg)) { | 1811 if (check_jid_syntax(arg)) { |
1804 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", arg); | 1812 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", arg); |
1805 free_arg_lst(paramlst); | 1813 free_arg_lst(paramlst); |
1806 return; | 1814 return; |
1807 } | 1815 } |
1808 } | 1816 } |
1809 } | 1817 } |
1817 | 1825 |
1818 arg = (char*)buddy_getjid(bud); | 1826 arg = (char*)buddy_getjid(bud); |
1819 type = buddy_gettype(bud); | 1827 type = buddy_gettype(bud); |
1820 | 1828 |
1821 if (!(type & (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT))) { | 1829 if (!(type & (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT))) { |
1822 scr_LogPrint(LPRINT_NORMAL, "Invalid buddy"); | 1830 scr_LogPrint(LPRINT_NORMAL, "Invalid buddy."); |
1823 return; | 1831 return; |
1824 } | 1832 } |
1825 } | 1833 } |
1826 | 1834 |
1827 if (!strcasecmp(subcmd, "allow")) { | 1835 if (!strcasecmp(subcmd, "allow")) { |
1828 jb_subscr_send_auth(arg); | 1836 jb_subscr_send_auth(arg); |
1829 scr_LogPrint(LPRINT_LOGNORM, | 1837 scr_LogPrint(LPRINT_LOGNORM, |
1830 "<%s> is allowed to receive your presence updates", arg); | 1838 "<%s> is now allowed to receive your presence updates.", arg); |
1831 } else if (!strcasecmp(subcmd, "cancel")) { | 1839 } else if (!strcasecmp(subcmd, "cancel")) { |
1832 jb_subscr_cancel_auth(arg); | 1840 jb_subscr_cancel_auth(arg); |
1833 scr_LogPrint(LPRINT_LOGNORM, | 1841 scr_LogPrint(LPRINT_LOGNORM, |
1834 "<%s> is no more allowed to receive your presence updates", | 1842 "<%s> will no longer receive your presence updates.", |
1835 arg); | 1843 arg); |
1836 } else if (!strcasecmp(subcmd, "request")) { | 1844 } else if (!strcasecmp(subcmd, "request")) { |
1837 jb_subscr_request_auth(arg); | 1845 jb_subscr_request_auth(arg); |
1838 scr_LogPrint(LPRINT_LOGNORM, | 1846 scr_LogPrint(LPRINT_LOGNORM, |
1839 "Sent presence notification request to <%s>", arg); | 1847 "Sent presence notification request to <%s>...", arg); |
1840 } else { | 1848 } else { |
1841 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | 1849 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
1842 } | 1850 } |
1843 | 1851 |
1844 free_arg_lst(paramlst); | 1852 free_arg_lst(paramlst); |
1845 } | 1853 } |
1846 | 1854 |
1847 static void do_version(char *arg) | 1855 static void do_version(char *arg) |
1848 { | 1856 { |
1849 scr_LogPrint(LPRINT_NORMAL, "This is mcabber version %s", PACKAGE_VERSION); | 1857 scr_LogPrint(LPRINT_NORMAL, "This is mcabber version %s.", PACKAGE_VERSION); |
1850 } | 1858 } |
1851 | 1859 |
1852 static void do_connect(char *arg) | 1860 static void do_connect(char *arg) |
1853 { | 1861 { |
1854 mcabber_connect(); | 1862 mcabber_connect(); |