当前位置: 首页>>代码示例>>C++>>正文


C++ sd_bus_message_new_method_call函数代码示例

本文整理汇总了C++中sd_bus_message_new_method_call函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_bus_message_new_method_call函数的具体用法?C++ sd_bus_message_new_method_call怎么用?C++ sd_bus_message_new_method_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sd_bus_message_new_method_call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_marshal

static void test_marshal(void) {
        _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *n = NULL;
        _cleanup_bus_unref_ sd_bus *bus = NULL;
        _cleanup_free_ void *blob;
        size_t sz;

        assert_se(sd_bus_open_system(&bus) >= 0);
        bus->message_version = 2; /* dirty hack to enable gvariant*/

        assert_se(sd_bus_message_new_method_call(bus, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName", &m) >= 0);

        assert_se(sd_bus_message_append(m,
                                        "a(usv)", 2,
                                        4711, "first-string-parameter", "(st)", "X", (uint64_t) 1111,
                                        4712, "second-string-parameter", "(a(si))", 2, "Y", 5, "Z", 6) >= 0);

        assert_se(bus_message_seal(m, 4711) >= 0);

#ifdef HAVE_GLIB
        {
                GVariant *v;
                char *t;

#if !defined(GLIB_VERSION_2_36)
                g_type_init();
#endif

                v = g_variant_new_from_data(G_VARIANT_TYPE("(yyyyuuua(yv))"), m->header, sizeof(struct bus_header) + BUS_MESSAGE_FIELDS_SIZE(m), false, NULL, NULL);
                t = g_variant_print(v, TRUE);
                printf("%s\n", t);
                g_free(t);
                g_variant_unref(v);

                v = g_variant_new_from_data(G_VARIANT_TYPE("(a(usv))"), m->body.data, BUS_MESSAGE_BODY_SIZE(m), false, NULL, NULL);
                t = g_variant_print(v, TRUE);
                printf("%s\n", t);
                g_free(t);
                g_variant_unref(v);
        }
#endif

        assert_se(bus_message_dump(m, NULL, true) >= 0);

        assert_se(bus_message_get_blob(m, &blob, &sz) >= 0);

        assert_se(bus_message_from_malloc(NULL, blob, sz, NULL, 0, NULL, NULL, &n) >= 0);
        blob = NULL;

        assert_se(bus_message_dump(n, NULL, true) >= 0);

        m = sd_bus_message_unref(m);

        assert_se(sd_bus_message_new_method_call(bus, "a.x", "/a/x", "a.x", "Ax", &m) >= 0);

        assert_se(sd_bus_message_append(m, "as", 0) >= 0);

        assert_se(bus_message_seal(m, 4712) >= 0);
        assert_se(bus_message_dump(m, NULL, true) >= 0);
}
开发者ID:jumpstarter-io,项目名称:systemd,代码行数:59,代码来源:test-bus-gvariant.c

示例2: sysview_session_take_control

int sysview_session_take_control(sysview_session *session) {
        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
        int r;

        assert_return(session, -EINVAL);
        assert_return(!session->custom, -EINVAL);

        if (session->wants_control)
                return 0;

        r = sd_bus_message_new_method_call(session->seat->context->sysbus,
                                           &m,
                                           "org.freedesktop.login1",
                                           session->path,
                                           "org.freedesktop.login1.Session",
                                           "TakeControl");
        if (r < 0)
                return r;

        r = sd_bus_message_append(m, "b", 0);
        if (r < 0)
                return r;

        r = sd_bus_call_async(session->seat->context->sysbus,
                              &session->slot_take_control,
                              m,
                              session_take_control_fn,
                              session,
                              0);
        if (r < 0)
                return r;

        session->wants_control = true;
        return 0;
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:35,代码来源:sysview.c

示例3: reload_manager

static int reload_manager(sd_bus *bus) {
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
        int r;

        log_info("Reloading system manager configuration");

        r = sd_bus_message_new_method_call(
                        bus,
                        &m,
                        "org.freedesktop.systemd1",
                        "/org/freedesktop/systemd1",
                        "org.freedesktop.systemd1.Manager",
                        "Reload");
        if (r < 0)
                return bus_log_create_error(r);

        /* Note we use an extra-long timeout here. This is because a reload or reexec means generators are rerun which
         * are timed out after DEFAULT_TIMEOUT_USEC. Let's use twice that time here, so that the generators can have
         * their timeout, and for everything else there's the same time budget in place. */

        r = sd_bus_call(bus, m, DEFAULT_TIMEOUT_USEC * 2, &error, NULL);
        if (r < 0)
                return log_error_errno(r, "Failed to reload daemon: %s", bus_error_message(&error, r));

        return 0;
}
开发者ID:heftig,项目名称:systemd,代码行数:27,代码来源:sulogin-shell.c

示例4: find_openbmc_path

// Use a lookup table to find the interface name of a specific sensor
// This will be used until an alternative is found.  this is the first
// step for mapping IPMI
int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) {

    const char  *busname = "org.openbmc.managers.System";
    const char  *objname = "/org/openbmc/managers/System";

    char  *str1, *str2, *str3;
    sd_bus_error error = SD_BUS_ERROR_NULL;
    sd_bus_message *reply = NULL, *m=NULL;


    int r;

    r = sd_bus_message_new_method_call(bus,&m,busname,objname,busname,"getObjectFromByteId");
    if (r < 0) {
        fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
    }

    r = sd_bus_message_append(m, "sy", type, num);
    if (r < 0) {
        fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
    }

    // Call the IPMI responder on the bus so the message can be sent to the CEC
    r = sd_bus_call(bus, m, 0, &error, &reply);
    if (r < 0) {
        fprintf(stderr, "Failed to call the method: %s", strerror(-r));
        goto final;
    }
开发者ID:cyrilbur-ibm,项目名称:phosphor-host-ipmid,代码行数:31,代码来源:testaddsel.C

示例5: sysview_session_release_control

void sysview_session_release_control(sysview_session *session) {
        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
        int r;

        assert(session);
        assert(!session->custom);

        if (!session->wants_control)
                return;

        session->wants_control = false;

        if (!session->has_control && !session->slot_take_control)
                return;

        session->has_control = false;
        session->slot_take_control = sd_bus_slot_unref(session->slot_take_control);

        r = sd_bus_message_new_method_call(session->seat->context->sysbus,
                                           &m,
                                           "org.freedesktop.login1",
                                           session->path,
                                           "org.freedesktop.login1.Session",
                                           "ReleaseControl");
        if (r >= 0)
                r = sd_bus_send(session->seat->context->sysbus, m, NULL);

        if (r < 0 && r != -ENOTCONN)
                log_debug_errno(r, "sysview: %s: cannot send ReleaseControl: %m",
                                session->name);
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:31,代码来源:sysview.c

示例6: sd_bus_call_method

_public_ int sd_bus_call_method(
                sd_bus *bus,
                const char *destination,
                const char *path,
                const char *interface,
                const char *member,
                sd_bus_error *error,
                sd_bus_message **reply,
                const char *types, ...) {

        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
        int r;

        assert_return(bus, -EINVAL);
        assert_return(!bus_pid_changed(bus), -ECHILD);

        if (!BUS_IS_OPEN(bus->state))
                return -ENOTCONN;

        r = sd_bus_message_new_method_call(bus, &m, destination, path, interface, member);
        if (r < 0)
                return r;

        if (!isempty(types)) {
                va_list ap;

                va_start(ap, types);
                r = bus_message_append_ap(m, types, ap);
                va_end(ap);
                if (r < 0)
                        return r;
        }

        return sd_bus_call(bus, m, 0, error, reply);
}
开发者ID:chenyf,项目名称:systemd,代码行数:35,代码来源:bus-convenience.c

示例7: ipmi_app_reset_watchdog

ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
                             ipmi_request_t request, ipmi_response_t response,
                             ipmi_data_len_t data_len, ipmi_context_t context)
{
    const char  *busname = "org.openbmc.watchdog.Host";
    const char  *objname = "/org/openbmc/watchdog/host0";
    const char  *iface = "org.openbmc.Watchdog";
    sd_bus_message *reply = NULL, *m = NULL;
    sd_bus_error error = SD_BUS_ERROR_NULL;
    int r = 0;

    // Status code.
    ipmi_ret_t rc = IPMI_CC_OK;
    *data_len = 0;

    printf("WATCHDOG RESET\n");

    // Refresh watchdog
    r = sd_bus_message_new_method_call(bus,&m,busname,objname,iface,"poke");
    if (r < 0) {
        fprintf(stderr, "Failed to add the method object: %s\n", strerror(-r));
        return -1;
    }
    r = sd_bus_call(bus, m, 0, &error, &reply);
    if (r < 0) {
        fprintf(stderr, "Failed to call the method: %s\n", strerror(-r));
        return -1;
    }

    sd_bus_error_free(&error);
    sd_bus_message_unref(m);

    return rc;
}
开发者ID:hramasub,项目名称:phosphor-host-ipmid,代码行数:34,代码来源:apphandler.C

示例8: maybe_reload

static int maybe_reload(sd_bus **bus) {
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
        int r;

        if (!arg_reload)
                return 0;

        r = acquire_bus(bus);
        if (r < 0)
                return r;

        r = sd_bus_message_new_method_call(
                        *bus,
                        &m,
                        "org.freedesktop.systemd1",
                        "/org/freedesktop/systemd1",
                        "org.freedesktop.systemd1.Manager",
                        "Reload");
        if (r < 0)
                return bus_log_create_error(r);

        /* Reloading the daemon may take long, hence set a longer timeout here */
        r = sd_bus_call(*bus, m, DEFAULT_TIMEOUT_USEC * 2, &error, NULL);
        if (r < 0)
                return log_error_errno(r, "Failed to reload daemon: %s", bus_error_message(&error, r));

        return 0;
}
开发者ID:l10n-tw,项目名称:systemd,代码行数:29,代码来源:portablectl.c

示例9: client

static int client(struct context *c) {
        _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
        _cleanup_bus_unref_ sd_bus *bus = NULL;
        sd_bus_error error = SD_BUS_ERROR_NULL;
        int r;

        assert_se(sd_bus_new(&bus) >= 0);
        assert_se(sd_bus_set_fd(bus, c->fds[1], c->fds[1]) >= 0);
        assert_se(sd_bus_negotiate_fds(bus, c->client_negotiate_unix_fds) >= 0);
        assert_se(sd_bus_set_anonymous(bus, c->client_anonymous_auth) >= 0);
        assert_se(sd_bus_start(bus) >= 0);

        r = sd_bus_message_new_method_call(
                        bus,
                        &m,
                        "org.freedesktop.systemd.test",
                        "/",
                        "org.freedesktop.systemd.test",
                        "Exit");
        if (r < 0) {
                log_error("Failed to allocate method call: %s", strerror(-r));
                return r;
        }

        r = sd_bus_call(bus, m, 0, &error, &reply);
        if (r < 0) {
                log_error("Failed to issue method call: %s", bus_error_message(&error, -r));
                return r;
        }

        return 0;
}
开发者ID:MOBO-OSS,项目名称:systemd-relative,代码行数:32,代码来源:test-bus-server.c

示例10: test_rr_lookup

static void test_rr_lookup(sd_bus *bus, const char *name, uint16_t type, const char *result) {
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL, *reply = NULL;
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        _cleanup_free_ char *m = NULL;
        int r;

        /* If the name starts with a dot, we prefix one to three random labels */
        if (startswith(name, ".")) {
                prefix_random(name + 1, &m);
                name = m;
        }

        assert_se(sd_bus_message_new_method_call(
                                  bus,
                                  &req,
                                  "org.freedesktop.resolve1",
                                  "/org/freedesktop/resolve1",
                                  "org.freedesktop.resolve1.Manager",
                                  "ResolveRecord") >= 0);

        assert_se(sd_bus_message_append(req, "isqqt", 0, name, DNS_CLASS_IN, type, UINT64_C(0)) >= 0);

        r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply);

        if (r < 0) {
                assert_se(result);
                assert_se(sd_bus_error_has_name(&error, result));
                log_info("[OK] %s/%s resulted in <%s>.", name, dns_type_to_string(type), error.name);
        } else {
                assert_se(!result);
                log_info("[OK] %s/%s succeeded.", name, dns_type_to_string(type));
        }
}
开发者ID:Hariprasathganesh,项目名称:testsysd,代码行数:33,代码来源:test-dnssec-complex.c

示例11: cc_Ball_drop

int cc_Ball_drop(struct cc_client_Ball *instance)
{
    int result = 0;
    struct cc_instance *i;
    sd_bus_message *message = NULL;

    CC_LOG_DEBUG("invoked cc_Ball_drop()\n");
    assert(instance);
    i = instance->instance;
    assert(i && i->backend && i->backend->bus);
    assert(i->service && i->path && i->interface);

    result = sd_bus_message_new_method_call(
        i->backend->bus, &message, i->service, i->path, i->interface, "drop");
    if (result < 0) {
        CC_LOG_ERROR("unable to create message: %s\n", strerror(-result));
        goto fail;
    }
    result = sd_bus_message_set_expect_reply(message, 0);
    if (result < 0) {
        CC_LOG_ERROR("unable to flag message no-reply-expected: %s\n", strerror(-result));
        goto fail;
    }
    /* Setting cookie=NULL in sd_bus_send() call makes the previous one redundant */
    result = sd_bus_send(i->backend->bus, message, NULL);
    if (result < 0) {
        CC_LOG_ERROR("unable to send message: %s\n", strerror(-result));
        goto fail;
    }

fail:
    message = sd_bus_message_unref(message);

    return result;
}
开发者ID:gmacario,项目名称:common-api-c-poc,代码行数:35,代码来源:client-Ball.c

示例12: kbdctx_query_locale

static int kbdctx_query_locale(kbdctx *kc) {
        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
        int r;

        kc->slot_locale_get_all = sd_bus_slot_unref(kc->slot_locale_get_all);

        r = sd_bus_message_new_method_call(kc->context->sysbus,
                                           &m,
                                           "org.freedesktop.locale1",
                                           "/org/freedesktop/locale1",
                                           "org.freedesktop.DBus.Properties",
                                           "GetAll");
        if (r < 0)
                goto error;

        r = sd_bus_message_append(m, "s", "org.freedesktop.locale1");
        if (r < 0)
                goto error;

        r = sd_bus_call_async(kc->context->sysbus,
                              &kc->slot_locale_get_all,
                              m,
                              kbdctx_locale_get_all_fn,
                              kc,
                              0);
        if (r < 0)
                goto error;

        return 0;

error:
        return log_debug_errno(r, "idev-keyboard: cannot send GetAll to locale1: %m");
}
开发者ID:RaghavanSanthanam,项目名称:systemd,代码行数:33,代码来源:idev-keyboard.c

示例13: set_locale

static int set_locale(sd_bus *bus, char **args, unsigned n) {
        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
        int r;

        assert(bus);
        assert(args);

        polkit_agent_open_if_enabled();

        r = sd_bus_message_new_method_call(bus,
                        "org.freedesktop.locale1",
                        "/org/freedesktop/locale1",
                        "org.freedesktop.locale1",
                        "SetLocale", &m);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_message_append_strv(m, args + 1);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_message_append(m, "b", arg_ask_password);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_call(bus, m, 0, &error, NULL);
        if (r < 0) {
                log_error("Failed to issue method call: %s", bus_error_message(&error, -r));
                return r;
        }

        return 0;
}
开发者ID:ariscop,项目名称:systemd,代码行数:34,代码来源:localectl.c

示例14: set_locale

static int set_locale(int argc, char **argv, void *userdata) {
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
        sd_bus *bus = userdata;
        int r;

        assert(bus);

        polkit_agent_open_if_enabled(arg_transport, arg_ask_password);

        r = sd_bus_message_new_method_call(
                        bus,
                        &m,
                        "org.freedesktop.locale1",
                        "/org/freedesktop/locale1",
                        "org.freedesktop.locale1",
                        "SetLocale");
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_message_append_strv(m, argv + 1);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_message_append(m, "b", arg_ask_password);
        if (r < 0)
                return bus_log_create_error(r);

        r = sd_bus_call(bus, m, 0, &error, NULL);
        if (r < 0)
                return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));

        return 0;
}
开发者ID:halfline,项目名称:systemd,代码行数:34,代码来源:localectl.c

示例15: locale_update_system_manager

static int locale_update_system_manager(Context *c, sd_bus *bus) {
        _cleanup_free_ char **l_unset = NULL;
        _cleanup_strv_free_ char **l_set = NULL;
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
        sd_bus_error error = SD_BUS_ERROR_NULL;
        unsigned c_set, c_unset, p;
        int r;

        assert(bus);

        l_unset = new0(char*, _VARIABLE_LC_MAX);
        if (!l_unset)
                return -ENOMEM;

        l_set = new0(char*, _VARIABLE_LC_MAX);
        if (!l_set)
                return -ENOMEM;

        for (p = 0, c_set = 0, c_unset = 0; p < _VARIABLE_LC_MAX; p++) {
                const char *name;

                name = locale_variable_to_string(p);
                assert(name);

                if (isempty(c->locale[p]))
                        l_unset[c_set++] = (char*) name;
                else {
                        char *s;

                        if (asprintf(&s, "%s=%s", name, c->locale[p]) < 0)
                                return -ENOMEM;

                        l_set[c_unset++] = s;
                }
        }

        assert(c_set + c_unset == _VARIABLE_LC_MAX);
        r = sd_bus_message_new_method_call(bus, &m,
                        "org.freedesktop.systemd1",
                        "/org/freedesktop/systemd1",
                        "org.freedesktop.systemd1.Manager",
                        "UnsetAndSetEnvironment");
        if (r < 0)
                return r;

        r = sd_bus_message_append_strv(m, l_unset);
        if (r < 0)
                return r;

        r = sd_bus_message_append_strv(m, l_set);
        if (r < 0)
                return r;

        r = sd_bus_call(bus, m, 0, &error, NULL);
        if (r < 0)
                log_error_errno(r, "Failed to update the manager environment: %m");

        return 0;
}
开发者ID:embe,项目名称:systemd,代码行数:59,代码来源:localed.c


注:本文中的sd_bus_message_new_method_call函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。