00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #include "config.h"
00029
00030 #ifdef HAVE_QOF
00031
00032 #include "parse-qof.h"
00033 #include "perr.h"
00034 #include "duifield-qof.h"
00035 #include "duifield.h"
00036 #include "parse-utils.h"
00037 #include "readfile.h"
00038
00039
00042 struct DwiQofParseCtxt_s
00043 {
00044 };
00045
00046
00047
00048 static gboolean
00049 qof_field_handler (gpointer self, DuiField *fld,
00050 const gchar * row_context, const char **attrs)
00051 {
00052 DwiQofParseCtxt G_GNUC_UNUSED *ctx = self;
00053 const char * property=NULL;
00054 gint i;
00055
00056 if (NULL == row_context)
00057 {
00058 SYNTAX ("qof attribute requies an object type to be sepecified using <row>!");
00059 return FALSE;
00060 }
00061
00062 i=0;
00063 while (attrs[i])
00064 {
00065 CASE ("property", property)
00066 {}
00067 i += 2;
00068 }
00069
00071 if (property)
00072 {
00073 dui_field_set_qof (fld, row_context, property);
00074 return TRUE;
00075 }
00076 return FALSE;
00077 }
00078
00079 static DuiParserFieldPlugin *
00080 qof_parser_plugin (DwiQofParseCtxt G_GNUC_UNUSED *ctx)
00081 {
00082 DuiParserFieldPlugin *plg = g_new0 (DuiParserFieldPlugin, 1);
00083
00084 plg->fieldname = "qof";
00085 plg->handler = qof_field_handler;
00086 plg->user_data = ctx;
00087
00088 return plg;
00089 }
00090
00091
00092
00093 static const char *
00094 qof_row_handler (gpointer self, DuiFieldMap *fm, const char **attrs)
00095 {
00096 DwiQofParseCtxt G_GNUC_UNUSED *ctx = self;
00097 const char * qobj_type=NULL;
00098 const char * property=NULL;
00099
00100 int i=0;
00101 while (attrs[i])
00102 {
00103 CASE ("qobject", qobj_type)
00104 CASE ("property", property)
00105 {}
00106 i += 2;
00107 }
00108 if (qobj_type)
00109 {
00110 dui_field_set_qof_match (&fm->target, qobj_type, property);
00111 }
00112 return qobj_type;
00113 }
00114
00115 static DuiParserTablePlugin *
00116 qof_parser_table_plugin (DwiQofParseCtxt *ctx)
00117 {
00118 DuiParserTablePlugin *plg = g_new0 (DuiParserTablePlugin, 1);
00119
00120 plg->plugin_name = "qof_parser";
00121 plg->handler = qof_row_handler;
00122 plg->user_data = ctx;
00123
00124 return plg;
00125 }
00126
00127
00128
00129 DwiQofParseCtxt *
00130 qof_parser_new (DuiParser *par)
00131 {
00132 DuiParserTablePlugin *tbl;
00133 DwiQofParseCtxt *ctx = g_new0 (DwiQofParseCtxt, 1);
00134
00135 DuiParserFieldPlugin *plg = qof_parser_plugin(ctx);
00136 dui_parser_register_field_plugin (par, plg);
00137
00138 tbl = qof_parser_table_plugin (ctx);
00139 dui_parser_register_table_plugin (par, tbl);
00140
00141 return ctx;
00142 }
00143
00144 void
00145 qof_parser_destroy (DwiQofParseCtxt *ctx)
00146 {
00148 g_free (ctx);
00149 }
00150
00151 #endif
00152