Esempio n. 1
0
/** Get voice calls associated with a modem [sync]
 *
 * Populate voice call lookup table with the reply data
 *
 * @param modem D-Bus object path
 */
static void
xofono_get_vcalls(const char *modem)
{
    DBusMessage *rsp = 0;
    DBusError    err = DBUS_ERROR_INIT;
    int          cnt = 0;

    /* FIXME: mce-dbus not have a async method call with
     * context data pointer -> using sync call for now ... */
    rsp = dbus_send_with_block(OFONO_SERVICE,
                               modem,
                               OFONO_VCALLMANAGER_INTERFACE,
                               OFONO_VCALLMANAGER_REQ_GET_CALLS,
                               -1,
                               DBUS_TYPE_INVALID);
    if( !rsp )
        goto EXIT;

    if( dbus_set_error_from_message(&err, rsp) ) {
        mce_log(LL_ERR, "%s: %s", err.name, err.message);
        goto EXIT;
    }

    // <arg name="calls_with_properties" type="a(oa{sv})" direction="out"/>

    DBusMessageIter body, arr1, mod;
    dbus_message_iter_init(rsp, &body);
    if( !mce_dbus_iter_get_array(&body, &arr1) )
        goto EXIT;

    while( !mce_dbus_iter_at_end(&arr1) ) {
        const char *name = 0;

        if( !mce_dbus_iter_get_struct(&arr1, &mod) )
            goto EXIT;
        if( !mce_dbus_iter_get_object(&mod, &name) )
            goto EXIT;

        ofono_vcall_t *vcall = vcalls_add_call(name);
        if( !vcall )
            continue;
        ofono_vcall_update_N(vcall, &mod);
        ++cnt;
    }
    call_state_rethink_schedule();

EXIT:
    mce_log(LL_DEBUG, "added %d calls", cnt);
    if( rsp ) dbus_message_unref(rsp);
    dbus_error_free(&err);
    return;
}
Esempio n. 2
0
/**
 * Translate a D-Bus bus name into a pid
 *
 * @param bus_name A string with the bus name
 * @return The pid of the process, or -1 if no process could be identified
 */
pid_t dbus_get_pid_from_bus_name(const gchar *const bus_name)
{
	dbus_uint32_t pid = -1;
	DBusMessage *reply;

	if ((reply = dbus_send_with_block("org.freedesktop.DBus",
				          "/org/freedesktop/DBus/Bus",
				          "org.freedesktop.DBus",
				          "GetConnectionUnixProcessID", -1,
				          DBUS_TYPE_STRING, &bus_name,
				          DBUS_TYPE_INVALID)) != NULL) {
		dbus_message_get_args(reply, NULL,
				      DBUS_TYPE_UINT32, &pid,
				      DBUS_TYPE_INVALID);
		dbus_message_unref(reply);
	}

	return (pid_t)pid;
}