00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00030 #include "config.h"
00031
00032 #include <string.h>
00033
00034 #include <glib.h>
00035 #include "duifield-hash.h"
00036 #include "duifield.h"
00037 #include "duiresolver.h"
00038 #include "interface.h"
00039 #include "perr.h"
00040
00041 struct hash_s
00042 {
00043 DuiInterface *hash_table_root;
00044 };
00045
00046
00047
00048 static void
00049 hash_field_clear (DuiField *f)
00050 {
00051 g_free (f->fieldname);
00052 f->type = DUI_FIELD_NONE;
00053 }
00054
00055
00056
00057 static const gchar *
00058 get_hash_key_value (DuiField *fs)
00059 {
00060 const gchar * fieldval = NULL;
00061 struct hash_s * gf = (struct hash_s*) get_gobj_field (fs);
00062
00063 fieldval = dui_interface_kvp_lookup (gf->hash_table_root,
00064 fs->fieldname);
00065 return fieldval;
00066 }
00067
00068 static void
00069 set_hash_key_value (DuiField *fs, const gchar *val)
00070 {
00071 struct hash_s * gf = (struct hash_s*) get_gobj_field (fs);
00072 dui_interface_kvp_insert (gf->hash_table_root,
00073 fs->fieldname, val);
00074 }
00075
00076
00077
00078 void
00079 dui_field_set_hash_key (DuiField *fs, const gchar * key)
00080 {
00081 fs->type = DUI_FIELD_HASH_KEY;
00082 fs->fieldname = g_strdup (key);
00083
00084 fs->get_field_value = get_hash_key_value;
00085 fs->set_field_value = set_hash_key_value;
00086 fs->clear_field = hash_field_clear;
00087 }
00088
00089
00090
00091 void
00092 dui_resolver_resolve_hash (DuiResolver *res , DuiInterface *rot)
00093 {
00094 GList *node;
00095 struct hash_s * gf;
00096
00097 for (node = res->field_list; node; node=node->next)
00098 {
00099 DuiField *fld = node->data;
00100 if (!DUI_FIELD_IS_TYPE(fld,DUI_FIELD_HASH_KEY)) continue;
00101 gf = (struct hash_s*) get_gobj_field (fld);
00102 gf->hash_table_root = rot;
00103 }
00104 }
00105
00106