Ejemplo n.º 1
0
static
int
test_run_one(
    const MMSConfig* config,
    const TestDesc* desc)
{
    Test test;
    if (test_init(&test, config, desc)) {
        GError* error = NULL;
        GBytes* push = g_bytes_new_static(
            g_mapped_file_get_contents(test.notification_ind),
            g_mapped_file_get_length(test.notification_ind));
        if (mms_dispatcher_handle_push(test.disp, "TestConnection",
            push, &error)) {
            if (mms_dispatcher_start(test.disp)) {
                test.ret = RET_OK;
                g_main_loop_run(test.loop);
            } else {
                MMS_INFO("%s FAILED", desc->name);
            }
        } else {
            MMS_ERR("%s", MMS_ERRMSG(error));
            MMS_INFO("%s FAILED", desc->name);
            g_error_free(error);
        }
        g_bytes_unref(push);
        test_finalize(&test);
        return test.ret;
    } else {
        return RET_ERR;
    }
}
Ejemplo n.º 2
0
/* org.nemomobile.MmsEngine.pushNotify */
static
gboolean
mms_engine_handle_push_notify(
    OrgNemomobileMmsEngine* proxy,
    GDBusMethodInvocation* call,
    const char* imsi,
    const char* type,
    GVariant* data,
    MMSEngine* engine)
{
    gsize len = 0;
    const guint8* bytes = g_variant_get_fixed_array(data, &len, 1);
    MMS_DEBUG("Received %u bytes from %s", (guint)len, imsi);
    if (!type || g_ascii_strcasecmp(type, MMS_CONTENT_TYPE)) {
        MMS_ERR("Unsupported content type %s", type);
        g_dbus_method_invocation_return_error(call, G_DBUS_ERROR,
            G_DBUS_ERROR_FAILED, "Unsupported content type");
    } else if (!imsi || !imsi[0]) {
        MMS_ERR_("IMSI is missing");
        g_dbus_method_invocation_return_error(call, G_DBUS_ERROR,
            G_DBUS_ERROR_FAILED, "IMSI is missing");
    } else if (!bytes || !len) {
        MMS_ERR_("No data provided");
        g_dbus_method_invocation_return_error(call, G_DBUS_ERROR,
            G_DBUS_ERROR_FAILED, "No data provided");
    } else {
        GError* err = NULL;
        GBytes* msg = g_bytes_new(bytes, len);
        if (mms_dispatcher_handle_push(engine->dispatcher, imsi, msg, &err)) {
            if (mms_dispatcher_start(engine->dispatcher)) {
                mms_engine_start_timeout_cancel(engine);
            }
            org_nemomobile_mms_engine_complete_push(proxy, call);
        } else {
            g_dbus_method_invocation_return_error(call, G_DBUS_ERROR,
                G_DBUS_ERROR_FAILED, "%s", MMS_ERRMSG(err));
            g_error_free(err);
        }
        g_bytes_unref(msg);
    }
    return TRUE;
}