summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2017-08-31 22:40:50 -0500
committerGary Kramlich <grim@reaperworld.com>2017-08-31 22:40:50 -0500
commitf1689a4802dd3087e6f74ee590ca6ad389aecdbb (patch)
treeb51d2f16a644866ed1290cac1cb655569378e2d7
parent6687ccce504d70f5e189578955a9b567baea64aa (diff)
downloadpidgin-f1689a4802dd3087e6f74ee590ca6ad389aecdbb.tar.gz
Initial attempt at removing the magic around PurpleProtocolXferInterface
-rw-r--r--finch/gntblist.c10
-rw-r--r--finch/gntconv.c11
-rw-r--r--libpurple/protocol.c57
-rw-r--r--libpurple/protocol.h49
-rw-r--r--libpurple/protocols/bonjour/bonjour.c4
-rw-r--r--libpurple/protocols/irc/irc.c4
-rw-r--r--libpurple/protocols/jabber/jabber.c4
-rw-r--r--libpurple/protocols/oscar/oscar.c4
-rw-r--r--libpurple/protocols/sametime/sametime.c4
-rw-r--r--libpurple/server.c10
-rw-r--r--libpurple/xfer.c47
-rw-r--r--libpurple/xfer.h75
-rw-r--r--pidgin/gtkblist.c10
-rw-r--r--pidgin/gtkconv.c22
-rw-r--r--pidgin/gtkutils.c13
15 files changed, 181 insertions, 143 deletions
diff --git a/finch/gntblist.c b/finch/gntblist.c
index c111240531..2898c4f6bd 100644
--- a/finch/gntblist.c
+++ b/finch/gntblist.c
@@ -1279,12 +1279,16 @@ create_buddy_menu(GntMenu *menu, PurpleBuddy *buddy)
add_custom_action(menu, _("Add Buddy Pounce"),
PURPLE_CALLBACK(finch_blist_pounce_node_cb), buddy);
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send))
+ if (PURPLE_IS_PROTOCOL_XFER(protocol))
{
- if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
- purple_protocol_xfer_iface_can_receive(protocol, gc, purple_buddy_get_name(buddy)))
+ if (purple_protocol_xfer_can_receive(
+ PURPLE_PROTOCOL_XFER(protocol),
+ gc,
+ purple_buddy_get_name(buddy))
+ ) {
add_custom_action(menu, _("Send File"),
PURPLE_CALLBACK(finch_blist_menu_send_file_cb), buddy);
+ }
}
account = purple_buddy_get_account(buddy);
diff --git a/finch/gntconv.c b/finch/gntconv.c
index 0c8aaa3a37..b4324dc657 100644
--- a/finch/gntconv.c
+++ b/finch/gntconv.c
@@ -719,10 +719,13 @@ gg_create_menu(FinchConv *ggc)
gnt_menu_add_item(GNT_MENU(sub), item);
gnt_menuitem_set_callback(item, add_pounce_cb, ggc);
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send) &&
- (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
- purple_protocol_xfer_iface_can_receive(protocol, gc,
- purple_conversation_get_name(ggc->active_conv)))) {
+ if (PURPLE_IS_PROTOCOL_XFER(protocol) &&
+ purple_protocol_xfer_can_receive(
+ PURPLE_PROTOCOL_XFER(protocol),
+ gc,
+ purple_conversation_get_name(ggc->active_conv)
+ )
+ ) {
item = gnt_menuitem_new(_("Send File"));
gnt_menu_add_item(GNT_MENU(sub), item);
gnt_menuitem_set_callback(item, send_file_cb, ggc);
diff --git a/libpurple/protocol.c b/libpurple/protocol.c
index c8cf1db341..73d61fd98a 100644
--- a/libpurple/protocol.c
+++ b/libpurple/protocol.c
@@ -800,63 +800,6 @@ purple_protocol_privacy_iface_set_permit_deny(PurpleProtocol *protocol,
#undef DEFINE_PROTOCOL_FUNC
/**************************************************************************
- * Protocol Xfer Interface API
- **************************************************************************/
-#define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
- PurpleProtocolXferIface *xfer_iface = \
- PURPLE_PROTOCOL_GET_XFER_IFACE(protocol); \
- if (xfer_iface && xfer_iface->funcname) \
- xfer_iface->funcname(__VA_ARGS__);
-
-#define DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol,defaultreturn,funcname,...) \
- PurpleProtocolXferIface *xfer_iface = \
- PURPLE_PROTOCOL_GET_XFER_IFACE(protocol); \
- if (xfer_iface && xfer_iface->funcname) \
- return xfer_iface->funcname(__VA_ARGS__); \
- else \
- return defaultreturn;
-
-GType
-purple_protocol_xfer_iface_get_type(void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY(type == 0)) {
- static const GTypeInfo info = {
- .class_size = sizeof(PurpleProtocolXferIface),
- };
-
- type = g_type_register_static(G_TYPE_INTERFACE,
- "PurpleProtocolXferIface", &info, 0);
- }
- return type;
-}
-
-gboolean
-purple_protocol_xfer_iface_can_receive(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *who)
-{
- DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, FALSE, can_receive, gc, who);
-}
-
-void
-purple_protocol_xfer_iface_send(PurpleProtocol *protocol, PurpleConnection *gc,
- const char *who, const char *filename)
-{
- DEFINE_PROTOCOL_FUNC(protocol, send, gc, who, filename);
-}
-
-PurpleXfer *
-purple_protocol_xfer_iface_new_xfer(PurpleProtocol *protocol,
- PurpleConnection *gc, const char *who)
-{
- DEFINE_PROTOCOL_FUNC_WITH_RETURN(protocol, NULL, new_xfer, gc, who);
-}
-
-#undef DEFINE_PROTOCOL_FUNC_WITH_RETURN
-#undef DEFINE_PROTOCOL_FUNC
-
-/**************************************************************************
* Protocol Roomlist Interface API
**************************************************************************/
#define DEFINE_PROTOCOL_FUNC(protocol,funcname,...) \
diff --git a/libpurple/protocol.h b/libpurple/protocol.h
index 6cea9faf93..40e48a228c 100644
--- a/libpurple/protocol.h
+++ b/libpurple/protocol.h
@@ -556,35 +556,6 @@ struct _PurpleProtocolPrivacyIface
#define PURPLE_PROTOCOL_GET_PRIVACY_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE, \
PurpleProtocolPrivacyIface))
-#define PURPLE_TYPE_PROTOCOL_XFER_IFACE (purple_protocol_xfer_iface_get_type())
-
-typedef struct _PurpleProtocolXferIface PurpleProtocolXferIface;
-
-/**
- * PurpleProtocolXferIface:
- *
- * The protocol file transfer interface.
- *
- * This interface provides file transfer callbacks for the protocol.
- */
-struct _PurpleProtocolXferIface
-{
- /*< private >*/
- GTypeInterface parent_iface;
-
- /*< public >*/
- gboolean (*can_receive)(PurpleConnection *, const char *who);
-
- void (*send)(PurpleConnection *, const char *who,
- const char *filename);
-
- PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
-};
-
-#define PURPLE_PROTOCOL_HAS_XFER_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_XFER_IFACE))
-#define PURPLE_PROTOCOL_GET_XFER_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_XFER_IFACE, \
- PurpleProtocolXferIface))
-
#define PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE (purple_protocol_roomlist_iface_get_type())
typedef struct _PurpleProtocolRoomlistIface PurpleProtocolRoomlistIface;
@@ -1084,26 +1055,6 @@ void purple_protocol_privacy_iface_set_permit_deny(PurpleProtocol *,
PurpleConnection *);
/**************************************************************************/
-/* Protocol Xfer Interface API */
-/**************************************************************************/
-
-/**
- * purple_protocol_xfer_iface_get_type:
- *
- * Returns: The #GType for the protocol xfer interface.
- */
-GType purple_protocol_xfer_iface_get_type(void);
-
-gboolean purple_protocol_xfer_iface_can_receive(PurpleProtocol *,
- PurpleConnection *, const char *who);
-
-void purple_protocol_xfer_iface_send(PurpleProtocol *, PurpleConnection *,
- const char *who, const char *filename);
-
-PurpleXfer *purple_protocol_xfer_iface_new_xfer(PurpleProtocol *,
- PurpleConnection *, const char *who);
-
-/**************************************************************************/
/* Protocol Roomlist Interface API */
/**************************************************************************/
diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
index 8b75345a93..d2237d1a91 100644
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -699,7 +699,7 @@ bonjour_protocol_im_iface_init(PurpleProtocolIMIface *im_iface)
}
static void
-bonjour_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+bonjour_protocol_xfer_iface_init(PurpleProtocolXferInterface *xfer_iface)
{
xfer_iface->can_receive = bonjour_can_receive_file;
xfer_iface->send = bonjour_send_file;
@@ -718,7 +718,7 @@ PURPLE_DEFINE_TYPE_EXTENDED(
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE,
bonjour_protocol_im_iface_init)
- PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER,
bonjour_protocol_xfer_iface_init)
);
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
index 261874bca7..f5dea517b8 100644
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -916,7 +916,7 @@ irc_protocol_roomlist_iface_init(PurpleProtocolRoomlistIface *roomlist_iface)
}
static void
-irc_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+irc_protocol_xfer_iface_init(PurpleProtocolXferInterface *xfer_iface)
{
xfer_iface->send = irc_dccsend_send_file;
xfer_iface->new_xfer = irc_dccsend_new_xfer;
@@ -940,7 +940,7 @@ PURPLE_DEFINE_TYPE_EXTENDED(
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE,
irc_protocol_roomlist_iface_init)
- PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER,
irc_protocol_xfer_iface_init)
);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
index d042378f39..7ab563078f 100644
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -4263,7 +4263,7 @@ jabber_protocol_media_iface_init(PurpleProtocolMediaIface *media_iface)
}
static void
-jabber_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+jabber_protocol_xfer_iface_init(PurpleProtocolXferInterface *xfer_iface)
{
xfer_iface->can_receive = jabber_can_receive_file;
xfer_iface->send = jabber_si_xfer_send;
@@ -4297,7 +4297,7 @@ PURPLE_DEFINE_TYPE_EXTENDED(
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_MEDIA_IFACE,
jabber_protocol_media_iface_init)
- PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER,
jabber_protocol_xfer_iface_init)
);
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
index 1abe2bb3ee..3c9f705c8f 100644
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -5760,7 +5760,7 @@ oscar_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
}
static void
-oscar_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+oscar_protocol_xfer_iface_init(PurpleProtocolXferInterface *xfer_iface)
{
xfer_iface->can_receive = oscar_can_receive_file;
xfer_iface->send = oscar_send_file;
@@ -5785,7 +5785,7 @@ PURPLE_DEFINE_TYPE_EXTENDED(
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE,
oscar_protocol_privacy_iface_init)
- PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER,
oscar_protocol_xfer_iface_init)
);
diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
index 6dddb06dd5..4b1edd676c 100644
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -5701,7 +5701,7 @@ mw_protocol_privacy_iface_init(PurpleProtocolPrivacyIface *privacy_iface)
static void
-mw_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface)
+mw_protocol_xfer_iface_init(PurpleProtocolXferInterface *xfer_iface)
{
xfer_iface->can_receive = mw_protocol_can_receive_file;
xfer_iface->send = mw_protocol_send_file;
@@ -5727,7 +5727,7 @@ PURPLE_DEFINE_TYPE_EXTENDED(
PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_PRIVACY_IFACE,
mw_protocol_privacy_iface_init)
- PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER,
mw_protocol_xfer_iface_init)
);
diff --git a/libpurple/server.c b/libpurple/server.c
index 13be8259fa..66a29991fe 100644
--- a/libpurple/server.c
+++ b/libpurple/server.c
@@ -894,9 +894,11 @@ void purple_serv_send_file(PurpleConnection *gc, const char *who, const char *fi
if (gc) {
protocol = purple_connection_get_protocol(gc);
- if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
- purple_protocol_xfer_iface_can_receive(protocol, gc, who))
-
- purple_protocol_xfer_iface_send(protocol, gc, who, file);
+ if(PURPLE_IS_PROTOCOL_XFER(protocol)) {
+ PurpleProtocolXferInterface *iface = PURPLE_PROTOCOL_XFER_GET_IFACE(protocol);
+ if(purple_protocol_xfer_can_receive(iface, gc, who)) {
+ purple_protocol_xfer_send(iface, gc, who, file);
+ }
+ }
}
}
diff --git a/libpurple/xfer.c b/libpurple/xfer.c
index 3df9640781..ee31c41249 100644
--- a/libpurple/xfer.c
+++ b/libpurple/xfer.c
@@ -2477,3 +2477,50 @@ purple_xfer_ui_ops_get_type(void)
return type;
}
+
+/**************************************************************************
+ * PurpleXferProtocolInterface
+ **************************************************************************/
+G_DEFINE_INTERFACE(PurpleProtocolXfer, purple_protocol_xfer, G_TYPE_INVALID);
+
+static void
+purple_protocol_xfer_default_init(PurpleProtocolXferInterface *face) {
+}
+
+gboolean
+purple_protocol_xfer_can_receive(PurpleProtocolXferInterface *iface,
+ PurpleConnection *connection,
+ const gchar *who
+) {
+ g_return_val_if_fail(PURPLE_IS_PROTOCOL_XFER(iface), FALSE);
+ g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
+ g_return_val_if_fail(who, FALSE);
+
+ return iface->can_receive(connection, who);
+}
+
+void
+purple_protocol_xfer_send(PurpleProtocolXferInterface *iface,
+ PurpleConnection *connection,
+ const gchar *who,
+ const gchar *filename
+) {
+ g_return_if_fail(PURPLE_IS_PROTOCOL_XFER(iface));
+ g_return_if_fail(PURPLE_IS_CONNECTION(connection));
+ g_return_if_fail(who);
+ g_return_if_fail(filename);
+
+ iface->send(connection, who, filename);
+}
+
+PurpleXfer *
+purple_protocol_xfer_new_xfer(PurpleProtocolXferInterface *iface,
+ PurpleConnection *connection,
+ const gchar *who
+) {
+ g_return_val_if_fail(PURPLE_IS_PROTOCOL_XFER(iface), FALSE);
+ g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
+ g_return_val_if_fail(who, FALSE);
+
+ return iface->new_xfer(connection, who);
+}
diff --git a/libpurple/xfer.h b/libpurple/xfer.h
index 99a0ad999d..04ca70b29a 100644
--- a/libpurple/xfer.h
+++ b/libpurple/xfer.h
@@ -38,6 +38,11 @@
#define PURPLE_TYPE_XFER_UI_OPS (purple_xfer_ui_ops_get_type())
+#define PURPLE_TYPE_PROTOCOL_XFER (purple_protocol_xfer_get_type())
+#define PURPLE_PROTOCOL_XFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PROTOCOL_XFER, PurpleProtocolXferInterface))
+#define PURPLE_IS_PROTOCOL_XFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL_XFER))
+#define PURPLE_PROTOCOL_XFER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL_XFER, PurpleProtocolXferInterface))
+
/**************************************************************************/
/** Data Structures */
/**************************************************************************/
@@ -46,10 +51,13 @@ typedef struct _PurpleXferClass PurpleXferClass;
typedef struct _PurpleXferUiOps PurpleXferUiOps;
+typedef struct _PurpleProtocolXferInterface PurpleProtocolXferInterface;
+
#include <glib.h>
#include <stdio.h>
#include "account.h"
+#include "connection.h"
/**
* PurpleXferType:
@@ -182,6 +190,27 @@ struct _PurpleXferClass
void (*_purple_reserved4)(void);
};
+/**
+ * PurpleProtocolXferIface:
+ *
+ * The protocol file transfer interface.
+ *
+ * This interface provides file transfer callbacks for the protocol.
+ */
+struct _PurpleProtocolXferInterface
+{
+ /*< private >*/
+ GTypeInterface parent_iface;
+
+ /*< public >*/
+ gboolean (*can_receive)(PurpleConnection *, const char *who);
+
+ void (*send)(PurpleConnection *, const char *who,
+ const char *filename);
+
+ PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
+};
+
G_BEGIN_DECLS
/**************************************************************************/
@@ -946,6 +975,52 @@ void purple_xfers_set_ui_ops(PurpleXferUiOps *ops);
*/
PurpleXferUiOps *purple_xfers_get_ui_ops(void);
+/******************************************************************************
+ * Protocol Interface
+ *****************************************************************************/
+
+/**
+ * purple_protocol_xfer_get_type:
+ *
+ * Returns: The #GType for the protocol xfer interface.
+ */
+GType purple_protocol_xfer_get_type(void);
+
+/**
+ * purple_protocol_xfer_can_receive:
+ * @iface: The #PurpleProtocolXferIface instance
+ * @connection: The #PurpleConnection that we're checking
+ * @who: The user that we want to set a file transfer to.
+ *
+ * Checks whether or not we can transfer a file to @who.
+ *
+ * Returns: TRUE on success, FALSE otherwise.
+ */
+gboolean purple_protocol_xfer_can_receive(PurpleProtocolXferInterface *iface, PurpleConnection *connection, const gchar *who);
+
+/**
+ * purple_protocol_xfer_send:
+ * @iface: The #PurpleProtocolXferInterface instance
+ * @connection: The #PurpleConnection that we're checking
+ * @who: The user that we want to set a file transfer to.
+ * @filename: The name of the file to send.
+ *
+ * Sends @filename to @who.
+ */
+void purple_protocol_xfer_send(PurpleProtocolXferInterface *iface, PurpleConnection *connection, const gchar *who, const gchar *filename);
+
+/**
+ * purple_protocol_xfer_send:
+ * @iface: The #PurpleProtocolXferInterface instance
+ * @connection: The #PurpleConnection that we're checking
+ * @who: The user that we want to set a file transfer to.
+ *
+ * Creates a new #PurpleXfer to @who.
+ *
+ * Returns: A new #PurpleXfer instance.
+ */
+PurpleXfer *purple_protocol_xfer_new_xfer(PurpleProtocolXferInterface *iface, PurpleConnection *connection, const gchar *who);
+
G_END_DECLS
#endif /* _PURPLE_XFER_H_ */
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 6563ca89f8..5fd4fa8a10 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -1523,11 +1523,11 @@ pidgin_blist_make_buddy_menu(GtkWidget *menu, PurpleBuddy *buddy, gboolean sub)
#endif
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send)) {
- if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
- purple_protocol_xfer_iface_can_receive(protocol,
- purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy)))
- {
+ if (protocol && PURPLE_IS_PROTOCOL_XFER(protocol)) {
+ if (purple_protocol_xfer_can_receive(
+ PURPLE_PROTOCOL_XFER(protocol),
+ purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy)
+ )) {
pidgin_new_menu_item(menu, _("_Send File..."),
PIDGIN_STOCK_TOOLBAR_SEND_FILE,
G_CALLBACK(gtk_blist_menu_send_file_cb),
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
index 4e3512517e..a23ebb9da3 100644
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -1679,7 +1679,7 @@ create_chat_menu(PurpleChatConversation *chat, const char *who, PurpleConnection
g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send))
+ if (protocol && PURPLE_IS_PROTOCOL_XFER(protocol))
{
gboolean can_receive_file = TRUE;
@@ -1693,9 +1693,11 @@ create_chat_menu(PurpleChatConversation *chat, const char *who, PurpleConnection
gchar *real_who = NULL;
real_who = purple_protocol_chat_iface_get_user_real_name(protocol, gc,
purple_chat_conversation_get_id(chat), who);
- if (!(!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
- purple_protocol_xfer_iface_can_receive(protocol, gc, real_who ? real_who : who)))
+
+ if (!purple_protocol_xfer_can_receive(protocol, gc, real_who ? real_who : who)) {
can_receive_file = FALSE;
+ }
+
g_free(real_who);
}
@@ -7424,12 +7426,18 @@ gray_stuff_out(PidginConversation *gtkconv)
if (PURPLE_IS_IM_CONVERSATION(conv))
{
+ gboolean can_send_file = FALSE;
+ const gchar *name = purple_conversation_get_name(conv);
+
+ if (PURPLE_IS_PROTOCOL_XFER(protocol) &&
+ purple_protocol_xfer_can_receive(PURPLE_PROTOCOL_XFER(protocol), gc, name)
+ ) {
+ can_send_file = TRUE;
+ }
+
gtk_action_set_sensitive(win->menu->add, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, add_buddy)));
gtk_action_set_sensitive(win->menu->remove, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER_IFACE, remove_buddy)));
- gtk_action_set_sensitive(win->menu->send_file,
- (PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send) &&
- (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive) ||
- purple_protocol_xfer_iface_can_receive(protocol, gc, purple_conversation_get_name(conv)))));
+ gtk_action_set_sensitive(win->menu->send_file, can_send_file);
gtk_action_set_sensitive(win->menu->get_attention, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, ATTENTION_IFACE, send)));
gtk_action_set_sensitive(win->menu->alias,
(account != NULL) &&
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
index d998ff9a5c..b93a54e6ba 100644
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -1439,10 +1439,15 @@ pidgin_dnd_file_send_image(PurpleAccount *account, const gchar *who,
if (!(purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_NO_IMAGES))
im = TRUE;
- if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, can_receive))
- ft = purple_protocol_xfer_iface_can_receive(protocol, gc, who);
- else if (protocol && PURPLE_PROTOCOL_IMPLEMENTS(protocol, XFER_IFACE, send))
- ft = TRUE;
+ if (protocol && PURPLE_IS_PROTOCOL_XFER(protocol)) {
+ PurpleProtocolXferInterface *iface = PURPLE_PROTOCOL_XFER(protocol);
+
+ if(iface->can_receive) {
+ ft = purple_protocol_xfer_can_receive(protocol, gc, who);
+ } else {
+ ft = (iface->send) ? TRUE : FALSE;
+ }
+ }
if (im && ft) {
purple_request_choice(NULL, NULL,