diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 4f652de..4fc97f4 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_req_first, sizeof(put_req_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_put_req(obex, provide_data, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_rsp_first, sizeof(put_rsp_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_rsp_first, sizeof(put_rsp_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq,
&d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_req_first, sizeof(put_req_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
d.id = g_obex_put_req(obex, abort_data, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_rsp_first, sizeof(put_rsp_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_rsp_first_srm_wait, sizeof(put_rsp_first_srm_wait) },
create_endpoints(&obex, &io, SOCK_SEQPACKET);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_PUT,
handle_put_seq_wait, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_rsp_first_srm, sizeof(put_rsp_first_srm) },
create_endpoints(&obex, &io, SOCK_SEQPACKET);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first, sizeof(get_req_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_data, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first, sizeof(get_req_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first_srm, sizeof(get_req_first_srm) },
create_endpoints(&obex, &io, SOCK_SEQPACKET);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first_srm_wait, sizeof(get_req_first_srm_wait) },
create_endpoints(&obex, &io, SOCK_SEQPACKET);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first_srm, sizeof(get_req_first_srm) },
d.provide_delay = 1;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_seq_delay, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first_srm, sizeof(get_req_first_srm) },
create_endpoints(&obex, &io, SOCK_SEQPACKET);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first_app, sizeof(get_req_first_app) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_data, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ NULL, 0 },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ NULL, 0 },
d.provide_delay = 1;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_unref(d.mainloop);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ NULL, 0 },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ NULL, 0 },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_req_first, sizeof(put_req_first) },
d.provide_delay = 200;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_put_req(obex, provide_eagain, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_rsp_first, sizeof(get_rsp_first) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ NULL, 0 },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ NULL, 0 },
create_endpoints(&obex, &io, SOCK_SEQPACKET);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ NULL, 0 },
create_endpoints(&obex, &io, SOCK_SEQPACKET);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_GET,
handle_get_seq_srm_wait, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_rsp_first_app, sizeof(get_rsp_first_app) },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_app, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_req_first, sizeof(put_req_first) },
d.provide_delay = 200;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_put_req(obex, provide_data, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_rsp_first, sizeof(get_rsp_first) },
d.provide_delay = 200;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ put_rsp_first, sizeof(put_rsp_first) },
d.provide_delay = 200;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_delay, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_req_first, sizeof(get_req_first) },
d.provide_delay = 200;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_get_req(obex, rcv_data_delay, transfer_complete, &d, &d.err,
G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ get_rsp_first, sizeof(get_rsp_first) },
d.provide_delay = 200;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_eagain,
&d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_req, sizeof(conn_req) } }, {
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, conn_complete, &d, &d.err, G_OBEX_HDR_INVALID);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_rsp, sizeof(conn_rsp) } }, {
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
handle_conn_rsp, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- if (!d.io_completed)
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_req, sizeof(conn_req) },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, conn_complete_get_req, &d, &d.err,
G_OBEX_HDR_INVALID);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_rsp, sizeof(conn_rsp) },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
handle_conn_rsp, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_req, sizeof(conn_req) },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, conn_complete_put_req, &d, &d.err,
G_OBEX_HDR_INVALID);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_rsp, sizeof(conn_rsp) },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
handle_conn_rsp, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_rsp, sizeof(conn_rsp) },
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
handle_conn_rsp, &d);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- if (!d.io_completed)
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_req, sizeof(conn_req) } ,
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, conn_complete_put_req_seq, &d, &d.err,
G_OBEX_HDR_INVALID);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ conn_req_srm, sizeof(conn_req_srm) } ,
d.obex = obex;
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, conn_complete_put_req_seq_srm, &d, &d.err,
G_OBEX_HDR_SRM, G_OBEX_SRM_INDICATE,
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
diff --git a/unit/test-gobex.c b/unit/test-gobex.c
index 6fbfa18..122bf42 100644
--- a/unit/test-gobex.c
+++ b/unit/test-gobex.c
static gboolean timeout(gpointer user_data)
{
- GError **err = user_data;
+ struct test_data *d = user_data;
if (!g_main_loop_is_running(mainloop))
return FALSE;
- g_set_error(err, TEST_ERROR, TEST_ERROR_TIMEOUT, "Timed out");
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_TIMEOUT, "Timed out");
+ d->timer_id = 0;
g_main_loop_quit(mainloop);
static gboolean send_connect_rsp(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
- GError **err = user_data;
+ struct test_data *d = user_data;
- if (!recv_and_send(io, pkt_connect_rsp, sizeof(pkt_connect_rsp), err))
+ if (!recv_and_send(io, pkt_connect_rsp, sizeof(pkt_connect_rsp),
+ &d->err))
g_main_loop_quit(mainloop);
+ d->io_id = 0;
return FALSE;
}
static gboolean send_nval_connect_rsp(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
- GError **err = user_data;
+ struct test_data *d = user_data;
if (!recv_and_send(io, pkt_nval_connect_rsp,
- sizeof(pkt_nval_connect_rsp), err))
+ sizeof(pkt_nval_connect_rsp), &d->err))
g_main_loop_quit(mainloop);
+ d->io_id = 0;
return FALSE;
}
static gboolean send_nval_short_rsp(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
- GError **err = user_data;
+ struct test_data *d = user_data;
if (!recv_and_send(io, pkt_nval_short_rsp,
- sizeof(pkt_nval_short_rsp), err))
+ sizeof(pkt_nval_short_rsp), &d->err))
g_main_loop_quit(mainloop);
+ d->io_id = 0;
return FALSE;
}
static gboolean send_nothing(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
- GError **err = user_data;
+ struct test_data *d = user_data;
- if (!recv_and_send(io, NULL, 0, err))
+ if (!recv_and_send(io, NULL, 0, &d->err))
g_main_loop_quit(mainloop);
+ d->io_id = 0;
return FALSE;
}
GIOFunc send_rsp_func, int req_timeout,
int transport_type)
{
- GError *gerr = NULL;
+ struct test_data d;
GIOChannel *io;
GIOCondition cond;
- guint timer_id, test_time;
+ int test_time;
GObex *obex;
create_endpoints(&obex, &io, transport_type);
- g_obex_send_req(obex, req, req_timeout, rsp_func, &gerr, &gerr);
- g_assert_no_error(gerr);
+ d.err = NULL;
+ g_obex_send_req(obex, req, req_timeout, rsp_func, &d.err, &d.err);
+ g_assert_no_error(d.err);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- g_io_add_watch(io, cond, send_rsp_func, &gerr);
+ d.io_id = g_io_add_watch(io, cond, send_rsp_func, &d);
mainloop = g_main_loop_new(NULL, FALSE);
else
test_time = 1;
- timer_id = g_timeout_add_seconds(test_time, timeout, &gerr);
+ d.timer_id = g_timeout_add_seconds(test_time, timeout, &d);
g_main_loop_run(mainloop);
g_main_loop_unref(mainloop);
mainloop = NULL;
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
g_obex_unref(obex);
- g_assert_no_error(gerr);
+ g_assert_no_error(d.err);
}
static void send_connect(GObexResponseFunc rsp_func, GIOFunc send_rsp_func,
send_connect(timeout_rsp, send_nothing, 0, SOCK_SEQPACKET);
}
-struct req_info {
- GObex *obex;
- guint id;
- GError *err;
-};
-
static void req_done(GObex *obex, GError *err, GObexPacket *rsp,
gpointer user_data)
{
- struct req_info *r = user_data;
+ struct test_data *d = user_data;
if (!g_error_matches(err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED))
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Did not get expected cancelled error");
g_main_loop_quit(mainloop);
static void test_cancel_req_immediate(void)
{
GObexPacket *req;
- struct req_info r;
+ struct test_data d;
gboolean ret;
- create_endpoints(&r.obex, NULL, SOCK_STREAM);
+ create_endpoints(&d.obex, NULL, SOCK_STREAM);
- r.err = NULL;
+ d.err = NULL;
req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
- r.id = g_obex_send_req(r.obex, req, -1, req_done, &r, &r.err);
- g_assert_no_error(r.err);
- g_assert(r.id != 0);
+ d.id = g_obex_send_req(d.obex, req, -1, req_done, &d, &d.err);
+ g_assert_no_error(d.err);
+ g_assert(d.id != 0);
- ret = g_obex_cancel_req(r.obex, r.id, FALSE);
+ ret = g_obex_cancel_req(d.obex, d.id, FALSE);
g_assert(ret == TRUE);
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
- g_assert_no_error(r.err);
+ g_assert_no_error(d.err);
- g_obex_unref(r.obex);
+ g_obex_unref(d.obex);
g_main_loop_unref(mainloop);
}
static gboolean cancel_server(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
- struct req_info *r = user_data;
+ struct test_data *d = user_data;
GIOStatus status;
gsize bytes_written, rbytes;
char buf[255];
status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL);
if (status != G_IO_STATUS_NORMAL) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Reading data failed with status %d", status);
goto failed;
}
if (rbytes < 3) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Not enough data from socket");
goto failed;
}
if ((uint8_t) buf[0] == (G_OBEX_OP_PUT | FINAL_BIT)) {
- if (!g_obex_cancel_req(r->obex, r->id, FALSE)) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ if (!g_obex_cancel_req(d->obex, d->id, FALSE)) {
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Cancelling request failed");
goto failed;
}
}
if ((uint8_t) buf[0] != (G_OBEX_OP_ABORT | FINAL_BIT)) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Neither Put nor Abort packet received");
goto failed;
}
g_io_channel_write_chars(io, (char *) pkt_abort_rsp,
sizeof(pkt_abort_rsp), &bytes_written, NULL);
if (bytes_written != sizeof(pkt_abort_rsp)) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Unable to write to socket");
goto failed;
}
return TRUE;
failed:
+ d->io_id = 0;
g_main_loop_quit(mainloop);
return FALSE;
}
static void test_cancel_req_delay(int transport_type)
{
GIOChannel *io;
- guint io_id, timer_id;
- struct req_info r;
+ struct test_data d;
GObexPacket *req;
GIOCondition cond;
- create_endpoints(&r.obex, &io, transport_type);
+ create_endpoints(&d.obex, &io, transport_type);
- r.err = NULL;
+ d.err = NULL;
req = g_obex_packet_new(G_OBEX_OP_PUT, TRUE, G_OBEX_HDR_INVALID);
- r.id = g_obex_send_req(r.obex, req, -1, req_done, &r, &r.err);
- g_assert_no_error(r.err);
- g_assert(r.id != 0);
+ d.id = g_obex_send_req(d.obex, req, -1, req_done, &d, &d.err);
+ g_assert_no_error(d.err);
+ g_assert(d.id != 0);
mainloop = g_main_loop_new(NULL, FALSE);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, cancel_server, &r);
+ d.io_id = g_io_add_watch(io, cond, cancel_server, &d);
- timer_id = g_timeout_add_seconds(2, timeout, &r.err);
+ d.timer_id = g_timeout_add_seconds(2, timeout, &d);
g_main_loop_run(mainloop);
- g_assert_no_error(r.err);
+ g_assert_no_error(d.err);
+
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
- g_source_remove(timer_id);
g_io_channel_unref(io);
- g_source_remove(io_id);
- g_obex_unref(r.obex);
+ g_obex_unref(d.obex);
g_main_loop_unref(mainloop);
}
test_cancel_req_delay(SOCK_SEQPACKET);
}
-struct rcv_buf_info {
- GError *err;
- const guint8 *buf;
- gsize len;
- gboolean completed;
-};
-
static gboolean rcv_data(GIOChannel *io, GIOCondition cond, gpointer user_data)
{
- struct rcv_buf_info *r = user_data;
+ struct test_data *d = user_data;
+ struct test_buf *b = d->recv;
GIOStatus status;
gsize rbytes;
char buf[255];
if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Unexpected condition %d on socket", cond);
goto done;
}
status = g_io_channel_read_chars(io, buf, sizeof(buf), &rbytes, NULL);
if (status != G_IO_STATUS_NORMAL) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Reading data failed with status %d", status);
goto done;
}
- if (rbytes != r->len) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ if ((gssize) rbytes != b->len) {
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Got %zu bytes instead of %zu",
rbytes, sizeof(pkt_connect_req));
- dump_bufs(r->buf, r->len, buf, rbytes);
+ dump_bufs(b->data, b->len, buf, rbytes);
goto done;
}
- if (memcmp(buf, r->buf, rbytes) != 0) {
- g_set_error(&r->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
+ if (memcmp(buf, b->data, rbytes) != 0) {
+ g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
"Mismatch with received data");
- dump_bufs(r->buf, r->len, buf, rbytes);
+ dump_bufs(b->data, b->len, buf, rbytes);
goto done;
}
done:
+ d->io_id = 0;
g_main_loop_quit(mainloop);
- r->completed = TRUE;
return FALSE;
}
static void test_send_connect(int transport_type)
{
guint8 connect_data[] = { 0x10, 0x00, 0x10, 0x00 };
- struct rcv_buf_info r;
+ struct test_data d;
+ struct test_buf *b = d.recv;
GIOChannel *io;
GIOCondition cond;
GObexPacket *req;
- guint io_id, timer_id;
GObex *obex;
create_endpoints(&obex, &io, transport_type);
- memset(&r, 0, sizeof(r));
- r.buf = pkt_connect_req;
- r.len = sizeof(pkt_connect_req);
+ memset(&d, 0, sizeof(d));
+ b->data = pkt_connect_req;
+ b->len = sizeof(pkt_connect_req);
req = g_obex_packet_new(G_OBEX_OP_CONNECT, TRUE, G_OBEX_HDR_INVALID);
g_assert(req != NULL);
g_obex_packet_set_data(req, connect_data, sizeof(connect_data),
G_OBEX_DATA_REF);
- g_obex_send(obex, req, &r.err);
- g_assert_no_error(r.err);
+ g_obex_send(obex, req, &d.err);
+ g_assert_no_error(d.err);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, rcv_data, &r);
+ d.io_id = g_io_add_watch(io, cond, rcv_data, &d);
mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, timeout, &r.err);
+ d.timer_id = g_timeout_add_seconds(1, timeout, &d);
g_main_loop_run(mainloop);
g_main_loop_unref(mainloop);
mainloop = NULL;
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- if (!r.completed)
- g_source_remove(io_id);
g_obex_unref(obex);
- g_assert_no_error(r.err);
+ g_assert_no_error(d.err);
}
static void test_send_connect_stream(void)
static void test_recv_unexpected(void)
{
- GError *err = NULL;
+ struct test_data d;
GObexPacket *req;
GIOChannel *io;
- guint timer_id;
GObex *obex;
guint8 buf[255];
gssize len;
create_endpoints(&obex, &io, SOCK_STREAM);
- g_obex_set_disconnect_function(obex, unexpected_disconn, &err);
+ d.err = NULL;
+ g_obex_set_disconnect_function(obex, unexpected_disconn, &d.err);
req = g_obex_packet_new(G_OBEX_RSP_CONTINUE, TRUE, G_OBEX_HDR_INVALID);
len = g_obex_packet_encode(req, buf, sizeof(buf));
g_obex_packet_free(req);
g_assert_cmpint(len, >=, 0);
- g_io_channel_write_chars(io, (char *) buf, len, NULL, &err);
- g_assert_no_error(err);
+ g_io_channel_write_chars(io, (char *) buf, len, NULL, &d.err);
+ g_assert_no_error(d.err);
mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, timeout, &err);
+ d.timer_id = g_timeout_add_seconds(1, timeout, &d);
g_main_loop_run(mainloop);
g_main_loop_unref(mainloop);
mainloop = NULL;
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+
g_io_channel_unref(io);
g_obex_unref(obex);
- g_assert_no_error(err);
+ g_assert_no_error(d.err);
}
static gssize get_body_data(void *buf, gsize len, gpointer user_data)
static void test_send_on_demand(int transport_type, GObexDataProducer func)
{
- struct rcv_buf_info r;
+ struct test_data d;
+ struct test_buf *b = d.recv;
GIOChannel *io;
GIOCondition cond;
GObexPacket *req;
- guint io_id, timer_id;
GObex *obex;
create_endpoints(&obex, &io, transport_type);
- memset(&r, 0, sizeof(r));
- r.buf = pkt_put_body;
- r.len = sizeof(pkt_put_body);
+ memset(&d, 0, sizeof(d));
+ b->data = pkt_put_body;
+ b->len = sizeof(pkt_put_body);
req = g_obex_packet_new(G_OBEX_OP_PUT, FALSE, G_OBEX_HDR_INVALID);
- g_obex_packet_add_body(req, func, &r);
+ g_obex_packet_add_body(req, func, &d);
- g_obex_send(obex, req, &r.err);
- g_assert_no_error(r.err);
+ g_obex_send(obex, req, &d.err);
+ g_assert_no_error(d.err);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, rcv_data, &r);
+ d.io_id = g_io_add_watch(io, cond, rcv_data, &d);
mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, timeout, &r.err);
+ d.timer_id = g_timeout_add_seconds(1, timeout, &d);
g_main_loop_run(mainloop);
g_main_loop_unref(mainloop);
mainloop = NULL;
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- if (!r.completed)
- g_source_remove(io_id);
g_obex_unref(obex);
- g_assert_no_error(r.err);
+ g_assert_no_error(d.err);
}
static void test_send_on_demand_stream(void)
static void recv_connect(int transport_type)
{
- GError *gerr = NULL;
- guint timer_id;
+ struct test_data d;
GObex *obex;
GIOChannel *io;
GIOStatus status;
create_endpoints(&obex, &io, transport_type);
+ d.err = NULL;
g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
- handle_connect_req, &gerr);
- g_obex_set_disconnect_function(obex, handle_connect_err, &gerr);
+ handle_connect_req, &d.err);
+ g_obex_set_disconnect_function(obex, handle_connect_err, &d.err);
status = g_io_channel_write_chars(io, (char *) pkt_connect_req,
sizeof(pkt_connect_req),
mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, timeout, &gerr);
+ d.timer_id = g_timeout_add_seconds(1, timeout, &d);
g_main_loop_run(mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+
g_obex_unref(obex);
g_io_channel_unref(io);
g_main_loop_unref(mainloop);
mainloop = NULL;
- g_assert_no_error(gerr);
+ g_assert_no_error(d.err);
}
static void test_recv_connect_stream(void)
static void test_disconnect(void)
{
- GError *gerr = NULL;
- guint timer_id;
+ struct test_data d;
GObex *obex;
GIOChannel *io;
create_endpoints(&obex, &io, SOCK_STREAM);
- g_obex_set_disconnect_function(obex, disconn_ev, &gerr);
+ d.err = NULL;
+ g_obex_set_disconnect_function(obex, disconn_ev, &d.err);
- timer_id = g_timeout_add_seconds(1, timeout, &gerr);
+ d.timer_id = g_timeout_add_seconds(1, timeout, &d);
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
- g_assert_no_error(gerr);
+ g_assert_no_error(d.err);
+
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
- g_source_remove(timer_id);
g_io_channel_unref(io);
g_obex_unref(obex);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_connect_req, sizeof(pkt_connect_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, req_complete, &d, &d.err, G_OBEX_HDR_INVALID);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_disconnect_req, sizeof(pkt_disconnect_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_disconnect(obex, req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_connect_req, sizeof(pkt_connect_req) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, req_complete, &d, &d.err, G_OBEX_HDR_INVALID);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_connect_req, sizeof(pkt_connect_req) },
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_connect(obex, req_complete, &d, &d.err, G_OBEX_HDR_INVALID);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_setpath_req, sizeof(pkt_setpath_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_setpath(obex, "dir", req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_setpath_up_req, sizeof(pkt_setpath_up_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_setpath(obex, "..", req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_setpath_up_down_req,
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_setpath(obex, "../dir", req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_mkdir_req, sizeof(pkt_mkdir_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_mkdir(obex, "dir", req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_delete_req, sizeof(pkt_delete_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_delete(obex, "foo.txt", req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_copy_req, sizeof(pkt_copy_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_copy(obex, "foo", "bar", req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
{
GIOChannel *io;
GIOCondition cond;
- guint io_id, timer_id;
GObex *obex;
struct test_data d = { 0, NULL, {
{ pkt_move_req, sizeof(pkt_move_req) } }, {
create_endpoints(&obex, &io, SOCK_STREAM);
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
- io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+ d.io_id = g_io_add_watch(io, cond, test_io_cb, &d);
d.mainloop = g_main_loop_new(NULL, FALSE);
- timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+ d.timer_id = g_timeout_add_seconds(1, test_timeout, &d);
g_obex_move(obex, "foo", "bar", req_complete, &d, &d.err);
g_assert_no_error(d.err);
g_main_loop_unref(d.mainloop);
- g_source_remove(timer_id);
+ if (d.timer_id > 0)
+ g_source_remove(d.timer_id);
+ if (d.io_id > 0)
+ g_source_remove(d.io_id);
+
g_io_channel_unref(io);
- g_source_remove(io_id);
g_obex_unref(obex);
g_assert_no_error(d.err);
diff --git a/unit/util.c b/unit/util.c
index e7804d8..1322d80 100644
--- a/unit/util.c
+++ b/unit/util.c
return FALSE;
d->err = g_error_new(TEST_ERROR, TEST_ERROR_TIMEOUT, "Timed out");
+ d->timer_id = 0;
g_main_loop_quit(d->mainloop);
return TRUE;
failed:
+ d->io_id = 0;
g_main_loop_quit(d->mainloop);
- d->io_completed = TRUE;
return FALSE;
}
diff --git a/unit/util.h b/unit/util.h
index d5d0f19..27a4509 100644
--- a/unit/util.h
+++ b/unit/util.h
GObex *obex;
guint id;
gsize total;
+ guint timer_id;
+ guint io_id;
GMainLoop *mainloop;
- gboolean io_completed;
};
#define TEST_ERROR test_error_quark()