Exemplo n.º 1
0
static void
_set_loggedin_username ()
{
    GVariant *vusername = _get_property ("Name");
    if (vusername && main_window->user_label) {
        elm_object_text_set(main_window->user_label,
                g_variant_get_string (vusername, NULL));
    }
    if (vusername) g_variant_unref (vusername);
}
Exemplo n.º 2
0
DataForm*
form_create(xmpp_stanza_t *const form_stanza)
{
    xmpp_ctx_t *ctx = connection_get_ctx();

    if (!_is_valid_form_element(form_stanza)) {
        return NULL;
    }

    DataForm *form = _form_new();
    form->type = _get_attr(form_stanza, "type");
    form->title = _get_property(form_stanza, "title");
    form->instructions = _get_property(form_stanza, "instructions");
    form->var_to_tag = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
    form->tag_to_var = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
    form->tag_ac = autocomplete_new();
    form->modified = FALSE;

    int tag_num = 1;

    // get fields
    xmpp_stanza_t *form_child = xmpp_stanza_get_children(form_stanza);
    while (form_child) {
        const char *child_name = xmpp_stanza_get_name(form_child);
        if (g_strcmp0(child_name, "field") == 0) {
            xmpp_stanza_t *field_stanza = form_child;

            FormField *field = _field_new();
            field->label = _get_attr(field_stanza, "label");
            field->type = _get_attr(field_stanza, "type");
            field->type_t = _get_field_type(field->type);
            field->value_ac = autocomplete_new();

            field->var = _get_attr(field_stanza, "var");

            if (field->type_t != FIELD_HIDDEN && field->var) {
                GString *tag = g_string_new("");
                g_string_printf(tag, "field%d", tag_num++);
                g_hash_table_insert(form->var_to_tag, strdup(field->var), strdup(tag->str));
                g_hash_table_insert(form->tag_to_var, strdup(tag->str), strdup(field->var));
                autocomplete_add(form->tag_ac, tag->str);
                g_string_free(tag, TRUE);
            }

            field->description = _get_property(field_stanza, "desc");
            field->required = _is_required(field_stanza);

            // handle repeated field children
            xmpp_stanza_t *field_child = xmpp_stanza_get_children(field_stanza);
            int value_index = 1;
            while (field_child) {
                child_name = xmpp_stanza_get_name(field_child);

                // handle values
                if (g_strcmp0(child_name, "value") == 0) {
                    char *value = xmpp_stanza_get_text(field_child);
                    if (value) {
                        field->values = g_slist_append(field->values, strdup(value));

                        if (field->type_t == FIELD_TEXT_MULTI) {
                            GString *ac_val = g_string_new("");
                            g_string_printf(ac_val, "val%d", value_index++);
                            autocomplete_add(field->value_ac, ac_val->str);
                            g_string_free(ac_val, TRUE);
                        }
                        if (field->type_t == FIELD_JID_MULTI) {
                            autocomplete_add(field->value_ac, value);
                        }

                        xmpp_free(ctx, value);
                    }

                // handle options
                } else if (g_strcmp0(child_name, "option") == 0) {
                    FormOption *option = malloc(sizeof(FormOption));
                    option->label = _get_attr(field_child, "label");
                    option->value = _get_property(field_child, "value");

                    if ((field->type_t == FIELD_LIST_SINGLE) || (field->type_t == FIELD_LIST_MULTI)) {
                        autocomplete_add(field->value_ac, option->value);
                    }

                    field->options = g_slist_append(field->options, option);
                }

                field_child = xmpp_stanza_get_next(field_child);
            }

            form->fields = g_slist_append(form->fields, field);
        }

        form_child = xmpp_stanza_get_next(form_child);
    }

    return form;
}
int pv_get_property(const struct physical_volume *pv,
		    struct lvm_property_type *prop)
{
	return _get_property(pv, prop, PVS | LABEL);
}
int vg_get_property(const struct volume_group *vg,
		    struct lvm_property_type *prop)
{
	return _get_property(vg, prop, VGS);
}
int lv_get_property(const struct logical_volume *lv,
		    struct lvm_property_type *prop)
{
	return _get_property(lv, prop, LVS);
}
Exemplo n.º 6
0
int pvseg_get_property(const struct pv_segment *pvseg,
                       struct lvm_property_type *prop)
{
    return _get_property(pvseg, prop, PVSEGS);
}
Exemplo n.º 7
0
int lvseg_get_property(const struct lv_segment *lvseg,
                       struct lvm_property_type *prop)
{
    return _get_property(lvseg, prop, SEGS);
}