mirror of
https://github.com/sailfishos/ofono
synced 2025-12-02 23:51:10 +08:00
Compare commits
3 Commits
mer/1.23+g
...
mer/1.23+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
870bac93e9 | ||
|
|
246cd4e1d2 | ||
|
|
ca20b65098 |
@@ -121,6 +121,30 @@ void __ofono_dbus_queue_request(struct ofono_dbus_queue *q,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __ofono_dbus_queue_submit_next(struct ofono_dbus_queue *q)
|
||||||
|
{
|
||||||
|
struct ofono_dbus_queue_request *next = q->requests;
|
||||||
|
|
||||||
|
while (next) {
|
||||||
|
struct ofono_dbus_queue_request *done;
|
||||||
|
DBusMessage *reply = next->fn(next->msg, next->data);
|
||||||
|
|
||||||
|
/* The request has been sent, no reply yet */
|
||||||
|
if (!reply)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* The request has completed synchronously */
|
||||||
|
done = next;
|
||||||
|
next = done->next;
|
||||||
|
q->requests = next;
|
||||||
|
done->next = NULL;
|
||||||
|
|
||||||
|
/* Send the reply */
|
||||||
|
__ofono_dbus_pending_reply(&done->msg, reply);
|
||||||
|
__ofono_dbus_queue_req_free(done);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Consumes one reference to the reply */
|
/* Consumes one reference to the reply */
|
||||||
void __ofono_dbus_queue_reply_msg(struct ofono_dbus_queue *q,
|
void __ofono_dbus_queue_reply_msg(struct ofono_dbus_queue *q,
|
||||||
DBusMessage *reply)
|
DBusMessage *reply)
|
||||||
@@ -150,20 +174,7 @@ void __ofono_dbus_queue_reply_msg(struct ofono_dbus_queue *q,
|
|||||||
__ofono_dbus_queue_req_free(done);
|
__ofono_dbus_queue_req_free(done);
|
||||||
|
|
||||||
/* Submit the next request if there is any */
|
/* Submit the next request if there is any */
|
||||||
while (next && reply) {
|
__ofono_dbus_queue_submit_next(q);
|
||||||
reply = next->fn(next->msg, next->data);
|
|
||||||
if (reply) {
|
|
||||||
/* The request has completed synchronously */
|
|
||||||
done = next;
|
|
||||||
next = done->next;
|
|
||||||
q->requests = next;
|
|
||||||
done->next = NULL;
|
|
||||||
|
|
||||||
/* Send the reply */
|
|
||||||
__ofono_dbus_pending_reply(&done->msg, reply);
|
|
||||||
__ofono_dbus_queue_req_free(done);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __ofono_dbus_queue_reply_ok(struct ofono_dbus_queue *q)
|
void __ofono_dbus_queue_reply_ok(struct ofono_dbus_queue *q)
|
||||||
@@ -250,8 +261,10 @@ void __ofono_dbus_queue_reply_all_fn_param(struct ofono_dbus_queue *q,
|
|||||||
* Find all other requests with the same handler and the same data
|
* Find all other requests with the same handler and the same data
|
||||||
* and complete those too (except when the handler is NULL)
|
* and complete those too (except when the handler is NULL)
|
||||||
*/
|
*/
|
||||||
if (!handler)
|
if (!handler) {
|
||||||
|
__ofono_dbus_queue_submit_next(q);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
req = q->requests;
|
req = q->requests;
|
||||||
@@ -274,6 +287,7 @@ void __ofono_dbus_queue_reply_all_fn_param(struct ofono_dbus_queue *q,
|
|||||||
|
|
||||||
req = next;
|
req = next;
|
||||||
}
|
}
|
||||||
|
__ofono_dbus_queue_submit_next(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ static void test_reply_last_reply(DBusPendingCall *call, void *dbus)
|
|||||||
G_CAST(dbus, struct test_reply_data, dbus);
|
G_CAST(dbus, struct test_reply_data, dbus);
|
||||||
|
|
||||||
DBG("");
|
DBG("");
|
||||||
test_dbus_check_error_reply(call, TEST_ERROR_FAILED);
|
test_dbus_check_empty_reply(call, NULL);
|
||||||
g_main_loop_quit(test->dbus.loop);
|
g_main_loop_quit(test->dbus.loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,6 +445,12 @@ static DBusMessage *test_reply_4(DBusMessage *msg, void *data)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DBusMessage *test_reply_5(DBusMessage *msg, void *data)
|
||||||
|
{
|
||||||
|
DBG("");
|
||||||
|
return dbus_message_new_method_return(msg);
|
||||||
|
}
|
||||||
|
|
||||||
static DBusMessage *test_reply_handler(DBusConnection *conn,
|
static DBusMessage *test_reply_handler(DBusConnection *conn,
|
||||||
DBusMessage *msg, void *data)
|
DBusMessage *msg, void *data)
|
||||||
{
|
{
|
||||||
@@ -485,10 +491,17 @@ static DBusMessage *test_reply_handler(DBusConnection *conn,
|
|||||||
case 6:
|
case 6:
|
||||||
__ofono_dbus_queue_request(test->queue, test_reply_4,
|
__ofono_dbus_queue_request(test->queue, test_reply_4,
|
||||||
msg, NULL);
|
msg, NULL);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
/* Call the same method again */
|
||||||
__ofono_dbus_queue_request(test->queue, test_reply_4,
|
__ofono_dbus_queue_request(test->queue, test_reply_4,
|
||||||
msg, NULL);
|
msg, NULL);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 8:
|
||||||
|
/* Call the last one */
|
||||||
|
__ofono_dbus_queue_request(test->queue, test_reply_5,
|
||||||
|
msg, NULL);
|
||||||
|
|
||||||
/* This completes the first one, with NULL handler */
|
/* This completes the first one, with NULL handler */
|
||||||
__ofono_dbus_queue_reply_all_fn_param(test->queue, NULL, NULL);
|
__ofono_dbus_queue_reply_all_fn_param(test->queue, NULL, NULL);
|
||||||
g_assert(__ofono_dbus_queue_pending(test->queue));
|
g_assert(__ofono_dbus_queue_pending(test->queue));
|
||||||
@@ -508,10 +521,12 @@ static DBusMessage *test_reply_handler(DBusConnection *conn,
|
|||||||
/* This one test_reply_3 with Failed */
|
/* This one test_reply_3 with Failed */
|
||||||
__ofono_dbus_queue_reply_all_error(test->queue, NULL);
|
__ofono_dbus_queue_reply_all_error(test->queue, NULL);
|
||||||
|
|
||||||
/* This one test_reply_4 with NotSupported */
|
/* This one completes all test_reply_4 with NotSupported */
|
||||||
error.type = OFONO_ERROR_TYPE_ERRNO;
|
error.type = OFONO_ERROR_TYPE_ERRNO;
|
||||||
error.error = -EOPNOTSUPP;
|
error.error = -EOPNOTSUPP;
|
||||||
__ofono_dbus_queue_reply_all_error(test->queue, &error);
|
__ofono_dbus_queue_reply_all_error(test->queue, &error);
|
||||||
|
|
||||||
|
/* test_reply_5 must be already completed */
|
||||||
g_assert(!__ofono_dbus_queue_pending(test->queue));
|
g_assert(!__ofono_dbus_queue_pending(test->queue));
|
||||||
|
|
||||||
/* And this one does nothing */
|
/* And this one does nothing */
|
||||||
@@ -541,7 +556,8 @@ static void test_reply_start(struct test_dbus_context *dbus)
|
|||||||
test_client_call(dbus, 4, test_dbus_expect_empty_reply);
|
test_client_call(dbus, 4, test_dbus_expect_empty_reply);
|
||||||
test_client_call(dbus, 5, test_expect_failed);
|
test_client_call(dbus, 5, test_expect_failed);
|
||||||
test_client_call(dbus, 6, test_expect_not_supported);
|
test_client_call(dbus, 6, test_expect_not_supported);
|
||||||
test_client_call(dbus, 7, test_reply_last_reply);
|
test_client_call(dbus, 7, test_expect_not_supported);
|
||||||
|
test_client_call(dbus, 8, test_reply_last_reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_reply(void)
|
static void test_reply(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user