]> jfr.im git - irc/weechat/weechat.git/commitdiff
xfer: add and identify active/passive xfer types.
authorMario Campos <redacted>
Fri, 18 Aug 2023 15:07:23 +0000 (10:07 -0500)
committerSébastien Helleu <redacted>
Wed, 6 Sep 2023 12:11:35 +0000 (14:11 +0200)
Before making any significant changes, let's identify the existing xfer types by either active or passive.

src/plugins/irc/irc-command.c
src/plugins/irc/irc-ctcp.c
src/plugins/irc/irc-server.c
src/plugins/xfer/xfer-network.c
src/plugins/xfer/xfer.c
src/plugins/xfer/xfer.h

index 1b6a2fecbf2d4db65f53c5de582d93cee42ff63a..cef86f0d3310243846bdd1a3854d547f8dd6aeff 100644 (file)
@@ -2148,7 +2148,7 @@ IRC_COMMAND_CALLBACK(dcc)
             {
                 weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
                 weechat_infolist_new_var_string (item, "plugin_id", ptr_server->name);
-                weechat_infolist_new_var_string (item, "type_string", "file_send");
+                weechat_infolist_new_var_string (item, "type_string", "file_send_passive");
                 weechat_infolist_new_var_string (item, "protocol_string", "dcc");
                 weechat_infolist_new_var_string (item, "remote_nick", argv[2]);
                 weechat_infolist_new_var_string (item, "local_nick", ptr_server->nick);
index e86a14c900379536f4fbdbeb364071f0c9e2fa60..071636f52ed79d24e3faaf24c47c968288b89ec8 100644 (file)
@@ -914,7 +914,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
             {
                 weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
                 weechat_infolist_new_var_string (item, "plugin_id", server->name);
-                weechat_infolist_new_var_string (item, "type_string", "file_recv");
+                weechat_infolist_new_var_string (item, "type_string", "file_recv_active");
                 weechat_infolist_new_var_string (item, "protocol_string", "dcc");
                 weechat_infolist_new_var_string (item, "remote_nick", nick);
                 weechat_infolist_new_var_string (item, "local_nick", server->nick);
@@ -1063,7 +1063,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
             {
                 weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
                 weechat_infolist_new_var_string (item, "plugin_id", server->name);
-                weechat_infolist_new_var_string (item, "type_string", "file_recv");
+                weechat_infolist_new_var_string (item, "type_string", "file_recv_active");
                 weechat_infolist_new_var_string (item, "filename",
                                                  (filename) ? filename : pos_file);
                 weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
@@ -1206,7 +1206,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
             {
                 weechat_infolist_new_var_string (item, "plugin_name", weechat_plugin->name);
                 weechat_infolist_new_var_string (item, "plugin_id", server->name);
-                weechat_infolist_new_var_string (item, "type_string", "file_recv");
+                weechat_infolist_new_var_string (item, "type_string", "file_recv_active");
                 weechat_infolist_new_var_string (item, "filename",
                                                  (filename) ? filename : pos_file);
                 weechat_infolist_new_var_integer (item, "port", atoi (pos_port));
index 2fa848792c42f79d33e2d4c4d09790501481a6cd..7ef98bd67e56beac1389d6fcd15e3fedd6c830e2 100644 (file)
@@ -6226,7 +6226,7 @@ irc_server_xfer_send_ready_cb (const void *pointer, void *data,
                 if (type && converted_addr[0])
                 {
                     /* send DCC PRIVMSG */
-                    if (strcmp (type, "file_send") == 0)
+                    if (strcmp (type, "file_send_passive") == 0)
                     {
                         filename = weechat_infolist_string (infolist, "filename");
                         spaces_in_name = (strchr (filename, ' ') != NULL);
index 5ba39b4bf470d0ba71025a972dd936298bbc19c4..02b0991d2fde3cf1bd7168cdc6b7712e079943d2 100644 (file)
@@ -498,7 +498,7 @@ xfer_network_fd_cb (const void *pointer, void *data, int fd)
 
     if (xfer->status == XFER_STATUS_CONNECTING)
     {
-        if (xfer->type == XFER_TYPE_FILE_SEND)
+        if (xfer->type == XFER_TYPE_FILE_SEND_PASSIVE)
         {
             xfer->last_activity = time (NULL);
             sock = accept (xfer->sock,
index 01297e47d4fc1049c6346656ec451513709ebadc..e4a62a2dc6901d4bc58734d9b14c7824ec0768ed 100644 (file)
@@ -55,8 +55,9 @@ WEECHAT_PLUGIN_PRIORITY(XFER_PLUGIN_PRIORITY);
 struct t_weechat_plugin *weechat_xfer_plugin = NULL;
 
 char *xfer_type_string[] =             /* strings for types                 */
-{ "file_recv", "file_send", "chat_recv",
-  "chat_send"
+{ "file_recv_active", "file_recv_passive",
+  "file_send_active", "file_send_passive",
+  "chat_recv", "chat_send"
 };
 
 char *xfer_protocol_string[] =         /* strings for protocols             */
@@ -349,7 +350,7 @@ xfer_close (struct t_xfer *xfer, enum t_xfer_status status)
                             (xfer->status == XFER_STATUS_DONE) ? "" : weechat_prefix ("error"),
                             XFER_PLUGIN_NAME,
                             xfer->filename,
-                            (xfer->type == XFER_TYPE_FILE_SEND) ? _("sent to") : _("received from"),
+                            (xfer->type == XFER_TYPE_FILE_SEND_PASSIVE) ? _("sent to") : _("received from"),
                             xfer->remote_nick,
                             xfer->remote_address_str,
                             (xfer->status == XFER_STATUS_DONE) ? _("OK") : _("FAILED"));
@@ -713,7 +714,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
     new_xfer->hash_target = NULL;
     new_xfer->hash_status = XFER_HASH_STATUS_UNKNOWN;
 
-    if ((type == XFER_TYPE_FILE_RECV)
+    if ((type == XFER_TYPE_FILE_RECV_ACTIVE)
         && weechat_config_boolean (xfer_config_file_auto_check_crc32))
     {
         ptr_crc32 = xfer_file_search_crc32 (new_xfer->filename);
@@ -742,7 +743,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
     /* write info message on core buffer */
     switch (type)
     {
-        case XFER_TYPE_FILE_RECV:
+        case XFER_TYPE_FILE_RECV_ACTIVE:
             weechat_printf (NULL,
                             _("%s: incoming file from %s "
                               "(%s, %s.%s), name: %s, %llu bytes "
@@ -757,7 +758,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
                             xfer_protocol_string[protocol]);
             xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
             break;
-        case XFER_TYPE_FILE_SEND:
+        case XFER_TYPE_FILE_SEND_PASSIVE:
             weechat_printf (NULL,
                             _("%s: offering file to %s (%s.%s), name: %s "
                               "(local filename: %s), %llu bytes (protocol: %s)"),
@@ -831,7 +832,7 @@ xfer_new (const char *plugin_name, const char *plugin_id,
      */
     if ((XFER_IS_RECV(type)
          && xfer_nick_auto_accepted (new_xfer->plugin_id, new_xfer->remote_nick))
-        || ((type == XFER_TYPE_FILE_RECV)
+        || ((type == XFER_TYPE_FILE_RECV_ACTIVE)
             && weechat_config_boolean (xfer_config_file_auto_accept_files))
         || ((type == XFER_TYPE_CHAT_RECV)
             && weechat_config_boolean (xfer_config_file_auto_accept_chats)))
@@ -1079,13 +1080,13 @@ xfer_add_cb (const void *pointer, void *data,
         }
     }
 
-    if (type == XFER_TYPE_FILE_RECV)
+    if (type == XFER_TYPE_FILE_RECV_ACTIVE)
     {
         filename2 = strdup (filename);
         sscanf (weechat_infolist_string (infolist, "size"), "%llu", &file_size);
     }
 
-    if (type == XFER_TYPE_FILE_SEND)
+    if (type == XFER_TYPE_FILE_SEND_PASSIVE)
     {
         /* add home if filename not beginning with '/' or '~' (not for Win32) */
 #ifdef _WIN32
@@ -1317,7 +1318,7 @@ xfer_add_cb (const void *pointer, void *data,
         }
     }
 
-    if (type == XFER_TYPE_FILE_RECV)
+    if (type == XFER_TYPE_FILE_RECV_ACTIVE)
     {
         if (filename2)
         {
@@ -1428,7 +1429,7 @@ xfer_start_resume_cb (const void *pointer, void *data,
 
     sscanf (str_start_resume, "%llu", &start_resume);
 
-    ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_RECV,
+    ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_RECV_ACTIVE,
                             XFER_STATUS_CONNECTING, port);
     if (ptr_xfer)
     {
@@ -1514,7 +1515,7 @@ xfer_accept_resume_cb (const void *pointer, void *data,
 
     sscanf (str_start_resume, "%llu", &start_resume);
 
-    ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_SEND,
+    ptr_xfer = xfer_search (plugin_name, plugin_id, XFER_TYPE_FILE_SEND_PASSIVE,
                             XFER_STATUS_CONNECTING, port);
     if (ptr_xfer)
     {
index c01afa220ba342711e7935e728b094656ea086eb..cc422f86fd9b13e0ff1d6501881ae16ffc0e788f 100644 (file)
 
 enum t_xfer_type
 {
-    XFER_TYPE_FILE_RECV = 0,
-    XFER_TYPE_FILE_SEND,
+    XFER_TYPE_FILE_RECV_ACTIVE = 0,
+    XFER_TYPE_FILE_RECV_PASSIVE,
+    XFER_TYPE_FILE_SEND_ACTIVE,
+    XFER_TYPE_FILE_SEND_PASSIVE,
     XFER_TYPE_CHAT_RECV,
     XFER_TYPE_CHAT_SEND,
     /* number of xfer types */
@@ -117,14 +119,22 @@ enum t_xfer_hash_status
 
 /* macros for type/status */
 
-#define XFER_IS_FILE(type) ((type == XFER_TYPE_FILE_RECV) ||    \
-                            (type == XFER_TYPE_FILE_SEND))
+#define XFER_IS_FILE(type) ((type == XFER_TYPE_FILE_RECV_ACTIVE) ||  \
+                            (type == XFER_TYPE_FILE_RECV_PASSIVE) || \
+                            (type == XFER_TYPE_FILE_SEND_ACTIVE) ||  \
+                            (type == XFER_TYPE_FILE_SEND_PASSIVE))
 #define XFER_IS_CHAT(type) ((type == XFER_TYPE_CHAT_RECV) ||    \
                             (type == XFER_TYPE_CHAT_SEND))
-#define XFER_IS_RECV(type) ((type == XFER_TYPE_FILE_RECV) ||    \
+#define XFER_IS_RECV(type) ((type == XFER_TYPE_FILE_RECV_ACTIVE) ||  \
+                            (type == XFER_TYPE_FILE_RECV_PASSIVE) || \
                             (type == XFER_TYPE_CHAT_RECV))
-#define XFER_IS_SEND(type) ((type == XFER_TYPE_FILE_SEND) ||    \
+#define XFER_IS_SEND(type) ((type == XFER_TYPE_FILE_SEND_ACTIVE) ||  \
+                            (type == XFER_TYPE_FILE_SEND_PASSIVE) || \
                             (type == XFER_TYPE_CHAT_SEND))
+#define XFER_IS_ACTIVE(type) ((type == XFER_TYPE_FILE_RECV_ACTIVE) || \
+                              (type == XFER_TYPE_FILE_SEND_ACTIVE))
+#define XFER_IS_PASSIVE(type) ((type == XFER_TYPE_FILE_RECV_PASSIVE) || \
+                               (type == XFER_TYPE_FILE_SEND_PASSIVE))
 
 #define XFER_HAS_ENDED(status) ((status == XFER_STATUS_DONE) ||      \
                                 (status == XFER_STATUS_FAILED) ||    \