diff --git a/po/POTFILES.in b/po/POTFILES.in index f3aba4202..fe508b5c6 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -239,6 +239,8 @@ ./src/plugins/xfer/xfer-chat.h ./src/plugins/xfer/xfer-command.c ./src/plugins/xfer/xfer-command.h +./src/plugins/xfer/xfer-completion.c +./src/plugins/xfer/xfer-completion.h ./src/plugins/xfer/xfer-config.c ./src/plugins/xfer/xfer-config.h ./src/plugins/xfer/xfer-dcc.c diff --git a/po/cs.po b/po/cs.po index dcc92c415..a6964c8ef 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-22 16:17+0100\n" +"POT-Creation-Date: 2009-03-23 11:08+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -5334,6 +5334,10 @@ msgstr "Ruším aktivní DCC: \"%s\" od %s\n" msgid "%s%s: error sending data to \"%s\" via xfer chat" msgstr "%s chyba posílání dat k \"%s\" přes DCC CHAT\n" +#, fuzzy, c-format +msgid "%s%s: can't find xfer for buffer \"%s\"" +msgstr "%s nemohu vytvořít nové soukromý buffer\"%s\"\n" + #, fuzzy, c-format msgid "Connected to %s (%d.%d.%d.%d) via xfer chat" msgstr "Připojeno na %s%s %s(%s%d.%d.%d.%d.%s)%s přes DCC rozhovor\n" diff --git a/po/de.po b/po/de.po index d8a8ca493..e9dbe3d27 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-22 16:17+0100\n" +"POT-Creation-Date: 2009-03-23 11:08+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Thomas Schuetz \n" "Language-Team: weechat-dev \n" @@ -5272,6 +5272,10 @@ msgstr "Aktiver DCC wird abgebrochen: \"%s\" von %s\n" msgid "%s%s: error sending data to \"%s\" via xfer chat" msgstr "%s Fehler beim Senden von Daten an \"%s\" via DCC CHAT\n" +#, fuzzy, c-format +msgid "%s%s: can't find xfer for buffer \"%s\"" +msgstr "%s kann kein neues privates Fenster \"%s\" erzeugen\n" + #, fuzzy, c-format msgid "Connected to %s (%d.%d.%d.%d) via xfer chat" msgstr "DCC Chat mit %s%s %s(%s%d.%d.%d.%d%s)%s aufgebaut\n" diff --git a/po/es.po b/po/es.po index 9c5cadfd2..0791ec3ea 100644 --- a/po/es.po +++ b/po/es.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-22 16:17+0100\n" +"POT-Creation-Date: 2009-03-23 11:08+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Roberto González Cardenete \n" "Language-Team: weechat-dev \n" @@ -5265,6 +5265,10 @@ msgstr "Abandonar el DCC activo: \"%s\" de %s\n" msgid "%s%s: error sending data to \"%s\" via xfer chat" msgstr "%s error enviando datos al \"%s\" con DCC CHAT\n" +#, fuzzy, c-format +msgid "%s%s: can't find xfer for buffer \"%s\"" +msgstr "%s no es posible crear una nueva ventana privada \"%s\"\n" + #, fuzzy, c-format msgid "Connected to %s (%d.%d.%d.%d) via xfer chat" msgstr "Conectado a %s%s %s(%s%d.%d.%d.%d%s)%s a través de una charla DCC\n" diff --git a/po/fr.po b/po/fr.po index dc475553f..bb35273d0 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-22 16:17+0100\n" -"PO-Revision-Date: 2009-03-22 16:17+0100\n" +"POT-Creation-Date: 2009-03-23 11:08+0100\n" +"PO-Revision-Date: 2009-03-23 11:08+0100\n" "Last-Translator: FlashCode \n" "Language-Team: weechat-dev \n" "MIME-Version: 1.0\n" @@ -5463,6 +5463,10 @@ msgstr "%s%s: abandon du xfer actif: \"%s\" de %s" msgid "%s%s: error sending data to \"%s\" via xfer chat" msgstr "%s%s: erreur d'envoi de données à \"%s\" via discussion xfer" +#, c-format +msgid "%s%s: can't find xfer for buffer \"%s\"" +msgstr "%s%s: impossible de trouver le xfer pour le tampon \"%s\"" + #, c-format msgid "Connected to %s (%d.%d.%d.%d) via xfer chat" msgstr "Connecté à %s (%d.%d.%d.%d) via discussion xfer" diff --git a/po/hu.po b/po/hu.po index 07a8d53e7..6d61967a2 100644 --- a/po/hu.po +++ b/po/hu.po @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-22 16:17+0100\n" +"POT-Creation-Date: 2009-03-23 11:08+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -5329,6 +5329,10 @@ msgstr "\"%s\" aktív DCC megszakítása a következővel: %s\n" msgid "%s%s: error sending data to \"%s\" via xfer chat" msgstr "%s hiba a(z) \"%s\" felé DCC CHAT-tel történő adatküldés közben\n" +#, fuzzy, c-format +msgid "%s%s: can't find xfer for buffer \"%s\"" +msgstr "%s nem sikerült új privát ablakot nyitni \"%s\"\n" + #, fuzzy, c-format msgid "Connected to %s (%d.%d.%d.%d) via xfer chat" msgstr "" diff --git a/po/ru.po b/po/ru.po index f18f9adf1..0a358604d 100644 --- a/po/ru.po +++ b/po/ru.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-22 16:17+0100\n" +"POT-Creation-Date: 2009-03-23 11:08+0100\n" "PO-Revision-Date: 2009-01-03 00:42+0100\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -5300,6 +5300,10 @@ msgstr "Отменяю активное DCC-сединение: \"%s\" от %s\n msgid "%s%s: error sending data to \"%s\" via xfer chat" msgstr "%s ошибка при отправке данных \"%s\" через DCC-чат\n" +#, fuzzy, c-format +msgid "%s%s: can't find xfer for buffer \"%s\"" +msgstr "%s невозможно создать новый буфер привата \"%s\"\n" + #, fuzzy, c-format msgid "Connected to %s (%d.%d.%d.%d) via xfer chat" msgstr "Соединён с %s%s %s(%s%d.%d.%d.%d%s)%s DCC-чатом\n" diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake index 8d375cc34..606075ca4 100644 --- a/po/srcfiles.cmake +++ b/po/srcfiles.cmake @@ -240,6 +240,8 @@ SET(WEECHAT_SOURCES ./src/plugins/xfer/xfer-chat.h ./src/plugins/xfer/xfer-command.c ./src/plugins/xfer/xfer-command.h +./src/plugins/xfer/xfer-completion.c +./src/plugins/xfer/xfer-completion.h ./src/plugins/xfer/xfer-config.c ./src/plugins/xfer/xfer-config.h ./src/plugins/xfer/xfer-dcc.c diff --git a/po/weechat.pot b/po/weechat.pot index 811ae6d74..24f613fde 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2009-03-22 16:17+0100\n" +"POT-Creation-Date: 2009-03-23 11:08+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -4597,6 +4597,10 @@ msgstr "" msgid "%s%s: error sending data to \"%s\" via xfer chat" msgstr "" +#, c-format +msgid "%s%s: can't find xfer for buffer \"%s\"" +msgstr "" + #, c-format msgid "Connected to %s (%d.%d.%d.%d) via xfer chat" msgstr "" diff --git a/src/plugins/xfer/CMakeLists.txt b/src/plugins/xfer/CMakeLists.txt index a7d7135b1..4d8e8f543 100644 --- a/src/plugins/xfer/CMakeLists.txt +++ b/src/plugins/xfer/CMakeLists.txt @@ -19,6 +19,7 @@ xfer.c xfer.h xfer-buffer.c xfer-buffer.h xfer-chat.c xfer-chat.h xfer-command.c xfer-command.h +xfer-completion.c xfer-completion.h xfer-config.c xfer-config.h xfer-dcc.c xfer-dcc.h xfer-file.c xfer-file.h diff --git a/src/plugins/xfer/Makefile.am b/src/plugins/xfer/Makefile.am index 9e2615180..d7c1fa52b 100644 --- a/src/plugins/xfer/Makefile.am +++ b/src/plugins/xfer/Makefile.am @@ -28,6 +28,8 @@ xfer_la_SOURCES = xfer.c \ xfer-chat.h \ xfer-command.c \ xfer-command.h \ + xfer-completion.c \ + xfer-completion.h \ xfer-config.c \ xfer-config.h \ xfer-dcc.c \ diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c index 27dfb1a41..495a94ee3 100644 --- a/src/plugins/xfer/xfer-chat.c +++ b/src/plugins/xfer/xfer-chat.c @@ -136,7 +136,8 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) if (ptr_buf) { - weechat_printf (xfer->buffer, "%s\t%s", xfer->remote_nick, ptr_buf); + weechat_printf_tags (xfer->buffer, "notify_message", "%s\t%s", + xfer->remote_nick, ptr_buf); } ptr_buf = next_ptr_buf; @@ -163,18 +164,30 @@ int xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer, const char *input_data) { - struct t_xfer *xfer; + struct t_xfer *ptr_xfer; - xfer = (struct t_xfer *)data; + /* make C compiler happy */ + (void) data; - if (!XFER_HAS_ENDED(xfer->status)) + ptr_xfer = xfer_search_by_buffer (buffer); + + if (!ptr_xfer) { - xfer_chat_sendf (xfer, "%s\n", input_data); - if (!XFER_HAS_ENDED(xfer->status)) + weechat_printf (NULL, + _("%s%s: can't find xfer for buffer \"%s\""), + weechat_prefix ("error"), XFER_PLUGIN_NAME, + weechat_buffer_get_string (buffer, "name")); + return WEECHAT_RC_OK; + } + + if (!XFER_HAS_ENDED(ptr_xfer->status)) + { + xfer_chat_sendf (ptr_xfer, "%s\n", input_data); + if (!XFER_HAS_ENDED(ptr_xfer->status)) { weechat_printf (buffer, "%s\t%s", - xfer->local_nick, + ptr_xfer->local_nick, input_data); } } @@ -190,21 +203,25 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer, int xfer_chat_buffer_close_cb (void *data, struct t_gui_buffer *buffer) { - struct t_xfer *xfer; + struct t_xfer *ptr_xfer; /* make C compiler happy */ + (void) data; (void) buffer; - xfer = (struct t_xfer *)data; + ptr_xfer = xfer_search_by_buffer (buffer); - if (!XFER_HAS_ENDED(xfer->status)) - { - xfer_close (xfer, XFER_STATUS_ABORTED); - xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); + if (ptr_xfer) + { + if (!XFER_HAS_ENDED(ptr_xfer->status)) + { + xfer_close (ptr_xfer, XFER_STATUS_ABORTED); + xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE); + } + + ptr_xfer->buffer = NULL; } - xfer->buffer = NULL; - return WEECHAT_RC_OK; } @@ -217,28 +234,40 @@ xfer_chat_open_buffer (struct t_xfer *xfer) { char *name; int length; - - length = strlen (xfer->plugin_name) + 1 + strlen (xfer->remote_nick) + 1; + + length = strlen (xfer->plugin_name) + 8 + strlen (xfer->remote_nick) + 1; name = malloc (length); if (name) { - snprintf (name, length, "%s_%s", xfer->plugin_name, xfer->remote_nick); - xfer->buffer = weechat_buffer_new (name, - &xfer_chat_buffer_input_cb, xfer, - &xfer_chat_buffer_close_cb, xfer); - if (xfer->buffer) + snprintf (name, length, "%s_dcc_%s", + xfer->plugin_name, xfer->remote_nick); + xfer->buffer = weechat_buffer_search (XFER_PLUGIN_NAME, name); + if (!xfer->buffer) { - weechat_buffer_set (xfer->buffer, "title", _("xfer chat")); - weechat_buffer_set (xfer->buffer, "localvar_set_type", "private"); - weechat_printf (xfer->buffer, - _("Connected to %s (%d.%d.%d.%d) via " - "xfer chat"), - xfer->remote_nick, - xfer->address >> 24, - (xfer->address >> 16) & 0xff, - (xfer->address >> 8) & 0xff, - xfer->address & 0xff); + xfer->buffer = weechat_buffer_new (name, + &xfer_chat_buffer_input_cb, NULL, + &xfer_chat_buffer_close_cb, NULL); + + /* failed to create buffer ? then return */ + if (!xfer->buffer) + return; } + + weechat_buffer_set (xfer->buffer, "title", _("xfer chat")); + weechat_buffer_set (xfer->buffer, "short_name", xfer->remote_nick); + weechat_buffer_set (xfer->buffer, "localvar_set_type", "private"); + weechat_buffer_set (xfer->buffer, "localvar_set_nick", xfer->local_nick); + weechat_buffer_set (xfer->buffer, "localvar_set_channel", xfer->remote_nick); + weechat_buffer_set (xfer->buffer, "highlight_words", xfer->local_nick); + weechat_printf (xfer->buffer, + _("Connected to %s (%d.%d.%d.%d) via " + "xfer chat"), + xfer->remote_nick, + xfer->address >> 24, + (xfer->address >> 16) & 0xff, + (xfer->address >> 8) & 0xff, + xfer->address & 0xff); + free (name); } } diff --git a/src/plugins/xfer/xfer-completion.c b/src/plugins/xfer/xfer-completion.c new file mode 100644 index 000000000..d0f36b3ca --- /dev/null +++ b/src/plugins/xfer/xfer-completion.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2003-2009 by FlashCode + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* xfer-completion.c: nick completion for xfer chats */ + + +#include +#include +#include + +#include "../weechat-plugin.h" +#include "xfer.h" +#include "xfer-completion.h" + + +/* + * xfer_completion_nick_cb: callback for completion with nick + */ + +int +xfer_completion_nick_cb (void *data, const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + struct t_xfer *ptr_xfer; + + /* make C compiler happy */ + (void) data; + (void) completion_item; + + ptr_xfer = xfer_search_by_buffer (buffer); + if (ptr_xfer) + { + /* remote nick */ + weechat_hook_completion_list_add (completion, + ptr_xfer->remote_nick, + 0, + WEECHAT_LIST_POS_SORT); + /* add self nick at the end */ + weechat_hook_completion_list_add (completion, + ptr_xfer->local_nick, + 1, + WEECHAT_LIST_POS_END); + } + + return WEECHAT_RC_OK; +} + +/* + * xfer_completion_init: init completion for xfer plugin + */ + +void +xfer_completion_init () +{ + weechat_hook_completion ("nick", + &xfer_completion_nick_cb, NULL); +} diff --git a/src/plugins/xfer/xfer-completion.h b/src/plugins/xfer/xfer-completion.h new file mode 100644 index 000000000..c4e279925 --- /dev/null +++ b/src/plugins/xfer/xfer-completion.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2003-2009 by FlashCode + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#ifndef __WEECHAT_XFER_COMPLETION_H +#define __WEECHAT_XFER_COMPLETION_H 1 + +extern void xfer_completion_init (); + +#endif /* xfer-completion.h */ diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c index 16bb46d01..2ea59bdc5 100644 --- a/src/plugins/xfer/xfer.c +++ b/src/plugins/xfer/xfer.c @@ -34,6 +34,7 @@ #include "xfer.h" #include "xfer-buffer.h" #include "xfer-command.h" +#include "xfer-completion.h" #include "xfer-config.h" #include "xfer-file.h" #include "xfer-info.h" @@ -230,6 +231,28 @@ xfer_search_by_number (int number) return NULL; } +/* + * xfer_search_by_buffer: search a xfer by buffer (for chat only) + */ + +struct t_xfer * +xfer_search_by_buffer (struct t_gui_buffer *buffer) +{ + struct t_xfer *ptr_xfer; + + if (!buffer) + return NULL; + + for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer) + { + if (ptr_xfer->buffer == buffer) + return ptr_xfer; + } + + /* xfer not found */ + return NULL; +} + /* * xfer_close: close a xfer */ @@ -1393,13 +1416,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) xfer_create_directories (); xfer_command_init (); - + + /* hook some signals */ weechat_hook_signal ("upgrade", &xfer_signal_upgrade_cb, NULL); weechat_hook_signal ("xfer_add", &xfer_add_cb, NULL); weechat_hook_signal ("xfer_start_resume", &xfer_start_resume_cb, NULL); weechat_hook_signal ("xfer_accept_resume", &xfer_accept_resume_cb, NULL); weechat_hook_signal ("debug_dump", &xfer_debug_dump_cb, NULL); + /* hook completions */ + xfer_completion_init (); + xfer_info_init (); return WEECHAT_RC_OK; diff --git a/src/plugins/xfer/xfer.h b/src/plugins/xfer/xfer.h index 195e61ddb..ba973223a 100644 --- a/src/plugins/xfer/xfer.h +++ b/src/plugins/xfer/xfer.h @@ -157,6 +157,7 @@ extern int xfer_count; extern int xfer_valid (struct t_xfer *xfer); extern struct t_xfer *xfer_search_by_number (int number); +extern struct t_xfer *xfer_search_by_buffer (struct t_gui_buffer *buffer); extern void xfer_close (struct t_xfer *xfer, enum t_xfer_status status); extern void xfer_send_signal (struct t_xfer *xfer, const char *signal); extern void xfer_free (struct t_xfer *xfer);