--- a/libpurple/tests/test_protocol_xfer.c Sun Nov 26 01:30:28 2017 -0600
+++ b/libpurple/tests/test_protocol_xfer.c Sun Nov 26 02:15:23 2017 -0600
@@ -30,13 +30,6 @@
/******************************************************************************
- *****************************************************************************/
-} TestPurpleProtocolXferFixture;
-/******************************************************************************
* PurpleProtcolXfer Implementations
*****************************************************************************/
static GType test_purple_protocol_xfer_get_type(void);
@@ -53,17 +46,24 @@
-test_purple_protocol_xfer_can_receive(PurpleProtocolXfer *xfer, PurpleConnection *c, const gchar *who) {
- TestPurpleProtocolXfer *test_xfer = (TestPurpleProtocolXfer *)xfer;
+test_purple_protocol_xfer_can_receive(PurpleProtocolXfer *prplxfer, PurpleConnection *c, const gchar *who) { + TestPurpleProtocolXfer *test_xfer = (TestPurpleProtocolXfer *)prplxfer; return test_xfer->can_send;
+test_purple_protocol_xfer_new_xfer(PurpleProtocolXfer *prplxfer, PurpleConnection *c, const gchar *who) { + PurpleAccount *a = purple_connection_get_account(c); + return purple_xfer_new(a, PURPLE_XFER_TYPE_SEND, who); test_purple_protocol_xfer_iface_init(PurpleProtocolXferInterface *iface) {
iface->can_receive = test_purple_protocol_xfer_can_receive;
- iface->new_xfer = NULL;
+ iface->new_xfer = test_purple_protocol_xfer_new_xfer; @@ -85,18 +85,10 @@
/******************************************************************************
- *****************************************************************************/
-test_purple_protocol_xfer_setup(TestPurpleProtocolXferFixture *fixture, gconstpointer data) {
-/******************************************************************************
*****************************************************************************/
-test_purple_protocol_xfer_can_receive_func(TestPurpleProtocolXferFixture *fixture, gconstpointer data) {
+test_purple_protocol_xfer_can_receive_func(void) { TestPurpleProtocolXfer *xfer = g_object_new(test_purple_protocol_xfer_get_type(), NULL);
PurpleAccount *a = purple_account_new("testing", "testing");
PurpleConnection *c = g_object_new(PURPLE_TYPE_CONNECTION, "account", a, NULL);
@@ -121,25 +113,46 @@
+test_purple_protocol_xfer_new_func(void) { + TestPurpleProtocolXfer *prplxfer = g_object_new(test_purple_protocol_xfer_get_type(), NULL); + PurpleAccount *a = purple_account_new("testing", "testing"); + PurpleConnection *c = g_object_new(PURPLE_TYPE_CONNECTION, "account", a, NULL); + PurpleXfer *xfer = NULL; + xfer = purple_protocol_xfer_new_xfer(PURPLE_PROTOCOL_XFER(prplxfer), c, "foo"); + g_assert_true(PURPLE_IS_XFER(xfer)); + g_assert_cmpstr("foo", ==, purple_xfer_get_remote_user(xfer)); /******************************************************************************
*****************************************************************************/
main(gint argc, gchar **argv) {
g_test_init(&argc, &argv, NULL);
#if GLIB_CHECK_VERSION(2, 38, 0)
g_test_set_nonfatal_assertions();
#endif /* GLIB_CHECK_VERSION(2, 38, 0) */
"/protocol-xfer/can-receive",
- TestPurpleProtocolXferFixture,
- test_purple_protocol_xfer_setup,
- test_purple_protocol_xfer_can_receive_func,
+ test_purple_protocol_xfer_can_receive_func
+ test_purple_protocol_xfer_new_func --- a/libpurple/xfer.c Sun Nov 26 01:30:28 2017 -0600
+++ b/libpurple/xfer.c Sun Nov 26 02:15:23 2017 -0600
@@ -2360,21 +2360,23 @@
g_return_val_if_fail(who != NULL, NULL);
protocol = purple_protocols_find(purple_account_get_protocol_id(account));
- g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
- if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, FACTORY_IFACE, xfer_new))
- xfer = purple_protocol_factory_iface_xfer_new(protocol, account, type,
+ if (PURPLE_IS_PROTOCOL_XFER(protocol)) { + PurpleConnection *connection = purple_account_get_connection(account); + xfer = purple_protocol_xfer_new_xfer( + PURPLE_PROTOCOL_XFER(protocol), + /* TODO: this should support the type */ xfer = g_object_new(PURPLE_TYPE_XFER,
- g_return_val_if_fail(xfer != NULL, NULL);