LIBS="$LIBS $PURPLE_LIBS"
AC_CHECK_FUNC(purple_request_screenshare_media, [AC_DEFINE(HAVE_SCREENSHARE, 1, [Have purple_request_screenshare_media()])], [])
+AC_CHECK_FUNC(serv_chat_send_file, [AC_DEFINE(HAVE_CHAT_SEND_FILE, 1, [Have serv_chat_send_file()])], [])
LIBS="$oldLIBS"
gstplugindir="$($PKG_CONFIG --variable=pluginsdir gstreamer-1.0)"
purple_xfer_cancel_local(xfer);
}
+ g_clear_object(&data->obj);
+
g_free(data->content);
g_free(data->content_type);
g_free(data->upload_id);
purple_debug_info("chime", "Starting to handle upload of file '%s'\n", xfer->local_filename);
struct purple_chime *pc = purple_connection_get_protocol_data(xfer->account->gc);
- struct chime_im *im = g_hash_table_lookup(pc->ims_by_email, xfer->who);
+ ChimeObject *obj = CHIME_OBJECT (xfer->data);
+ xfer->data = NULL;
g_return_if_fail(CHIME_IS_CONNECTION(pc->cxn));
ChimeConnectionPrivate *priv = CHIME_CONNECTION_GET_PRIVATE(pc->cxn);
purple_debug_error("chime", _("Could not read file '%s' (errno=%d, errstr=%s)\n"),
xfer->local_filename, error->code, error->message);
g_clear_error(&error);
+ g_object_unref(obj);
return;
}
AttachmentUpload *data = g_new0(AttachmentUpload, 1);
data->conn = pc->cxn;
- data->obj = im->m.obj;
+ data->obj = obj;
data->content = file_contents;
data->content_length = length;
get_mime_type(xfer->local_filename, &data->content_type);
void chime_send_file(PurpleConnection *gc, const char *who, const char *filename)
{
+ struct purple_chime *pc = purple_connection_get_protocol_data(gc);
+ struct chime_im *im = g_hash_table_lookup(pc->ims_by_email, who);
+
purple_debug_info("chime", "chime_send_file(who=%s, file=%s\n", who, filename);
+ if (!im)
+ return;
+
+ chime_send_file_object(gc, im->m.obj, who, filename);
+}
+
+void chime_send_file_object(PurpleConnection *gc, ChimeObject *obj, const char *who, const char *filename)
+{
+ purple_debug_info("chime", "chime_send_file_object(who=%s, file=%s\n", who, filename);
+
PurpleXfer *xfer;
xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
if (xfer) {
purple_xfer_set_cancel_send_fnc(xfer, chime_send_cancel);
}
+ /* This is only in xfer->data until chime_send_init() runs. */
+ xfer->data = g_object_ref(obj);
+
if (filename) {
purple_xfer_request_accepted(xfer, filename);
} else {
chime_connection_remove_room_member_async(cxn, room, me, NULL, leave_room_cb, chat);
}
+void chime_purple_chat_send_file(PurpleConnection *conn, int id, const char *filename)
+{
+ struct purple_chime *pc = purple_connection_get_protocol_data(conn);
+ struct chime_chat *chat = g_hash_table_lookup(pc->live_chats, GUINT_TO_POINTER(id));
+
+ chime_send_file_object(conn, chat->m.obj, purple_conversation_get_name(chat->conv), filename);
+}
+
GList *chime_purple_chat_menu(PurpleChat *pchat)
{
.send_file = chime_send_file,
.get_media_caps = chime_purple_get_media_caps,
.initiate_media = chime_purple_initiate_media,
- .add_buddies_with_invite = NULL, /* We *really* depend on 2.8.0, and this is
- * immediately before .get_cb_alias() */
#ifdef PRPL_HAS_GET_CB_ALIAS
.get_cb_alias = chime_purple_get_cb_alias,
#endif
+#ifdef HAVE_CHAT_SEND_FILE
+ .chat_send_file = chime_purple_chat_send_file,
+#endif
};
static void chime_purple_show_about_plugin(PurplePluginAction *action)
chime_prpl_info.protocol_options = opts;
-#ifndef PRPL_HAS_GET_CB_ALIAS
- PurplePluginProtocolInfo *i = g_malloc0(sizeof (*i) + sizeof(void *));
+#ifndef HAVE_CHAT_SEND_FILE
+ /* If built against a Pidgin that doesn't yet support chat_send_file(),
+ * or indeed get_cb_alias(), copy the struct and extend it manually. */
+ PurplePluginProtocolInfo *i = g_malloc0(sizeof (*i) + 3 * sizeof(void *));
memcpy(i, &chime_prpl_info, sizeof(*i));
chime_plugin_info.extra_info = i;
- /* Now add the .get_cb_alias method */
- i->struct_size += sizeof(void *);
- i++;
- *(void **)i = chime_purple_get_cb_alias;
+ /* ->add_buddies_with_invite() was 2.8.0; We know we have that */
+ void **p = (void **)&i->add_buddies_with_invite;
+ p++;
+ *p++ = chime_purple_get_cb_alias;
+ *p++ = NULL; /* chat_can_receive_file() but they all can */
+ *p++ = chime_purple_chat_send_file;
+
+ i->struct_size += (unsigned long)p - (unsigned long)i;
#endif
}
void chime_purple_chat_join_audio(struct chime_chat *chat);
GList *chime_purple_chat_menu(PurpleChat *chat);
char *chime_purple_get_cb_alias(PurpleConnection *conn, int id, const gchar *who);
+void chime_purple_chat_send_file(PurpleConnection *gc, int id, const char *filename);
/* conversations.c */
void on_chime_new_conversation(ChimeConnection *cxn, ChimeConversation *conv, PurpleConnection *conn);
void download_attachment(ChimeConnection *cxn, ChimeAttachment *att, AttachmentContext *ctx);
void chime_send_file(PurpleConnection *gc, const char *who, const char *filename);
+void chime_send_file_object(PurpleConnection *gc, ChimeObject *obj, const char *who, const char *filename);
#endif /* __CHIME_H__ */