Tue, 30 Aug 2011 20:21:33 +0000
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_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) { |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32259
diff
changeset
|
135 | purple_xfer_set_bytes_sent(xfer->xfer, offset); |
| 8849 | 136 | } |
| 15884 | 137 | purple_xfer_update_progress(xfer->xfer); |
| 8849 | 138 | |
| 139 | if (status == SILC_CLIENT_FILE_MONITOR_SEND || | |
| 140 | status == SILC_CLIENT_FILE_MONITOR_RECEIVE) { | |
| 141 | if (offset == filesize) { | |
| 142 | /* Download finished */ | |
| 15884 | 143 | purple_xfer_set_completed(xfer->xfer, TRUE); |
| 8849 | 144 | silc_client_file_close(client, conn, session_id); |
| 145 | } | |
| 146 | } | |
| 147 | } | |
| 148 | ||
| 149 | static void | |
| 15884 | 150 | silcpurple_ftp_cancel(PurpleXfer *x) |
| 8849 | 151 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
152 | 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
|
153 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
154 | 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
|
155 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
156 | |
| 15884 | 157 | xfer->xfer->status = PURPLE_XFER_STATUS_CANCEL_LOCAL; |
| 158 | purple_xfer_update_progress(xfer->xfer); | |
| 8849 | 159 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); |
| 160 | } | |
| 161 | ||
| 162 | static void | |
| 15884 | 163 | silcpurple_ftp_ask_name_cancel(PurpleXfer *x) |
| 8849 | 164 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
165 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 166 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
167 | 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
|
168 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
169 | |
| 8849 | 170 | /* Cancel the transmission */ |
| 171 | xfer->completion(NULL, xfer->completion_context); | |
| 172 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); | |
| 173 | } | |
| 174 | ||
| 175 | static void | |
| 15884 | 176 | silcpurple_ftp_ask_name_ok(PurpleXfer *x) |
| 8849 | 177 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
178 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 179 | const char *name; |
| 180 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
181 | 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
|
182 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
183 | |
| 15884 | 184 | name = purple_xfer_get_local_filename(x); |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10254
diff
changeset
|
185 | g_unlink(name); |
| 8849 | 186 | xfer->completion(name, xfer->completion_context); |
| 187 | } | |
| 188 | ||
| 189 | static void | |
| 15884 | 190 | silcpurple_ftp_ask_name(SilcClient client, |
| 8849 | 191 | SilcClientConnection conn, |
| 192 | SilcUInt32 session_id, | |
| 193 | const char *remote_filename, | |
| 194 | SilcClientFileName completion, | |
| 195 | void *completion_context, | |
| 196 | void *context) | |
| 197 | { | |
| 15884 | 198 | SilcPurpleXfer xfer = context; |
| 8849 | 199 | |
| 200 | xfer->completion = completion; | |
| 201 | xfer->completion_context = completion_context; | |
| 202 | ||
| 15884 | 203 | purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_ask_name_ok); |
| 204 | purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_ask_name_cancel); | |
| 8849 | 205 | |
| 206 | /* Request to save the file */ | |
| 15884 | 207 | purple_xfer_set_filename(xfer->xfer, remote_filename); |
| 208 | purple_xfer_request(xfer->xfer); | |
| 8849 | 209 | } |
| 210 | ||
| 211 | static void | |
| 15884 | 212 | silcpurple_ftp_request_result(PurpleXfer *x) |
| 8849 | 213 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
214 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 215 | SilcClientFileError status; |
| 15884 | 216 | 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
|
217 | 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
|
218 | 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
|
219 | 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
|
220 | SilcSocket sock; |
| 8849 | 221 | |
| 15884 | 222 | if (purple_xfer_get_status(x) != PURPLE_XFER_STATUS_ACCEPTED) |
| 8849 | 223 | 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
|
224 | 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
|
225 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
226 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
227 | 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
|
228 | &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
|
229 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
230 | 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
|
231 | /* 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
|
232 | 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
|
233 | 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
|
234 | /* 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
|
235 | 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
|
236 | 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
|
237 | /* 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
|
238 | 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
|
239 | 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
|
240 | &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
|
241 | 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
|
242 | /* 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
|
243 | 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
|
244 | } |
|
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 | 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
|
248 | 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
|
249 | } |
|
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 | 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
|
252 | 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
|
253 | 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
|
254 | /* 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
|
255 | params.local_ip = local_ip; |
| 8849 | 256 | |
| 257 | /* Start the file transfer */ | |
| 258 | 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
|
259 | ¶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
|
260 | xfer->sg->private_key, |
| 15884 | 261 | silcpurple_ftp_monitor, xfer, |
| 8849 | 262 | NULL, xfer->session_id, |
| 15884 | 263 | silcpurple_ftp_ask_name, xfer); |
| 8849 | 264 | switch (status) { |
| 265 | 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
|
266 | 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
|
267 | silc_free(remote_ip); |
| 8849 | 268 | return; |
| 269 | break; | |
| 270 | ||
| 271 | case SILC_CLIENT_FILE_UNKNOWN_SESSION: | |
| 15884 | 272 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 273 | _("No file transfer session active"), NULL); |
| 274 | break; | |
| 275 | ||
| 276 | case SILC_CLIENT_FILE_ALREADY_STARTED: | |
| 15884 | 277 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 278 | _("File transfer already started"), NULL); |
| 279 | break; | |
| 280 | ||
| 281 | case SILC_CLIENT_FILE_KEY_AGREEMENT_FAILED: | |
| 15884 | 282 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 283 | _("Could not perform key agreement for file transfer"), |
| 284 | NULL); | |
| 285 | break; | |
| 286 | ||
| 287 | default: | |
| 15884 | 288 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 289 | _("Could not start the file transfer"), NULL); |
| 290 | break; | |
| 291 | } | |
| 292 | ||
| 293 | /* Error */ | |
| 15884 | 294 | purple_xfer_unref(xfer->xfer); |
| 8849 | 295 | g_free(xfer->hostname); |
| 296 | 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
|
297 | 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
|
298 | silc_free(remote_ip); |
| 8849 | 299 | } |
| 300 | ||
| 301 | static void | |
| 15884 | 302 | silcpurple_ftp_request_denied(PurpleXfer *x) |
| 8849 | 303 | { |
| 304 | ||
| 305 | } | |
| 306 | ||
| 15884 | 307 | 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
|
308 | 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
|
309 | const char *hostname, SilcUInt16 port) |
| 8849 | 310 | { |
| 15884 | 311 | PurpleConnection *gc = client->application; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
312 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 15884 | 313 | SilcPurpleXfer xfer; |
| 8849 | 314 | |
| 315 | xfer = silc_calloc(1, sizeof(*xfer)); | |
| 316 | if (!xfer) { | |
|
13453
4000a28ae1f5
[gaim-migrate @ 15827]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12149
diff
changeset
|
317 | silc_client_file_close(sg->client, sg->conn, session_id); |
| 8849 | 318 | return; |
| 319 | } | |
| 320 | ||
| 321 | xfer->sg = sg; | |
| 322 | xfer->client_entry = client_entry; | |
| 323 | xfer->session_id = session_id; | |
| 324 | xfer->hostname = g_strdup(hostname); | |
| 325 | xfer->port = port; | |
| 15884 | 326 | 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
|
327 | xfer->client_entry->nickname); |
| 8849 | 328 | if (!xfer->xfer) { |
| 329 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); | |
| 330 | g_free(xfer->hostname); | |
| 331 | silc_free(xfer); | |
| 332 | return; | |
| 333 | } | |
| 15884 | 334 | purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_request_result); |
| 335 | purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_request_denied); | |
| 336 | purple_xfer_set_cancel_recv_fnc(xfer->xfer, silcpurple_ftp_cancel); | |
| 8849 | 337 | xfer->xfer->remote_ip = g_strdup(hostname); |
| 338 | 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
|
339 | purple_xfer_set_protocol_data(xfer->xfer, xfer); |
| 8849 | 340 | |
| 341 | /* File transfer request */ | |
| 15884 | 342 | purple_xfer_request(xfer->xfer); |
| 8849 | 343 | } |
| 344 | ||
| 345 | static void | |
| 15884 | 346 | silcpurple_ftp_send_cancel(PurpleXfer *x) |
| 8849 | 347 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
348 | 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
|
349 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
350 | 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
|
351 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
352 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
353 | /* This call will free all resources */ |
| 8849 | 354 | silc_client_file_close(xfer->sg->client, xfer->sg->conn, xfer->session_id); |
| 355 | } | |
| 356 | ||
| 357 | static void | |
| 15884 | 358 | silcpurple_ftp_send(PurpleXfer *x) |
| 8849 | 359 | { |
|
32259
928cac2f99a1
Fix SILC for purple_xfer_[gs][4~et_protocol_data.
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
360 | SilcPurpleXfer xfer = purple_xfer_get_protocol_data(x); |
| 8849 | 361 | const char *name; |
| 8910 | 362 | char *local_ip = NULL, *remote_ip = NULL; |
| 8849 | 363 | 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
|
364 | 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
|
365 | 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
|
366 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
367 | 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
|
368 | return; |
| 8849 | 369 | |
| 15884 | 370 | name = purple_xfer_get_local_filename(x); |
| 8849 | 371 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
372 | 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
|
373 | &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
|
374 | |
| 15884 | 375 | /* Do the same magic what we do with key agreement (see silcpurple_buddy.c) |
| 8849 | 376 | 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
|
377 | if (silc_net_check_local_by_sock(sock, NULL, &local_ip)) { |
| 8849 | 378 | /* Check if the IP is private */ |
| 15884 | 379 | if (silcpurple_ip_is_private(local_ip)) { |
| 8849 | 380 | local = FALSE; |
| 381 | /* Local IP is private, resolve the remote server IP to see whether | |
| 382 | 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
|
383 | if (silc_net_check_host_by_sock(sock, NULL, |
| 8849 | 384 | &remote_ip)) |
| 15884 | 385 | if (silcpurple_ip_is_private(remote_ip)) |
| 8849 | 386 | /* We assume we are in LAN. Let's provide the connection point. */ |
| 387 | local = TRUE; | |
| 388 | } | |
| 389 | } | |
| 390 | ||
| 391 | if (local && !local_ip) | |
| 392 | local_ip = silc_net_localip(); | |
| 393 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
394 | 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
|
395 | 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
|
396 | 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
|
397 | /* 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
|
398 | 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
|
399 | |
| 8849 | 400 | /* Send the file */ |
| 401 | 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
|
402 | 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
|
403 | xfer->sg->public_key, xfer->sg->private_key, |
| 15884 | 404 | silcpurple_ftp_monitor, xfer, |
| 8849 | 405 | name, &xfer->session_id); |
| 406 | ||
| 407 | silc_free(local_ip); | |
| 408 | silc_free(remote_ip); | |
| 409 | } | |
| 410 | ||
| 411 | static void | |
| 15884 | 412 | 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
|
413 | 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
|
414 | 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
|
415 | 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
|
416 | void *context) |
| 8849 | 417 | { |
| 15884 | 418 | PurpleConnection *gc = client->application; |
| 8849 | 419 | char tmp[256]; |
| 420 | ||
| 421 | if (!clients) { | |
| 422 | g_snprintf(tmp, sizeof(tmp), | |
| 423 | _("User %s is not present in the network"), | |
| 424 | (const char *)context); | |
| 15884 | 425 | purple_notify_error(gc, _("Secure File Transfer"), |
| 8849 | 426 | _("Cannot send file"), tmp); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
18168
diff
changeset
|
427 | g_free(context); |
| 8849 | 428 | return; |
| 429 | } | |
| 430 | ||
| 15884 | 431 | 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
|
432 | g_free(context); |
| 8849 | 433 | } |
| 434 | ||
| 15884 | 435 | PurpleXfer *silcpurple_ftp_new_xfer(PurpleConnection *gc, const char *name) |
| 8849 | 436 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32270
diff
changeset
|
437 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 438 | SilcClient client = sg->client; |
| 439 | 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
|
440 | SilcDList clients; |
| 15884 | 441 | SilcPurpleXfer xfer; |
| 8849 | 442 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
443 | g_return_val_if_fail(name != NULL, NULL); |
| 8849 | 444 | |
| 445 | /* 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
|
446 | clients = silc_client_get_clients_local(client, conn, name, FALSE); |
| 8849 | 447 | 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
|
448 | 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
|
449 | 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
|
450 | g_strdup(name)); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
451 | return NULL; |
| 8849 | 452 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
453 | silc_dlist_start(clients); |
| 8849 | 454 | |
| 455 | xfer = silc_calloc(1, sizeof(*xfer)); | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
456 | g_return_val_if_fail(xfer != NULL, NULL); |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
457 | |
| 8849 | 458 | 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
|
459 | xfer->client_entry = silc_dlist_get(clients); |
| 15884 | 460 | 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
|
461 | xfer->client_entry->nickname); |
| 8849 | 462 | if (!xfer->xfer) { |
| 463 | silc_free(xfer); | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
464 | return NULL; |
| 8849 | 465 | } |
| 15884 | 466 | purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_send); |
| 467 | purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_request_denied); | |
| 468 | 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
|
469 | purple_xfer_set_protocol_data(xfer->xfer, xfer); |
| 8849 | 470 | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
471 | silc_free(clients); |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
472 | |
|
12149
9706e9a4fad3
[gaim-migrate @ 14450]
Richard Laager <rlaager@pidgin.im>
parents:
12143
diff
changeset
|
473 | return xfer->xfer; |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
474 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
475 | |
| 15884 | 476 | 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
|
477 | { |
| 15884 | 478 | PurpleXfer *xfer = silcpurple_ftp_new_xfer(gc, name); |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
479 | |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
480 | g_return_if_fail(xfer != NULL); |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11015
diff
changeset
|
481 | |
| 8849 | 482 | /* Choose file to send */ |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9353
diff
changeset
|
483 | if (file) |
| 15884 | 484 | purple_xfer_request_accepted(xfer, file); |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9353
diff
changeset
|
485 | else |
| 15884 | 486 | purple_xfer_request(xfer); |
| 8849 | 487 | } |