comparison libpurple/protocols/jabber/si.c @ 25260:5456120de480

disapproval of revision '3de5eea959151773885ba601f681aec2431dd47d'
author Marcus Lundblad <ml@update.uu.se>
date Wed, 14 Jan 2009 18:53:28 +0000
parents dbba20fb7c39
children a34d6975c239
comparison
equal deleted inserted replaced
25259:dbba20fb7c39 25260:5456120de480
1027 PurpleXfer *xfer = jabber_si_xfer_find(js, sid, who); 1027 PurpleXfer *xfer = jabber_si_xfer_find(js, sid, who);
1028 if (xfer) { 1028 if (xfer) {
1029 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; 1029 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
1030 JabberIBBSession *sess = 1030 JabberIBBSession *sess =
1031 jabber_ibb_session_create_from_xmlnode(js, packet, xfer); 1031 jabber_ibb_session_create_from_xmlnode(js, packet, xfer);
1032 const char *filename;
1032 1033
1033 jabber_si_bytestreams_ibb_timeout_remove(jsx); 1034 jabber_si_bytestreams_ibb_timeout_remove(jsx);
1034 1035
1035 if (sess) { 1036 if (sess) {
1036 jsx->fp = xfer->dest_fp; 1037 /* open the file to write to */
1037 xfer->dest_fp = NULL; 1038 filename = purple_xfer_get_local_filename(xfer);
1038 /* the FD we get from xfer should never be NULL (see ft.c) */ 1039 jsx->fp = g_fopen(filename, "wb");
1039 1040 if (jsx->fp == NULL) {
1041 purple_debug_error("jabber", "failed to open file %s for writing: %s\n",
1042 filename, g_strerror(errno));
1043 purple_xfer_cancel_remote(xfer);
1044 return FALSE;
1045 }
1046
1040 /* setup callbacks here...*/ 1047 /* setup callbacks here...*/
1041 jabber_ibb_session_set_data_received_callback(sess, 1048 jabber_ibb_session_set_data_received_callback(sess,
1042 jabber_si_xfer_ibb_recv_data_cb); 1049 jabber_si_xfer_ibb_recv_data_cb);
1043 jabber_ibb_session_set_closed_callback(sess, 1050 jabber_ibb_session_set_closed_callback(sess,
1044 jabber_si_xfer_ibb_closed_cb); 1051 jabber_si_xfer_ibb_closed_cb);
1116 JabberStream *js = jabber_ibb_session_get_js(sess); 1123 JabberStream *js = jabber_ibb_session_get_js(sess);
1117 PurpleConnection *gc = js->gc; 1124 PurpleConnection *gc = js->gc;
1118 PurpleAccount *account = purple_connection_get_account(gc); 1125 PurpleAccount *account = purple_connection_get_account(gc);
1119 1126
1120 if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) { 1127 if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) {
1121 jsx->fp = xfer->dest_fp; 1128 const char *filename = purple_xfer_get_local_filename(xfer);
1122 xfer->dest_fp = NULL; /* disable double fclose */ 1129 jsx->fp = g_fopen(filename, "rb");
1123 /* the FD we get from xfer should never be NULL (see ft.c) */ 1130 if (jsx->fp == NULL) {
1124 1131 purple_debug_error("jabber", "Failed to open file %s for reading: %s\n",
1132 filename, g_strerror(errno));
1133 purple_xfer_error(purple_xfer_get_type(xfer), account,
1134 jabber_ibb_session_get_who(sess),
1135 _("Failed to open the file"));
1136 purple_xfer_cancel_local(xfer);
1137 return;
1138 }
1139
1125 purple_xfer_start(xfer, 0, NULL, 0); 1140 purple_xfer_start(xfer, 0, NULL, 0);
1126 purple_xfer_set_bytes_sent(xfer, 0); 1141 purple_xfer_set_bytes_sent(xfer, 0);
1127 purple_xfer_update_progress(xfer); 1142 purple_xfer_update_progress(xfer);
1128 jabber_si_xfer_ibb_send_data(sess); 1143 jabber_si_xfer_ibb_send_data(sess);
1129 } else { 1144 } else {