Example #1
0
static sss_sifp_error
sss_sifp_invoke_find_va(sss_sifp_ctx *ctx,
                        const char *object_path,
                        const char *interface,
                        const char *method,
                        char **_object_path,
                        int first_arg_type,
                        va_list ap)
{
   DBusMessage *reply = NULL;
   char *dbus_method = NULL;
   sss_sifp_error ret;

   if (ctx == NULL || method == NULL || _object_path == NULL) {
       return SSS_SIFP_INVALID_ARGUMENT;
   }

   dbus_method = sss_sifp_strcat(ctx, "Find", method);
   if (dbus_method == NULL) {
       ret = SSS_SIFP_OUT_OF_MEMORY;
       goto done;
   }

   ret = sss_sifp_ifp_call(ctx, object_path, interface, dbus_method,
                           first_arg_type, ap, &reply);
   if (ret != SSS_SIFP_OK) {
       goto done;
   }

   ret = sss_sifp_parse_object_path(ctx, reply, _object_path);

done:
    sss_sifp_free_string(ctx, &dbus_method);

   if (reply != NULL) {
       dbus_message_unref(reply);
   }

   return ret;
}
Example #2
0
sss_sifp_error
sss_sifp_invoke_list(sss_sifp_ctx *ctx,
                     const char *method,
                     char ***_object_paths,
                     int first_arg_type,
                     ...)
{
    DBusMessage *reply = NULL;
    char *dbus_method = NULL;
    sss_sifp_error ret;
    va_list ap;

    if (ctx == NULL || method == NULL || _object_paths == NULL) {
        return SSS_SIFP_INVALID_ARGUMENT;
    }

    dbus_method = sss_sifp_strcat(ctx, "List", method);
    if (dbus_method == NULL) {
        ret = SSS_SIFP_OUT_OF_MEMORY;
        goto done;
    }

    va_start(ap, first_arg_type);
    ret = sss_sifp_ifp_call(ctx, dbus_method, first_arg_type, ap, &reply);
    va_end(ap);
    if (ret != SSS_SIFP_OK) {
        goto done;
    }

    ret = sss_sifp_parse_object_path_list(ctx, reply, _object_paths);

done:
    sss_sifp_free_string(ctx, &dbus_method);

    if (reply != NULL) {
        dbus_message_unref(reply);
    }

    return ret;
}
Example #3
0
static sss_sifp_error
sss_sifp_fetch_object_by_attr(sss_sifp_ctx *ctx,
                              const char *path,
                              const char *iface_find,
                              const char *iface_object,
                              const char *method,
                              int attr_type,
                              const void *attr,
                              sss_sifp_object **_object)
{
    sss_sifp_object *object = NULL;
    char *object_path = NULL;
    sss_sifp_error ret;

    if (method == NULL || attr == NULL || attr_type == DBUS_TYPE_INVALID) {
        return SSS_SIFP_INVALID_ARGUMENT;
    }

    ret = sss_sifp_invoke_find_ex(ctx, path, iface_find, method, &object_path,
                                  attr_type, attr, DBUS_TYPE_INVALID);
    if (ret != SSS_SIFP_OK) {
        goto done;
    }

    ret = sss_sifp_fetch_object(ctx, object_path, iface_object, &object);
    if (ret != SSS_SIFP_OK) {
        goto done;
    }

    *_object = object;

    ret = SSS_SIFP_OK;

done:
    sss_sifp_free_string(ctx, &object_path);

    return ret;
}