159 |
if (!cfg_dcc_auto_rename) |
if (!cfg_dcc_auto_rename) |
160 |
{ |
{ |
161 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
162 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
163 |
return; |
return; |
164 |
} |
} |
165 |
|
|
167 |
if (!filename2) |
if (!filename2) |
168 |
{ |
{ |
169 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
170 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
171 |
return; |
return; |
172 |
} |
} |
173 |
ptr_dcc->filename_suffix = 0; |
ptr_dcc->filename_suffix = 0; |
405 |
"(maybe private buffer has already DCC CHAT?)\n"), |
"(maybe private buffer has already DCC CHAT?)\n"), |
406 |
WEECHAT_ERROR); |
WEECHAT_ERROR); |
407 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
408 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
409 |
return; |
return; |
410 |
} |
} |
411 |
|
|
433 |
if (!dcc_connect (ptr_dcc)) |
if (!dcc_connect (ptr_dcc)) |
434 |
{ |
{ |
435 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
436 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
437 |
} |
} |
438 |
else |
else |
439 |
{ |
{ |
458 |
dcc_channel_for_chat (ptr_dcc); |
dcc_channel_for_chat (ptr_dcc); |
459 |
} |
} |
460 |
} |
} |
461 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
462 |
} |
} |
463 |
|
|
464 |
/* |
/* |
477 |
"PRIVMSG %s :\01DCC RESUME %s %d %u\01\r\n", |
"PRIVMSG %s :\01DCC RESUME %s %d %u\01\r\n", |
478 |
ptr_dcc->nick, ptr_dcc->filename, |
ptr_dcc->nick, ptr_dcc->filename, |
479 |
ptr_dcc->port, ptr_dcc->start_resume); |
ptr_dcc->port, ptr_dcc->start_resume); |
480 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
481 |
} |
} |
482 |
else |
else |
483 |
dcc_recv_connect_init (ptr_dcc); |
dcc_recv_connect_init (ptr_dcc); |
515 |
ptr_dcc->filename); |
ptr_dcc->filename); |
516 |
gui_printf (ptr_dcc->server->buffer, _("resumed at position %u\n"), |
gui_printf (ptr_dcc->server->buffer, _("resumed at position %u\n"), |
517 |
ptr_dcc->start_resume); |
ptr_dcc->start_resume); |
518 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
519 |
} |
} |
520 |
else |
else |
521 |
gui_printf (server->buffer, |
gui_printf (server->buffer, |
624 |
gui_printf (server->buffer, ", "); |
gui_printf (server->buffer, ", "); |
625 |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%lu", size); |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%lu", size); |
626 |
gui_printf (server->buffer, _(" bytes\n")); |
gui_printf (server->buffer, _(" bytes\n")); |
627 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
628 |
} |
} |
629 |
if (type == DCC_FILE_SEND) |
if (type == DCC_FILE_SEND) |
630 |
{ |
{ |
638 |
gui_printf (server->buffer, "), "); |
gui_printf (server->buffer, "), "); |
639 |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%lu", size); |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%lu", size); |
640 |
gui_printf (server->buffer, _(" bytes\n")); |
gui_printf (server->buffer, _(" bytes\n")); |
641 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
642 |
} |
} |
643 |
if (type == DCC_CHAT_RECV) |
if (type == DCC_CHAT_RECV) |
644 |
{ |
{ |
650 |
"%d.%d.%d.%d", |
"%d.%d.%d.%d", |
651 |
addr >> 24, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); |
addr >> 24, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); |
652 |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, ")\n"); |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, ")\n"); |
653 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
654 |
} |
} |
655 |
if (type == DCC_CHAT_SEND) |
if (type == DCC_CHAT_SEND) |
656 |
{ |
{ |
657 |
irc_display_prefix (server->buffer, PREFIX_INFO); |
irc_display_prefix (server->buffer, PREFIX_INFO); |
658 |
gui_printf (server->buffer, _("Sending DCC chat request to ")); |
gui_printf (server->buffer, _("Sending DCC chat request to ")); |
659 |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s\n", nick); |
gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s\n", nick); |
660 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
661 |
} |
} |
662 |
|
|
663 |
if (DCC_IS_FILE(type) && (!new_dcc->local_filename)) |
if (DCC_IS_FILE(type) && (!new_dcc->local_filename)) |
664 |
{ |
{ |
665 |
dcc_close (new_dcc, DCC_FAILED); |
dcc_close (new_dcc, DCC_FAILED); |
666 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
667 |
return NULL; |
return NULL; |
668 |
} |
} |
669 |
|
|
683 |
gui_printf (new_dcc->server->buffer, ") "); |
gui_printf (new_dcc->server->buffer, ") "); |
684 |
gui_printf (new_dcc->server->buffer, _("will be resumed at position %u\n"), |
gui_printf (new_dcc->server->buffer, _("will be resumed at position %u\n"), |
685 |
new_dcc->start_resume); |
new_dcc->start_resume); |
686 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
687 |
} |
} |
688 |
|
|
689 |
/* connect if needed and redraw DCC buffer */ |
/* connect if needed and redraw DCC buffer */ |
692 |
if (!dcc_connect (new_dcc)) |
if (!dcc_connect (new_dcc)) |
693 |
{ |
{ |
694 |
dcc_close (new_dcc, DCC_FAILED); |
dcc_close (new_dcc, DCC_FAILED); |
695 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
696 |
return NULL; |
return NULL; |
697 |
} |
} |
698 |
} |
} |
701 |
|| ( (type == DCC_FILE_RECV) && (cfg_dcc_auto_accept_files) ) ) |
|| ( (type == DCC_FILE_RECV) && (cfg_dcc_auto_accept_files) ) ) |
702 |
dcc_accept (new_dcc); |
dcc_accept (new_dcc); |
703 |
else |
else |
704 |
dcc_redraw (2); |
dcc_redraw (HOTLIST_PRIVATE); |
705 |
gui_draw_buffer_status (gui_current_window->buffer, 0); |
gui_draw_buffer_status (gui_current_window->buffer, 0); |
706 |
|
|
707 |
return new_dcc; |
return new_dcc; |
1033 |
else |
else |
1034 |
{ |
{ |
1035 |
dcc_close (ptr_dcc, DCC_ABORTED); |
dcc_close (ptr_dcc, DCC_ABORTED); |
1036 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1037 |
} |
} |
1038 |
} |
} |
1039 |
|
|
1062 |
if ((cfg_dcc_timeout != 0) && (time (NULL) > ptr_dcc->last_activity + cfg_dcc_timeout)) |
if ((cfg_dcc_timeout != 0) && (time (NULL) > ptr_dcc->last_activity + cfg_dcc_timeout)) |
1063 |
{ |
{ |
1064 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1065 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1066 |
continue; |
continue; |
1067 |
} |
} |
1068 |
} |
} |
1089 |
if (sock < 0) |
if (sock < 0) |
1090 |
{ |
{ |
1091 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1092 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1093 |
continue; |
continue; |
1094 |
} |
} |
1095 |
ptr_dcc->sock = sock; |
ptr_dcc->sock = sock; |
1096 |
if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1) |
if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1) |
1097 |
{ |
{ |
1098 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1099 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1100 |
continue; |
continue; |
1101 |
} |
} |
1102 |
ptr_dcc->addr = ntohl (addr.sin_addr.s_addr); |
ptr_dcc->addr = ntohl (addr.sin_addr.s_addr); |
1103 |
ptr_dcc->status = DCC_ACTIVE; |
ptr_dcc->status = DCC_ACTIVE; |
1104 |
ptr_dcc->file = open (ptr_dcc->local_filename, O_RDONLY | O_NONBLOCK, 0644); |
ptr_dcc->file = open (ptr_dcc->local_filename, O_RDONLY | O_NONBLOCK, 0644); |
1105 |
ptr_dcc->start_transfer = time (NULL); |
ptr_dcc->start_transfer = time (NULL); |
1106 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1107 |
} |
} |
1108 |
} |
} |
1109 |
} |
} |
1130 |
if (sock < 0) |
if (sock < 0) |
1131 |
{ |
{ |
1132 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1133 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1134 |
continue; |
continue; |
1135 |
} |
} |
1136 |
ptr_dcc->sock = sock; |
ptr_dcc->sock = sock; |
1137 |
if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1) |
if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1) |
1138 |
{ |
{ |
1139 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1140 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1141 |
continue; |
continue; |
1142 |
} |
} |
1143 |
ptr_dcc->addr = ntohl (addr.sin_addr.s_addr); |
ptr_dcc->addr = ntohl (addr.sin_addr.s_addr); |
1144 |
ptr_dcc->status = DCC_ACTIVE; |
ptr_dcc->status = DCC_ACTIVE; |
1145 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1146 |
dcc_channel_for_chat (ptr_dcc); |
dcc_channel_for_chat (ptr_dcc); |
1147 |
} |
} |
1148 |
} |
} |
1173 |
if (num_read == 0) |
if (num_read == 0) |
1174 |
{ |
{ |
1175 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1176 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1177 |
continue; |
continue; |
1178 |
} |
} |
1179 |
|
|
1180 |
if (write (ptr_dcc->file, buffer, num_read) == -1) |
if (write (ptr_dcc->file, buffer, num_read) == -1) |
1181 |
{ |
{ |
1182 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1183 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1184 |
continue; |
continue; |
1185 |
} |
} |
1186 |
ptr_dcc->last_activity = time (NULL); |
ptr_dcc->last_activity = time (NULL); |
1191 |
if (ptr_dcc->pos >= ptr_dcc->size) |
if (ptr_dcc->pos >= ptr_dcc->size) |
1192 |
{ |
{ |
1193 |
dcc_close (ptr_dcc, DCC_DONE); |
dcc_close (ptr_dcc, DCC_DONE); |
1194 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1195 |
} |
} |
1196 |
else |
else |
1197 |
dcc_redraw (0); |
dcc_redraw (HOTLIST_LOW); |
1198 |
} |
} |
1199 |
} |
} |
1200 |
if (ptr_dcc->type == DCC_FILE_SEND) |
if (ptr_dcc->type == DCC_FILE_SEND) |
1207 |
"max is %d.\n"), |
"max is %d.\n"), |
1208 |
sizeof (buffer)); |
sizeof (buffer)); |
1209 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1210 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1211 |
continue; |
continue; |
1212 |
} |
} |
1213 |
if (ptr_dcc->pos > ptr_dcc->ack) |
if (ptr_dcc->pos > ptr_dcc->ack) |
1219 |
if (num_read == 0) |
if (num_read == 0) |
1220 |
{ |
{ |
1221 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1222 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1223 |
continue; |
continue; |
1224 |
} |
} |
1225 |
if (num_read < 4) |
if (num_read < 4) |
1231 |
&& (ptr_dcc->ack >= ptr_dcc->size)) |
&& (ptr_dcc->ack >= ptr_dcc->size)) |
1232 |
{ |
{ |
1233 |
dcc_close (ptr_dcc, DCC_DONE); |
dcc_close (ptr_dcc, DCC_DONE); |
1234 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1235 |
continue; |
continue; |
1236 |
} |
} |
1237 |
} |
} |
1243 |
if (num_read < 1) |
if (num_read < 1) |
1244 |
{ |
{ |
1245 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1246 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1247 |
continue; |
continue; |
1248 |
} |
} |
1249 |
num_sent = send (ptr_dcc->sock, buffer, num_read, 0); |
num_sent = send (ptr_dcc->sock, buffer, num_read, 0); |
1250 |
if (num_sent < 0) |
if (num_sent < 0) |
1251 |
{ |
{ |
1252 |
dcc_close (ptr_dcc, DCC_FAILED); |
dcc_close (ptr_dcc, DCC_FAILED); |
1253 |
dcc_redraw (1); |
dcc_redraw (HOTLIST_MSG); |
1254 |
continue; |
continue; |
1255 |
} |
} |
1256 |
ptr_dcc->last_activity = time (NULL); |
ptr_dcc->last_activity = time (NULL); |
1257 |
ptr_dcc->pos += (unsigned long) num_sent; |
ptr_dcc->pos += (unsigned long) num_sent; |
1258 |
dcc_calculate_speed (ptr_dcc, 0); |
dcc_calculate_speed (ptr_dcc, 0); |
1259 |
dcc_redraw (0); |
dcc_redraw (HOTLIST_LOW); |
1260 |
} |
} |
1261 |
} |
} |
1262 |
} |
} |