Mon, 29 Aug 2011 02:53:05 +0000
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
| 8849 | 1 | /* |
| 2 | ||
| 15884 | 3 | silcpurple_ft.c |
| 8849 | 4 | |
| 5 | Author: Pekka Riikonen <priikone@silcnet.org> | |
| 6 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
7 | Copyright (C) 2004 - 2007 Pekka Riikonen |
| 8849 | 8 | |
| 9 | This program is free software; you can redistribute it and/or modify | |
| 10 | it under the terms of the GNU General Public License as published by | |
| 11 | the Free Software Foundation; version 2 of the License. | |
| 12 | ||
| 13 | This program is distributed in the hope that it will be useful, | |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | GNU General Public License for more details. | |
| 17 | ||
| 18 | */ | |
| 19 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
22972
diff
changeset
|
20 | #include "internal.h" |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
21 | #include "silc.h" |
| 8849 | 22 | #include "silcclient.h" |
| 15884 | 23 | #include "silcpurple.h" |
| 8849 | 24 | |
| 25 | /****************************** File Transfer ********************************/ | |
| 26 | ||
| 27 | /* This implements the secure file transfer protocol (SFTP) using the SILC | |
| 28 | SFTP library implementation. The API we use from the SILC Toolkit is the | |
| 29 | SILC Client file transfer API, as it provides a simple file transfer we | |
| 30 | need in this case. We could use the SILC SFTP API directly, but it would | |
| 31 | be an overkill since we'd effectively re-implement the file transfer what | |
| 32 | the SILC Client's file transfer API already provides. | |
| 33 | ||
| 15884 | 34 | From Purple we do NOT use the FT API to do the transfer as it is very limiting. |
| 8849 | 35 | In fact it does not suite to file transfers like SFTP at all. For example, |
| 36 | it assumes that read operations are synchronous what they are not in SFTP. | |
| 15884 | 37 | It also assumes that the file transfer socket is to be handled by the Purple |
| 8849 | 38 | eventloop, and this naturally is something we don't want to do in case of |
| 39 | SILC Toolkit. The FT API suites well to purely stream based file transfers | |
| 40 | like HTTP GET and similar. | |
| 41 | ||
| 15884 | 42 | For this reason, we directly access the Purple GKT FT API and hack the FT |
| 8849 | 43 | API to merely provide the user interface experience and all the magic |
| 44 | is done in the SILC Toolkit. Ie. we update the statistics information in | |
| 45 | the FT API for user interface, and that's it. A bit dirty but until the | |
| 46 | FT API gets better this is the way to go. Good thing that FT API allowed | |
| 47 | us to do this. */ | |
| 48 | ||
| 49 | typedef struct { | |
| 15884 | 50 | SilcPurple sg; |
| 8849 | 51 | SilcClientEntry client_entry; |
| 52 | SilcUInt32 session_id; | |
| 53 | char *hostname; | |
| 54 | SilcUInt16 port; | |
| 15884 | 55 | PurpleXfer *xfer; |
| 8849 | 56 | |
| 57 | SilcClientFileName completion; | |
| 58 | void *completion_context; | |
| 15884 | 59 | } *SilcPurpleXfer; |
| 8849 | 60 | |
| 61 | static void | |
| 15884 | 62 | silcpurple_ftp_monitor(SilcClient client, |
| 8849 | 63 | SilcClientConnection conn, |
| 64 | SilcClientMonitorStatus status, | |
| 65 | SilcClientFileError error, | |
| 66 | SilcUInt64 offset, | |
| 67 | SilcUInt64 filesize, | |
| 68 | SilcClientEntry client_entry, | |
| 69 | SilcUInt32 session_id, | |
| 70 | const char *filepath, | |
| 71 | void *context) | |
| 72 | { | |
| 15884 | 73 | SilcPurpleXfer xfer = context; |
| 74 | PurpleConnection *gc = xfer->sg->gc; | |
| 8849 | 75 | char tmp[256]; |
| 76 | ||
| 77 | if (status == SILC_CLIENT_FILE_MONITOR_CLOSED) { | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
78 | /* All started sessions terminate here */ |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
79 | purple_xfer_set_protocol_data(xfer->xfer, NULL); |
| 15884 | 80 | purple_xfer_unref(xfer->xfer); |
| 8849 | 81 | silc_free(xfer); |
| 82 | return; | |
| 83 | } | |
| 84 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
85 | if (status == SILC_CLIENT_FILE_MONITOR_DISCONNECT) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
86 | purple_notify_error(gc, _("Secure File Transfer"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
87 | _("Error during file transfer"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
88 | _("Remote disconnected")); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
89 | xfer->xfer->status = PURPLE_XFER_STATUS_CANCEL_REMOTE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
90 | purple_xfer_update_progress(xfer->xfer); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
91 | silc_client_file_close(client, conn, session_id); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
92 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
93 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
94 | |
| 8849 | 95 | if (status == SILC_CLIENT_FILE_MONITOR_KEY_AGREEMENT) |
| 96 | return; | |
| 97 | ||
| 98 | if (status == SILC_CLIENT_FILE_MONITOR_ERROR) { | |
| 99 | if (error == SILC_CLIENT_FILE_NO_SUCH_FILE) { | |
| 100 | g_snprintf(tmp, sizeof(tmp), "No such file %s", | |
| 101 | filepath ? filepath : "[N/A]"); | |
| 15884 | 102 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 103 | _("Error during file transfer"), tmp); |
| 104 | } else if (error == SILC_CLIENT_FILE_PERMISSION_DENIED) { | |
| 15884 | 105 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 106 | _("Error during file transfer"), |
| 107 | _("Permission denied")); | |
| 108 | } else if (error == SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED) { | |
| 15884 | 109 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 110 | _("Error during file transfer"), |
| 111 | _("Key agreement failed")); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
112 | } else if (error == SILC_CLIENT_FILE_TIMEOUT) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
113 | purple_notify_error(gc, _("Secure File Transfer"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
114 | _("Error during file transfer"), |
|
18168
07f5c0108577
Replace "timedout" with "timed out".
Richard Laager <rlaager@pidgin.im>
parents:
17675
diff
changeset
|
115 | _("Connection timed out")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
116 | } else if (error == SILC_CLIENT_FILE_CONNECT_FAILED) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
117 | purple_notify_error(gc, _("Secure File Transfer"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
118 | _("Error during file transfer"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
119 | _("Creating connection failed")); |
| 8849 | 120 | } else if (error == SILC_CLIENT_FILE_UNKNOWN_SESSION) { |
| 15884 | 121 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 122 | _("Error during file transfer"), |
|
10254
e7938826d550
[gaim-migrate @ 11394]
Mark Doliner <markdoliner@pidgin.im>
parents:
9788
diff
changeset
|
123 | _("File transfer session does not exist")); |
| 8849 | 124 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
125 | xfer->xfer->status = PURPLE_XFER_STATUS_CANCEL_REMOTE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
126 | purple_xfer_update_progress(xfer->xfer); |
| 8849 | 127 | silc_client_file_close(client, conn, session_id); |
| 128 | return; | |
| 129 | } | |
| 130 | ||
| 131 | /* Update file transfer UI */ | |
| 132 | if (!offset && filesize) | |
| 15884 | 133 | purple_xfer_set_size(xfer->xfer, filesize); |
| 8849 | 134 | if (offset && filesize) { |
| 135 | xfer->xfer->bytes_sent = offset; | |
| 136 | xfer->xfer->bytes_remaining = filesize - offset; | |
| 137 | } | |
| 15884 | 138 | purple_xfer_update_progress(xfer->xfer); |
| 8849 | 139 | |
| 140 | if (status == SILC_CLIENT_FILE_MONITOR_SEND || | |
| 141 | status == SILC_CLIENT_FILE_MONITOR_RECEIVE) { | |
| 142 | if (offset == filesize) { | |
| 143 | /* Download finished */ | |
| 15884 | 144 | purple_xfer_set_completed(xfer->xfer, TRUE); |
| 8849 | 145 | silc_client_file_close(client, conn, session_id); |
| 146 | } | |
| 147 | } | |
| 148 | } | |
| 149 | ||
| 150 | static void | |
| 15884 | 151 | silcpurple_ftp_cancel(PurpleXfer *x) |
| 8849 | 152 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
153 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
154 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
155 | if (!xfer) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
156 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
157 | |
| 15884 | 158 | xfer->xfer->status = PURPLE_XFER_STATUS_CANCEL_LOCAL; |
| 159 | purple_xfer_update_progress(xfer->xfer); | |
| 8849 | 160 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); |
| 161 | } | |
| 162 | ||
| 163 | static void | |
| 15884 | 164 | silcpurple_ftp_ask_name_cancel(PurpleXfer *x) |
| 8849 | 165 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
166 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 167 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
168 | if (!xfer) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
169 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
170 | |
| 8849 | 171 | /* Cancel the transmission */ |
| 172 | xfer->completion(NULL, xfer->completion_context); | |
| 173 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); | |
| 174 | } | |
| 175 | ||
| 176 | static void | |
| 15884 | 177 | silcpurple_ftp_ask_name_ok(PurpleXfer *x) |
| 8849 | 178 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
179 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 180 | const char *name; |
| 181 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
182 | if (!xfer) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
183 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
184 | |
| 15884 | 185 | name = purple_xfer_get_local_filename(x); |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10254
diff
changeset
|
186 | g_unlink(name); |
| 8849 | 187 | xfer->completion(name, xfer->completion_context); |
| 188 | } | |
| 189 | ||
| 190 | static void | |
| 15884 | 191 | silcpurple_ftp_ask_name(SilcClient client, |
| 8849 | 192 | SilcClientConnection conn, |
| 193 | SilcUInt32 session_id, | |
| 194 | const char *remote_filename, | |
| 195 | SilcClientFileName completion, | |
| 196 | void *completion_context, | |
| 197 | void *context) | |
| 198 | { | |
| 15884 | 199 | SilcPurpleXfer xfer = context; |
| 8849 | 200 | |
| 201 | xfer->completion = completion; | |
| 202 | xfer->completion_context = completion_context; | |
| 203 | ||
| 15884 | 204 | purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_ask_name_ok); |
| 205 | purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_ask_name_cancel); | |
| 8849 | 206 | |
| 207 | /* Request to save the file */ | |
| 15884 | 208 | purple_xfer_set_filename(xfer->xfer, remote_filename); |
| 209 | purple_xfer_request(xfer->xfer); | |
| 8849 | 210 | } |
| 211 | ||
| 212 | static void | |
| 15884 | 213 | silcpurple_ftp_request_result(PurpleXfer *x) |
| 8849 | 214 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
215 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 216 | SilcClientFileError status; |
| 15884 | 217 | PurpleConnection *gc = xfer->sg->gc; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
218 | SilcClientConnectionParams params; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
219 | gboolean local = xfer->hostname ? FALSE : TRUE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
220 | char *local_ip = NULL, *remote_ip = NULL; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
221 | SilcSocket sock; |
| 8849 | 222 | |
| 15884 | 223 | if (purple_xfer_get_status(x) != PURPLE_XFER_STATUS_ACCEPTED) |
| 8849 | 224 | return; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
225 | if (!xfer) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
226 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
227 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
228 | silc_socket_stream_get_info(silc_packet_stream_get_stream(xfer->sg->conn->stream), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
229 | &sock, NULL, NULL, NULL); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
230 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
231 | if (local) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
232 | /* Do the same magic what we do with key agreement (see silcpurple_buddy.c) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
233 | to see if we are behind NAT. */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
234 | if (silc_net_check_local_by_sock(sock, NULL, &local_ip)) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
235 | /* Check if the IP is private */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
236 | if (silcpurple_ip_is_private(local_ip)) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
237 | local = TRUE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
238 | /* Local IP is private, resolve the remote server IP to see whether |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
239 | we are talking to Internet or just on LAN. */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
240 | if (silc_net_check_host_by_sock(sock, NULL, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
241 | &remote_ip)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
242 | if (silcpurple_ip_is_private(remote_ip)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
243 | /* We assume we are in LAN. Let's provide the connection point. */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
244 | local = TRUE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
245 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
246 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
247 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
248 | if (local && !local_ip) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
249 | local_ip = silc_net_localip(); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
250 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
251 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
252 | memset(¶ms, 0, sizeof(params)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
253 | params.timeout_secs = 60; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
254 | if (local) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
255 | /* Provide connection point */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
256 | params.local_ip = local_ip; |
| 8849 | 257 | |
| 258 | /* Start the file transfer */ | |
| 259 | status = silc_client_file_receive(xfer->sg->client, xfer->sg->conn, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
260 | ¶ms, xfer->sg->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
261 | xfer->sg->private_key, |
| 15884 | 262 | silcpurple_ftp_monitor, xfer, |
| 8849 | 263 | NULL, xfer->session_id, |
| 15884 | 264 | silcpurple_ftp_ask_name, xfer); |
| 8849 | 265 | switch (status) { |
| 266 | case SILC_CLIENT_FILE_OK: | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
267 | silc_free(local_ip); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
268 | silc_free(remote_ip); |
| 8849 | 269 | return; |
| 270 | break; | |
| 271 | ||
| 272 | case SILC_CLIENT_FILE_UNKNOWN_SESSION: | |
| 15884 | 273 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 274 | _("No file transfer session active"), NULL); |
| 275 | break; | |
| 276 | ||
| 277 | case SILC_CLIENT_FILE_ALREADY_STARTED: | |
| 15884 | 278 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 279 | _("File transfer already started"), NULL); |
| 280 | break; | |
| 281 | ||
| 282 | case SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED: | |
| 15884 | 283 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 284 | _("Could not perform key agreement for file transfer"), |
| 285 | NULL); | |
| 286 | break; | |
| 287 | ||
| 288 | default: | |
| 15884 | 289 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 290 | _("Could not start the file transfer"), NULL); |
| 291 | break; | |
| 292 | } | |
| 293 | ||
| 294 | /* Error */ | |
| 15884 | 295 | purple_xfer_unref(xfer->xfer); |
| 8849 | 296 | g_free(xfer->hostname); |
| 297 | silc_free(xfer); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
298 | silc_free(local_ip); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
299 | silc_free(remote_ip); |
| 8849 | 300 | } |
| 301 | ||
| 302 | static void | |
| 15884 | 303 | silcpurple_ftp_request_denied(PurpleXfer *x) |
| 8849 | 304 | { |
| 305 | ||
| 306 | } | |
| 307 | ||
| 15884 | 308 | void silcpurple_ftp_request(SilcClient client, SilcClientConnection conn, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
309 | SilcClientEntry client_entry, SilcUInt32 session_id, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
310 | const char *hostname, SilcUInt16 port) |
| 8849 | 311 | { |
| 15884 | 312 | PurpleConnection *gc = client->application; |
| 313 | SilcPurple sg = gc->proto_data; | |
| 314 | SilcPurpleXfer xfer; | |
| 8849 | 315 | |
| 316 | xfer = silc_calloc(1, sizeof(*xfer)); | |
| 317 | if (!xfer) { | |
|
13453
4000a28ae1f5
[gaim-migrate @ 15827]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12149
diff
changeset
|
318 | silc_client_file_close(sg->client, sg->conn, session_id); |
| 8849 | 319 | return; |
| 320 | } | |
| 321 | ||
| 322 | xfer->sg = sg; | |
| 323 | xfer->client_entry = client_entry; | |
| 324 | xfer->session_id = session_id; | |
| 325 | xfer->hostname = g_strdup(hostname); | |
| 326 | xfer->port = port; | |
| 15884 | 327 | xfer->xfer = purple_xfer_new(xfer->sg->account, PURPLE_XFER_RECEIVE, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
328 | xfer->client_entry->nickname); |
| 8849 | 329 | if (!xfer->xfer) { |
| 330 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); | |
| 331 | g_free(xfer->hostname); | |
| 332 | silc_free(xfer); | |
| 333 | return; | |
| 334 | } | |
| 15884 | 335 | purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_request_result); |
| 336 | purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_request_denied); | |
| 337 | purple_xfer_set_cancel_recv_fnc(xfer->xfer, silcpurple_ftp_cancel); | |
| 8849 | 338 | xfer->xfer->remote_ip = g_strdup(hostname); |
| 339 | xfer->xfer->remote_port = port; | |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
340 | purple_xfer_set_protocol_data(xfer->xfer, xfer); |
| 8849 | 341 | |
| 342 | /* File transfer request */ | |
| 15884 | 343 | purple_xfer_request(xfer->xfer); |
| 8849 | 344 | } |
| 345 | ||
| 346 | static void | |
| 15884 | 347 | silcpurple_ftp_send_cancel(PurpleXfer *x) |
| 8849 | 348 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
349 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
350 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
351 | if (!xfer) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
352 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
353 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
354 | /* This call will free all resources */ |
| 8849 | 355 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); |
| 356 | } | |
| 357 | ||
| 358 | static void | |
| 15884 | 359 | silcpurple_ftp_send(PurpleXfer *x) |
| 8849 | 360 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
361 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 362 | const char *name; |
| 8910 | 363 | char *local_ip = NULL, *remote_ip = NULL; |
| 8849 | 364 | gboolean local = TRUE; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
365 | SilcClientConnectionParams params; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
366 | SilcSocket sock; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
367 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
368 | if (!xfer) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
369 | return; |
| 8849 | 370 | |
| 15884 | 371 | name = purple_xfer_get_local_filename(x); |
| 8849 | 372 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
373 | silc_socket_stream_get_info(silc_packet_stream_get_stream(xfer->sg->conn->stream), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
374 | &sock, NULL, NULL, NULL); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
375 | |
| 15884 | 376 | /* Do the same magic what we do with key agreement (see silcpurple_buddy.c) |
| 8849 | 377 | to see if we are behind NAT. */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
378 | if (silc_net_check_local_by_sock(sock, NULL, &local_ip)) { |
| 8849 | 379 | /* Check if the IP is private */ |
| 15884 | 380 | if (silcpurple_ip_is_private(local_ip)) { |
| 8849 | 381 | local = FALSE; |
| 382 | /* Local IP is private, resolve the remote server IP to see whether | |
| 383 | we are talking to Internet or just on LAN. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
384 | if (silc_net_check_host_by_sock(sock, NULL, |
| 8849 | 385 | &remote_ip)) |
| 15884 | 386 | if (silcpurple_ip_is_private(remote_ip)) |
| 8849 | 387 | /* We assume we are in LAN. Let's provide the connection point. */ |
| 388 | local = TRUE; | |
| 389 | } | |
| 390 | } | |
| 391 | ||
| 392 | if (local && !local_ip) | |
| 393 | local_ip = silc_net_localip(); | |
| 394 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
395 | memset(¶ms, 0, sizeof(params)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
396 | params.timeout_secs = 60; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
397 | if (local) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
398 | /* Provide connection point */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
399 | params.local_ip = local_ip; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
400 | |
| 8849 | 401 | /* Send the file */ |
| 402 | silc_client_file_send(xfer->sg->client, xfer->sg->conn, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
403 | xfer->client_entry, ¶ms, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
404 | xfer->sg->public_key, xfer->sg->private_key, |
| 15884 | 405 | silcpurple_ftp_monitor, xfer, |
| 8849 | 406 | name, &xfer->session_id); |
| 407 | ||
| 408 | silc_free(local_ip); | |
| 409 | silc_free(remote_ip); | |
| 410 | } | |
| 411 | ||
| 412 | static void | |
| 15884 | 413 | silcpurple_ftp_send_file_resolved(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
414 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
415 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
416 | SilcDList clients, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
417 | void *context) |
| 8849 | 418 | { |
| 15884 | 419 | PurpleConnection *gc = client->application; |
| 8849 | 420 | char tmp[256]; |
| 421 | ||
| 422 | if (!clients) { | |
| 423 | g_snprintf(tmp, sizeof(tmp), | |
| 424 | _("User %s is not present in the network"), | |
| 425 | (const char *)context); | |
| 15884 | 426 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 427 | _("Cannot send file"), tmp); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
18168
diff
changeset
|
428 | g_free(context); |
| 8849 | 429 | return; |
| 430 | } | |
| 431 | ||
| 15884 | 432 | silcpurple_ftp_send_file(client->application, (const char *)context, NULL); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
18168
diff
changeset
|
433 | g_free(context); |
| 8849 | 434 | } |
| 435 | ||
| 15884 | 436 | PurpleXfer *silcpurple_ftp_new_xfer(PurpleConnection *gc, const char *name) |
| 8849 | 437 | { |
| 15884 | 438 | SilcPurple sg = gc->proto_data; |
| 8849 | 439 | SilcClient client = sg->client; |
| 440 | SilcClientConnection conn = sg->conn; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
441 | SilcDList clients; |
| 15884 | 442 | SilcPurpleXfer xfer; |
| 8849 | 443 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
444 | g_return_val_if_fail(name != NULL, NULL); |
| 8849 | 445 | |
| 446 | /* Find client entry */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
447 | clients = silc_client_get_clients_local(client, conn, name, FALSE); |
| 8849 | 448 | if (!clients) { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
449 | silc_client_get_clients(client, conn, name, NULL, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
450 | silcpurple_ftp_send_file_resolved, |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
18168
diff
changeset
|
451 | g_strdup(name)); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
452 | return NULL; |
| 8849 | 453 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
454 | silc_dlist_start(clients); |
| 8849 | 455 | |
| 456 | xfer = silc_calloc(1, sizeof(*xfer)); | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
457 | g_return_val_if_fail(xfer != NULL, NULL); |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
458 | |
| 8849 | 459 | xfer->sg = sg; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
460 | xfer->client_entry = silc_dlist_get(clients); |
| 15884 | 461 | xfer->xfer = purple_xfer_new(xfer->sg->account, PURPLE_XFER_SEND, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
462 | xfer->client_entry->nickname); |
| 8849 | 463 | if (!xfer->xfer) { |
| 464 | silc_free(xfer); | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
465 | return NULL; |
| 8849 | 466 | } |
| 15884 | 467 | purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_send); |
| 468 | purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_request_denied); | |
| 469 | purple_xfer_set_cancel_send_fnc(xfer->xfer, silcpurple_ftp_send_cancel); | |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
470 | purple_xfer_set_protocol_data(xfer->xfer, xfer); |
| 8849 | 471 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
472 | silc_free(clients); |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
473 | |
|
12149
9706e9a4fad3
[gaim-migrate @ 14450]
Richard Laager <rlaager@pidgin.im>
parents:
12143
diff
changeset
|
474 | return xfer->xfer; |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
475 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
476 | |
| 15884 | 477 | void silcpurple_ftp_send_file(PurpleConnection *gc, const char *name, const char *file) |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
478 | { |
| 15884 | 479 | PurpleXfer *xfer = silcpurple_ftp_new_xfer(gc, name); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
480 | |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
481 | g_return_if_fail(xfer != NULL); |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
482 | |
| 8849 | 483 | /* Choose file to send */ |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9353
diff
changeset
|
484 | if (file) |
| 15884 | 485 | purple_xfer_request_accepted(xfer, file); |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9353
diff
changeset
|
486 | else |
| 15884 | 487 | purple_xfer_request(xfer); |
| 8849 | 488 | } |