Changeset 4384
- Timestamp:
- 09/28/06 17:48:33 (2 years ago)
- Files:
-
- wire/trunk/Makefile.in (modified) (1 diff)
- wire/trunk/NEWS (modified) (1 diff)
- wire/trunk/man/wire.1 (modified) (2 diffs)
- wire/trunk/wire/chats.c (added)
- wire/trunk/wire/chats.h (added)
- wire/trunk/wire/client.c (modified) (33 diffs)
- wire/trunk/wire/commands.c (modified) (35 diffs)
- wire/trunk/wire/commands.h (modified) (1 diff)
- wire/trunk/wire/files.c (modified) (5 diffs)
- wire/trunk/wire/files.h (modified) (3 diffs)
- wire/trunk/wire/ignores.c (modified) (3 diffs)
- wire/trunk/wire/main.c (modified) (2 diffs)
- wire/trunk/wire/transfers.c (modified) (6 diffs)
- wire/trunk/wire/transfers.h (modified) (2 diffs)
- wire/trunk/wire/users.c (modified) (7 diffs)
- wire/trunk/wire/users.h (modified) (2 diffs)
- wire/trunk/wire/windows.c (modified) (23 diffs)
- wire/trunk/wire/windows.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wire/trunk/Makefile.in
r4260 r4384 17 17 SUBDIRS = libwired 18 18 19 WIREOBJECTS = $(objdir)/wire/client.o \ 19 WIREOBJECTS = $(objdir)/wire/chats.o \ 20 $(objdir)/wire/client.o \ 20 21 $(objdir)/wire/commands.o \ 21 22 $(objdir)/wire/files.o \ wire/trunk/NEWS
r4378 r4384 4 4 1.1.2 5 5 - Add globbing, e.g. /get *.mp3 6 - Add support for private chats 6 7 - Clear the chat action indicator when scrolling to the bottom of a window 7 8 wire/trunk/man/wire.1
r4197 r4384 141 141 .Pp 142 142 Example: /info morris 143 .It Nm invite Ar user 144 When in a private chat window, invites the user with the nick provided to participate in the chat. 145 .Pp 146 Example: /invite morris 143 147 .It Nm kick Ar user Ar message 144 148 Kicks a user. The first argument is the user to kick, the second is the message to send. … … 215 219 .Pp 216 220 Example: /put ~/a\ file.txt 221 .It Nm privchat Op Ar user 222 Creates a private chat. If a nick is a given, also invites that user to participate in the private chat. 223 .Pp 224 Example: /privchat 217 225 .It Nm pwd 218 226 Shows the current working directory. wire/trunk/wire/client.c
r4378 r4384 64 64 static void wr_msg_321(wi_array_t *); 65 65 static void wr_msg_322(wi_array_t *); 66 static void wr_msg_330(wi_array_t *); 66 67 static void wr_msg_331(wi_array_t *); 68 static void wr_msg_332(wi_array_t *); 67 69 static void wr_msg_341(wi_array_t *); 68 70 static void wr_msg_400(wi_array_t *); … … 179 181 180 182 void wr_connect(wi_string_t *hostname, unsigned int port, wi_string_t *login, wi_string_t *password) { 183 wi_enumerator_t *enumerator; 181 184 wi_list_t *addresses; 182 wi_list_node_t *node;183 185 wi_address_t *address; 184 186 wi_socket_t *socket; … … 202 204 } 203 205 204 WI_LIST_FOREACH(addresses, node, address) { 206 enumerator = wi_list_data_enumerator(addresses); 207 208 while((address = wi_enumerator_next_data(enumerator))) { 205 209 ip = wi_address_string(address); 206 210 … … 263 267 wi_release(wr_address); 264 268 265 wr_reply_uid = 0;266 267 269 wr_clear_windows(); 268 wr_clear_ users();270 wr_clear_chats(); 269 271 wr_clear_files(); 270 272 wr_clear_transfers(); 273 wr_clear_users(); 271 274 272 275 wr_connected = false; … … 331 334 case 321: wr_msg_321(arguments); break; 332 335 case 322: wr_msg_322(arguments); break; 333 case 330: break;336 case 330: wr_msg_330(arguments); break; 334 337 case 331: wr_msg_331(arguments); break; 335 case 332: break;338 case 332: wr_msg_332(arguments); break; 336 339 case 340: break; 337 340 case 341: wr_msg_341(arguments); break; … … 536 539 537 540 static void wr_msg_300(wi_array_t *arguments) { 541 wr_chat_t *chat; 538 542 wr_user_t *user; 539 543 wr_cid_t cid; … … 543 547 uid = wi_string_uint32(WI_ARRAY(arguments, 1)); 544 548 545 user = wr_user_with_uid(uid); 546 547 if(user && !wr_is_ignored(user->nick)) 548 wr_wprint_say(wr_window_with_chat(cid), user->nick, WI_ARRAY(arguments, 2)); 549 chat = wr_chats_chat_with_cid(cid); 550 user = wr_chat_user_with_uid(chat, uid); 551 552 if(user && !wr_is_ignored(wr_user_nick(user))) 553 wr_wprint_say(wr_windows_window_with_chat(chat), wr_user_nick(user), WI_ARRAY(arguments, 2)); 549 554 } 550 555 … … 552 557 553 558 static void wr_msg_301(wi_array_t *arguments) { 559 wr_chat_t *chat; 554 560 wr_user_t *user; 555 561 wr_cid_t cid; … … 559 565 uid = wi_string_uint32(WI_ARRAY(arguments, 1)); 560 566 561 user = wr_user_with_uid(uid); 562 563 if(user && !wr_is_ignored(user->nick)) 564 wr_wprint_me(wr_window_with_chat(cid), user->nick, WI_ARRAY(arguments, 2)); 567 chat = wr_chats_chat_with_cid(cid); 568 user = wr_chat_user_with_uid(chat, uid); 569 570 if(user && !wr_is_ignored(wr_user_nick(user))) 571 wr_wprint_me(wr_windows_window_with_chat(chat), wr_user_nick(user), WI_ARRAY(arguments, 2)); 565 572 } 566 573 … … 568 575 569 576 static void wr_msg_302(wi_array_t *arguments) { 577 wr_chat_t *chat; 570 578 wr_user_t *user; 571 579 wr_cid_t cid; 572 580 573 581 cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 574 575 user = wr_user_init(wr_user_alloc()); 576 577 user->uid = wi_string_uint32(WI_ARRAY(arguments, 1)); 578 user->idle = wi_string_bool(WI_ARRAY(arguments, 2)); 579 user->admin = wi_string_bool(WI_ARRAY(arguments, 3)); 580 user->nick = wi_retain(WI_ARRAY(arguments, 5)); 581 user->login = wi_retain(WI_ARRAY(arguments, 6)); 582 user->ip = wi_retain(WI_ARRAY(arguments, 7)); 583 user->status = wi_retain(WI_ARRAY(arguments, 9)); 584 585 wi_list_append_data(wr_users, user); 582 chat = wr_chats_chat_with_cid(cid); 583 584 user = wr_user_init_with_arguments(wr_user_alloc(), arguments); 585 wr_chat_add_user(chat, user); 586 586 wi_release(user); 587 587 588 588 wr_draw_divider(); 589 wr_wprintf_prefix(wr_window _with_chat(cid), WI_STR("%@ has joined"),590 user->nick);589 wr_wprintf_prefix(wr_windows_window_with_chat(chat), WI_STR("%@ has joined"), 590 wr_user_nick(user)); 591 591 } 592 592 … … 594 594 595 595 static void wr_msg_303(wi_array_t *arguments) { 596 wr_chat_t *chat; 596 597 wr_user_t *user; 597 598 wr_cid_t cid; … … 601 602 uid = wi_string_uint32(WI_ARRAY(arguments, 1)); 602 603 603 user = wr_user_with_uid(uid); 604 chat = wr_chats_chat_with_cid(cid); 605 user = wr_chat_user_with_uid(chat, uid); 604 606 605 607 if(user) { 606 wr_wprintf_prefix(wr_window _with_chat(cid), WI_STR("%@ has left"),607 user->nick);608 609 w i_list_remove_data(wr_users, user);608 wr_wprintf_prefix(wr_windows_window_with_chat(chat), WI_STR("%@ has left"), 609 wr_user_nick(user)); 610 611 wr_chat_remove_user(chat, user); 610 612 wr_draw_divider(); 611 613 } … … 620 622 621 623 uid = wi_string_uint32(WI_ARRAY(arguments, 0)); 622 user = wr_ user_with_uid(uid);624 user = wr_chat_user_with_uid(wr_public_chat, uid); 623 625 624 626 if(user) { 625 627 nick = WI_ARRAY(arguments, 4); 626 628 627 if(!wi_is_equal( user->nick, nick)) {629 if(!wi_is_equal(wr_user_nick(user), nick)) { 628 630 wr_wprintf_prefix(wr_console_window, WI_STR("%@ is now known as %@"), 629 user->nick, nick); 630 631 wi_release(user->nick); 632 user->nick = wi_retain(nick); 631 wr_user_nick(user), nick); 632 633 wr_user_set_nick(user, nick); 633 634 } 634 635 635 user->idle = wi_string_bool(WI_ARRAY(arguments, 1)); 636 user->admin = wi_string_bool(WI_ARRAY(arguments, 2)); 637 638 wi_release(user->status); 639 user->status = wi_retain(WI_ARRAY(arguments, 5)); 636 wr_user_set_idle(user, wi_string_bool(WI_ARRAY(arguments, 1))); 637 wr_user_set_admin(user, wi_string_bool(WI_ARRAY(arguments, 2))); 638 wr_user_set_status(user, WI_ARRAY(arguments, 5)); 640 639 } 641 640 } … … 649 648 650 649 uid = wi_string_uint32(WI_ARRAY(arguments, 0)); 651 user = wr_ user_with_uid(uid);652 653 if(user && !wr_is_ignored( user->nick)) {654 window = wr_window _with_user(user);650 user = wr_chat_user_with_uid(wr_public_chat, uid); 651 652 if(user && !wr_is_ignored(wr_user_nick(user))) { 653 window = wr_windows_window_with_user(user); 655 654 656 655 if(!window) { … … 660 659 } 661 660 662 wr_wprint_msg(window, user->nick, WI_ARRAY(arguments, 1));663 wr_reply_uid = user->uid;661 wr_wprint_msg(window, wr_user_nick(user), WI_ARRAY(arguments, 1)); 662 wr_reply_uid = wr_user_id(user); 664 663 } 665 664 } … … 676 675 message = WI_ARRAY(arguments, 2); 677 676 678 victim = wr_ user_with_uid(victim_uid);679 killer = wr_ user_with_uid(killer_uid);677 victim = wr_chat_user_with_uid(wr_public_chat, victim_uid); 678 killer = wr_chat_user_with_uid(wr_public_chat, killer_uid); 680 679 681 680 if(killer && victim) { 682 681 if(wi_string_length(message) > 0) { 683 682 wr_wprintf_prefix(wr_console_window, WI_STR("%@ was kicked by %@: %@"), 684 victim->nick, killer->nick, message);683 wr_user_nick(victim), wr_user_nick(killer), message); 685 684 } else { 686 685 wr_wprintf_prefix(wr_console_window, WI_STR("%@ was kicked by %@"), 687 victim->nick, killer->nick);686 wr_user_nick(victim), wr_user_nick(killer)); 688 687 } 689 688 } 690 689 691 690 if(victim) { 692 w i_list_remove_data(wr_users, victim);691 wr_chat_remove_user(wr_public_chat, victim); 693 692 wr_draw_divider(); 694 693 } … … 706 705 message = WI_ARRAY(arguments, 2); 707 706 708 victim = wr_ user_with_uid(victim_uid);709 killer = wr_ user_with_uid(killer_uid);707 victim = wr_chat_user_with_uid(wr_public_chat, victim_uid); 708 killer = wr_chat_user_with_uid(wr_public_chat, killer_uid); 710 709 711 710 if(killer && victim) { 712 711 if(wi_string_length(message) > 0) { 713 712 wr_wprintf_prefix(wr_console_window, WI_STR("%@ was banned by %@: %@"), 714 victim->nick, killer->nick, message);713 wr_user_nick(victim), wr_user_nick(killer), message); 715 714 } else { 716 715 wr_wprintf_prefix(wr_console_window, WI_STR("%@ was banned by %@"), 717 victim->nick, killer->nick);716 wr_user_nick(victim), wr_user_nick(killer)); 718 717 } 719 718 } 720 719 721 720 if(victim) { 722 w i_list_remove_data(wr_users, victim);721 wr_chat_remove_user(wr_public_chat, victim); 723 722 wr_draw_divider(); 724 723 } … … 728 727 729 728 static void wr_msg_308(wi_array_t *arguments) { 730 wi_date_t *date; 731 wi_array_t *array, *transfers; 732 wi_string_t *string, *interval, *name, *transferred, *size, *speed; 733 unsigned int n, i, count; 729 wi_enumerator_t *enumerator; 730 wi_date_t *date; 731 wi_array_t *array, *transfers; 732 wi_string_t *string, *interval, *name, *transferred, *size, *speed; 733 uint32_t n; 734 wi_boolean_t first; 734 735 735 736 wr_printf_prefix(WI_STR("User info:"), … … 761 762 string = WI_ARRAY(arguments, (n == WR_TRANSFER_DOWNLOAD) ? 13 : 14); 762 763 transfers = wi_string_components_separated_by_string(string, WI_STR(WR_GROUP_SEPARATOR_STR)); 763 count = wi_array_count(transfers);764 765 for(i = 0; i < count; i++) {766 string = WI_ARRAY(transfers, i);764 enumerator = wi_array_data_enumerator(transfers); 765 first = true; 766 767 while((string = wi_enumerator_next_data(enumerator))) { 767 768 array = wi_string_components_separated_by_string(string, WI_STR(WR_RECORD_SEPARATOR_STR)); 768 769 … … 773 774 speed = wr_files_string_for_size(wi_string_uint32(WI_ARRAY(array, 3))); 774 775 775 if( i == 0) {776 if(first) { 776 777 if(n == WR_TRANSFER_DOWNLOAD) { 777 778 wr_printf_block(WI_STR("Downloads: %@, %@ of %@, %@/s"), … … 786 787 } 787 788 } 789 790 first = false; 788 791 } 789 792 } … … 797 800 798 801 uid = wi_string_uint32(WI_ARRAY(arguments, 0)); 799 user = wr_ user_with_uid(uid);800 801 if(user && !wr_is_ignored( user->nick)) {802 user = wr_chat_user_with_uid(wr_public_chat, uid); 803 804 if(user && !wr_is_ignored(wr_user_nick(user))) { 802 805 wr_wprintf_prefix(wr_console_window, WI_STR("Broadcast message from %@:"), 803 user->nick);806 wr_user_nick(user)); 804 807 wr_wprintf_block(wr_console_window, WI_STR("%@"), 805 808 WI_ARRAY(arguments, 1)); … … 810 813 811 814 static void wr_msg_310(wi_array_t *arguments) { 815 wr_chat_t *chat; 812 816 wr_user_t *user; 813 814 user = wr_user_init(wr_user_alloc()); 815 816 user->uid = wi_string_uint32(WI_ARRAY(arguments, 1)); 817 user->idle = wi_string_bool(WI_ARRAY(arguments, 2)); 818 user->admin = wi_string_bool(WI_ARRAY(arguments, 3)); 819 user->nick = wi_retain(WI_ARRAY(arguments, 5)); 820 user->login = wi_retain(WI_ARRAY(arguments, 6)); 821 user->ip = wi_retain(WI_ARRAY(arguments, 7)); 822 user->status = wi_retain(WI_ARRAY(arguments, 9)); 823 824 wi_list_append_data(wr_users, user); 817 wr_cid_t cid; 818 819 cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 820 chat = wr_chats_chat_with_cid(cid); 821 822 user = wr_user_init_with_arguments(wr_user_alloc(), arguments); 823 wr_chat_add_user(chat, user); 825 824 wi_release(user); 826 825 } … … 829 828 830 829 static void wr_msg_311(wi_array_t *arguments) { 830 wr_chat_t *chat; 831 wr_cid_t cid; 832 833 cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 834 chat = wr_chats_chat_with_cid(cid); 835 831 836 wr_draw_divider(); 832 wr_print_users( );837 wr_print_users(wr_windows_window_with_chat(chat)); 833 838 } 834 839 … … 875 880 876 881 882 static void wr_msg_330(wi_array_t *arguments) { 883 wr_cid_t cid; 884 885 if(wr_private_chat) { 886 cid = wi_string_int32(WI_ARRAY(arguments, 0)); 887 888 wr_chat_set_id(wr_private_chat, cid); 889 wr_chats_add_chat(wr_private_chat); 890 891 wr_send_command(WI_STR("WHO %u"), cid); 892 893 if(wr_private_chat_invite_uid > 0) { 894 wr_send_command(WI_STR("INVITE %u%c%u"), 895 wr_private_chat_invite_uid, WR_FIELD_SEPARATOR, 896 cid); 897 } 898 899 wi_release(wr_private_chat); 900 wr_private_chat = NULL; 901 902 wr_private_chat_invite_uid = 0; 903 } 904 } 905 906 907 877 908 static void wr_msg_331(wi_array_t *arguments) { 909 wr_window_t *window; 910 wr_chat_t *chat; 878 911 wr_user_t *user; 912 wr_cid_t cid; 879 913 wr_uid_t uid; 880 914 915 cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 881 916 uid = wi_string_uint32(WI_ARRAY(arguments, 1)); 882 user = wr_user_with_uid(uid); 917 918 user = wr_chat_user_with_uid(wr_public_chat, uid); 883 919 884 920 if(user) { 885 wr_wprintf_prefix(wr_console_window, WI_STR("Private chat invitation from %@: %@"), 886 user->nick, 887 WI_STR("Not supported, declining")); 888 } 889 890 wr_send_command(WI_STR("DECLINE %#@"), WI_ARRAY(arguments, 0)); 921 wr_send_command(WI_STR("JOIN %u"), cid); 922 wr_send_command(WI_STR("WHO %u"), cid); 923 924 chat = wr_chat_init_private_chat(wr_chat_alloc()); 925 wr_chat_set_id(chat, cid); 926 wr_chats_add_chat(chat); 927 wi_release(chat); 928 929 window = wr_window_init_with_chat(wr_window_alloc(), chat); 930 wr_windows_add_window(window); 931 wr_windows_show_window(window); 932 wi_release(window); 933 } 934 } 935 936 937 938 static void wr_msg_332(wi_array_t *arguments) { 939 wr_chat_t *chat; 940 wr_user_t *user; 941 wr_cid_t cid; 942 wr_uid_t uid; 943 944 cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 945 uid = wi_string_uint32(WI_ARRAY(arguments, 1)); 946 947 chat = wr_chats_chat_with_cid(cid); 948 user = wr_chat_user_with_uid(wr_public_chat, uid); 949 950 if(user && chat) { 951 wr_wprintf_prefix(wr_windows_window_with_chat(chat), WI_STR("%@ has declined invitation"), 952 wr_user_nick(user)); 953 } 891 954 } 892 955 … … 895 958 static void wr_msg_341(wi_array_t *arguments) { 896 959 wi_date_t *date; 960 wr_chat_t *chat; 897 961 wr_window_t *window; 898 962 wr_cid_t cid; 899 963 900 964 cid = wi_string_uint32(WI_ARRAY(arguments, 0)); 901 window = wr_window_with_chat(cid); 902 903 if(window->type == WR_WINDOW_TYPE_CHAT) { 904 wi_release(window->topic.nick); 905 window->topic.nick = wi_retain(WI_ARRAY(arguments, 1)); 906 907 wi_release(window->topic.date); 908 date = wi_date_with_iso8601_string(WI_ARRAY(arguments, 4)); 909 window->topic.date = wi_retain(wi_date_string_with_format(date, WI_STR("%a %b %e %T %Y"))); 910 911 wi_release(window->topic.topic); 912 window->topic.topic = wi_retain(WI_ARRAY(arguments, 5)); 913 914 wr_draw_header(); 915 wr_print_topic(); 965 chat = wr_chats_chat_with_cid(cid); 966 967 if(chat) { 968 window = wr_windows_window_with_chat(chat); 969 970 if(window && wr_window_is_chat(window)) { 971 wi_release(window->topic.nick); 972 window->topic.nick = wi_retain(WI_ARRAY(arguments, 1)); 973 974 wi_release(window->topic.date); 975 date = wi_date_with_iso8601_string(WI_ARRAY(arguments, 4)); 976 window->topic.date = wi_retain(wi_date_string_with_format(date, WI_STR("%a %b %e %T %Y"))); 977 978 wi_release(window->topic.topic); 979 window->topic.topic = wi_retain(WI_ARRAY(arguments, 5)); 980 981 wr_draw_header(); 982 wr_print_topic(); 983 } 916 984 } 917 985 } … … 923 991 wr_transfer_t *transfer; 924 992 925 transfer = wr_transfer _with_path(WI_ARRAY(arguments, 0));993 transfer = wr_transfers_transfer_with_path(WI_ARRAY(arguments, 0)); 926 994 927 995 if(!transfer) … … 973 1041 wr_transfer_t *transfer; 974 1042 975 transfer = wr_transfer _with_path(WI_ARRAY(arguments, 0));1043 transfer = wr_transfers_transfer_with_path(WI_ARRAY(arguments, 0)); 976 1044 977 1045 if(transfer) { … … 1045 1113 } 1046 1114 else if(wr_stat_state == WR_STAT_TRANSFER) { 1047 transfer = wr_transfer _with_path(WI_ARRAY(arguments, 0));1115 transfer = wr_transfers_transfer_with_path(WI_ARRAY(arguments, 0)); 1048 1116 1049 1117 if(transfer) { … … 1077 1145 wr_file_t *file; 1078 1146 1079 file = wr_file_init(wr_file_alloc()); 1080 file->type = wi_string_uint32(WI_ARRAY(arguments, 1)); 1081 file->size = wi_string_uint32(WI_ARRAY(arguments, 2)); 1082 file->path = wi_retain(WI_ARRAY(arguments, 0)); 1083 file->name = wi_retain(wi_string_last_path_component(file->path)); 1084 1147 file = wr_file_init_with_arguments(wr_file_alloc(), arguments); 1085 1148 wi_array_add_data(wr_files, file); 1086 1149 wi_release(file); … … 1090 1153 1091 1154 static void wr_msg_411(wi_array_t *arguments) { 1092 wr_file_t *file;1093 1155 wi_file_offset_t free; 1094 uint32_t i, count, max_length = 0;1095 1156 1096 1157 if(wr_ls_state == WR_LS_LISTING) { 1097 1158 free = wi_string_uint64(WI_ARRAY(arguments, 1)); 1098 count = wi_array_count(wr_files);1099 1159 1100 1160 wr_printf_prefix(WI_STR("Listing of %@ (%@ available):"), wr_files_ld, wr_files_string_for_size(free)); 1101 1161 1102 if( count == 0) {1162 if(wi_array_count(wr_files) == 0) 1103 1163 wr_printf_block(WI_STR("(empty)")); 1104 } else { 1105 for(i = 0; i < count; i++) { 1106 file = WI_ARRAY(wr_files, i); 1107 max_length = WI_MAX(max_length, wi_string_length(file->name)); 1108 } 1109 1110 for(i = 0; i < count; i++) { 1111 file = WI_ARRAY(wr_files, i); 1112 wr_print_file(file, false, max_length); 1113 } 1114 } 1164 else 1165 wr_print_files(); 1115 1166 } 1116 1167 } … … 1121 1172 wr_file_t *file; 1122 1173 1123 file = wr_file_init(wr_file_alloc()); 1124 file->type = wi_string_uint32(WI_ARRAY(arguments, 1)); 1125 file->size = wi_string_uint32(WI_ARRAY(arguments, 2)); 1126 file->path = wi_retain(WI_ARRAY(arguments, 0)); 1127 file->name = wi_retain(wi_string_last_path_component(file->path)); 1128 1174 file = wr_file_init_with_arguments(wr_file_alloc(), arguments); 1129 1175 wi_array_add_data(wr_files, file); 1130 1176 wi_release(file); … … 1134 1180 1135 1181 static void wr_msg_421(wi_array_t *arguments) { 1136 wr_file_t *file;1137 uint32_t i, count, max_length = 0;1138 1139 count = wi_array_count(wr_files);1140 1141 1182 wr_printf_prefix(WI_STR("Search results:")); 1142 1183 1143 if( count == 0) {1184 if(wi_array_count(wr_files) == 0) 1144 1185 wr_printf_block(WI_STR("(none)")); 1145 } else { 1146 for(i = 0; i < count; i++) { 1147 file = WI_ARRAY(wr_files, i); 1148 max_length = WI_MAX(max_length, wi_string_length(file->name)); 1149 } 1150 1151 for(i = 0; i < count; i++) { 1152 file = WI_ARRAY(wr_files, i); 1153 wr_print_file(file, false, max_length); 1154 } 1155 } 1156 } 1186 else 1187 wr_print_files(); 1188 } wire/trunk/wire/commands.c
r4377 r4384 46 46 #include "windows.h" 47 47 48 struct _wr_commands { 49 const char *name; 50 51 wi_boolean_t help; 52 const char *usage; 53 54 wi_boolean_t connected; 55 unsigned int optargs; 56 int optindex; 57 wr_completer_t completer; 58 59 void (*action)(wi_array_t *); 60 }; 61 typedef struct _wr_commands wr_commands_t; 62 63 48 64 static unsigned int wr_command_index(wi_string_t *); 49 65 static void wr_command_usage(wi_string_t *); … … 64 80 static void wr_cmd_ignore(wi_array_t *); 65 81 static void wr_cmd_info(wi_array_t *); 82 static void wr_cmd_invite(wi_array_t *); 66 83 static void wr_cmd_kick(wi_array_t *); 67 84 static void wr_cmd_ls(wi_array_t *); … … 78 95 static void wr_cmd_post(wi_array_t *); 79 96 static void wr_cmd_put(wi_array_t *); 97 static void wr_cmd_privchat(wi_array_t *); 80 98 static void wr_cmd_pwd(wi_array_t *); 81 99 static void wr_cmd_quit(wi_array_t *); … … 176 194 true, 1, -1, WR_COMPLETER_NICKNAME, 177 195 wr_cmd_info }, 196 { "invite", 197 true, "<user>", 198 true, 1, -1, WR_COMPLETER_NICKNAME, 199 wr_cmd_invite }, 178 200 { "join", 179 201 false, "<server> [-l <login>] [-p <password>] [-P <port>]", … … 236 258 true, 1, 0, WR_COMPLETER_NICKNAME, 237 259 wr_cmd_post }, 260 { "privchat", 261 true, "[<user>]", 262 true, 0, -1, WR_COMPLETER_NICKNAME, 263 wr_cmd_privchat }, 238 264 { "put", 239 265 true, "<path>", … … 500 526 501 527 nick = WI_ARRAY(arguments, 0); 502 user = wr_ user_with_nick(nick);528 user = wr_chat_user_with_nick(wr_public_chat, nick); 503 529 504 530 if(!user) { … … 515 541 516 542 wr_send_command(WI_STR("BAN %u%c%#@"), 517 user->uid, WR_FIELD_SEPARATOR,543 wr_user_id(user), WR_FIELD_SEPARATOR, 518 544 message); 519 545 } … … 602 628 603 629 static void wr_cmd_close(wi_array_t *arguments) { 604 if(wr_ current_window == wr_console_window) {630 if(wr_window_is_public_chat(wr_current_window)) { 605 631 if(wr_connected) 606 632 wr_disconnect(); … … 608 634 wr_printf_prefix(WI_STR("%@: %@"), wr_last_command, WI_STR("Not connected")); 609 635 } else { 636 if(wr_window_is_private_chat(wr_current_window)) 637 wr_send_command(WI_STR("LEAVE %u"), wr_chat_id(wr_current_window->chat)); 638 610 639 wr_windows_close_window(wr_current_window); 611 640 } … … 615 644 616 645 /* 617 /comment <path> <comment>646 /comment <path> [<path> ...] <comment> 618 647 */ 619 648 … … 638 667 } 639 668 } else { 640 paths = wr_files_full_paths( wi_array_subarray_with_range(arguments, wi_make_range(0, wi_array_count(arguments) - 1)));669 paths = wr_files_full_paths(arguments); 641 670 count = wi_array_count(paths); 642 671 comment = wi_array_last_data(arguments); 643 672 644 for(i = 0; i < count ; i++) {673 for(i = 0; i < count - 1; i++) { 645 674 path = WI_ARRAY(paths, i); 646 675 … … 675 704 676 705 /* 677 /get <path> 706 /get <path> [<path> ...] 678 707 */ 679 708 680 709 static void wr_cmd_get(wi_array_t *arguments) { 681 wi_array_t *paths; 682 uint32_t i, count; 683 684 paths = wr_files_full_paths(arguments); 685 count = wi_array_count(paths); 686 687 for(i = 0; i < count; i++) 688 wr_transfer_download(WI_ARRAY(paths, i)); 710 wi_enumerator_t *enumerator; 711 wi_string_t *path; 712 713 enumerator = wi_array_data_enumerator(arguments); 714 715 while((path = wi_enumerator_next_data(enumerator))) 716 wr_transfers_download(path); 689 717 690 718 wr_draw_transfers(true); … … 780 808 781 809 static void wr_cmd_ignore(wi_array_t *arguments) { 782 wi_ list_node_t *node;810 wi_enumerator_t *enumerator; 783 811 wi_string_t *string; 784 812 wr_ignore_t *ignore; … … 804 832 wr_printf_block(WI_STR("(none)")); 805 833 } else { 806 WI_LIST_FOREACH(wr_ignores, node, ignore) 834 enumerator = wi_list_data_enumerator(wr_ignores); 835 836 while((ignore = wi_enumerator_next_data(enumerator))) 807 837 wr_printf_block(WI_STR("%u: %@"), wr_ignore_id(ignore), wr_ignore_string(ignore)); 808 838 } … … 813 843 814 844 /* 815 /info <user> 845 /info <user> [<user> ...] 816 846 */ 817 847 818 848 static void wr_cmd_info(wi_array_t *arguments) { 849 wi_enumerator_t *enumerator; 819 850 wi_string_t *nick; 820 851 wr_user_t *user; 821 822 nick = WI_ARRAY(arguments, 0); 823 user = wr_user_with_nick(nick); 824 825 if(!user) { 826 wr_printf_prefix(WI_STR("info: %@: Client not found"), 827 nick); 828 852 853 enumerator = wi_array_data_enumerator(arguments); 854 855 while((nick = wi_enumerator_next_data(enumerator))) { 856 user = wr_chat_user_with_nick(wr_public_chat, nick); 857 858 if(!user) { 859 wr_printf_prefix(WI_STR("info: %@: Client not found"), 860 nick); 861 862 continue; 863 } 864 865 wr_send_command(WI_STR("INFO %u"), wr_user_id(user)); 866 } 867 } 868 869 870 871 /* 872 /invite <user> [<user> ...] 873 */ 874 875 static void wr_cmd_invite(wi_array_t *arguments) { 876 wi_enumerator_t *enumerator; 877 wi_string_t *nick; 878 wr_user_t *user; 879 wr_chat_t *chat; 880 881 if(!wr_window_is_private_chat(wr_current_window)) { 882 wr_printf_prefix(WI_STR("invite: Current window is not a private chat")); 883 829 884 return; 830 885 } 831 832 wr_send_command(WI_STR("INFO %u"), user->uid); 886 887 chat = wr_current_window->chat; 888 enumerator = wi_array_data_enumerator(arguments); 889 890 while((nick = wi_enumerator_next_data(
