diff options
author | Sivaiah Nallagatla <snallagatla@novell.com> | 2004-04-03 08:59:28 +0000 |
---|---|---|
committer | Sivaiah Nallagatla <siva@src.gnome.org> | 2004-04-03 08:59:28 +0000 |
commit | 961b5ffa82c3d627fff8a9c9c737cf578ae1e886 (patch) | |
tree | 9c78562df69374fd077b0568ed08ad4afbe65a58 | |
parent | d7c4d34917c7269436df82d856c94238c4a329f4 (diff) | |
download | evolution-data-server-961b5ffa82c3d627fff8a9c9c737cf578ae1e886.tar.gz |
changed implementation to take care of nested filter condtions. added new
2004-04-03 Sivaiah Nallagatla <snallagatla@novell.com>
* e-gw-filter.[ch] : changed implementation to take care of nested filter
condtions. added new e_gw_filter_group_condtions api
-rw-r--r-- | servers/groupwise/ChangeLog | 5 | ||||
-rw-r--r-- | servers/groupwise/e-gw-filter.c | 134 | ||||
-rw-r--r-- | servers/groupwise/e-gw-filter.h | 2 |
3 files changed, 98 insertions, 43 deletions
diff --git a/servers/groupwise/ChangeLog b/servers/groupwise/ChangeLog index 9c24155ad..b463b98af 100644 --- a/servers/groupwise/ChangeLog +++ b/servers/groupwise/ChangeLog @@ -1,3 +1,8 @@ +2004-04-03 Sivaiah Nallagatla <snallagatla@novell.com> + + * e-gw-filter.[ch] : changed implementation to take care of nested filter + condtions. added new e_gw_filter_group_condtions api + 2004-04-02 Sivaiah Nallagatla <snallagatla@novell.com> * e-gw-message.c (e_gw_message_write_string-parameter_with_attribute) : diff --git a/servers/groupwise/e-gw-filter.c b/servers/groupwise/e-gw-filter.c index 0660324ed..5e2d13f1e 100644 --- a/servers/groupwise/e-gw-filter.c +++ b/servers/groupwise/e-gw-filter.c @@ -34,6 +34,7 @@ struct _FilterComponent { int operation; char *field_name; char *field_value; + int num_of_conditions; }; typedef struct _FilterComponent FilterComponent; @@ -46,13 +47,6 @@ struct _EGwFilterPrivate { -void -e_gw_filter_group_type (EGwFilter *filter, int all_or_any) -{ - g_return_if_fail (E_IS_GW_FILTER (filter)); - filter->priv->filter_group_type = all_or_any; -} - void e_gw_filter_add_filter_component (EGwFilter *filter, EGwFilterOpType operation, const char *field_name, const char *field_value) { @@ -66,43 +60,37 @@ e_gw_filter_add_filter_component (EGwFilter *filter, EGwFilterOpType operation, component->operation = operation; component->field_name = g_strdup (field_name); component->field_value = g_strdup (field_value); - - filter->priv->component_list = g_slist_append (filter->priv->component_list, component); + filter->priv->component_list = g_slist_prepend (filter->priv->component_list, component); } void -e_gw_filter_append_to_soap_message (EGwFilter *filter, SoupSoapMessage *msg) +e_gw_filter_group_conditions (EGwFilter *filter, EGwFilterOpType operation, int num_of_condtions) { - EGwFilterPrivate *priv; - GSList *component_list; + FilterComponent *component; + + g_return_if_fail (E_IS_GW_FILTER (filter)); + g_return_if_fail ( operation == E_GW_FILTER_OP_AND || operation == E_GW_FILTER_OP_OR || + operation == E_GW_FILTER_OP_NOT); + component = g_new0 (FilterComponent, 1); + component->operation = operation; + component->num_of_conditions = num_of_condtions; + filter->priv->component_list = g_slist_prepend (filter->priv->component_list, component); +} + +static void +append_child_component (FilterComponent* filter_component, SoupSoapMessage *msg) +{ + char *operation_name; - FilterComponent *filter_component; - g_return_if_fail (E_IS_GW_FILTER (filter)); g_return_if_fail (SOUP_IS_SOAP_MESSAGE (msg)); - - priv = filter->priv; - component_list = priv->component_list; - - soup_soap_message_start_element (msg, "filter", NULL, NULL); + soup_soap_message_start_element (msg, "element", NULL, NULL); + operation_name = NULL; - if (g_slist_length(component_list) > 1) { - soup_soap_message_start_element (msg, "element", NULL, NULL); - if (priv->filter_group_type == E_GW_FILTER_OP_AND) - e_gw_message_write_string_parameter (msg, "op", NULL, "and"); - else - e_gw_message_write_string_parameter (msg, "op", NULL, "or"); - } - - for (; component_list != NULL; component_list = g_slist_next (component_list)) { - soup_soap_message_start_element (msg, "element", NULL, NULL); - filter_component = (FilterComponent *)component_list->data; - operation_name = NULL; - - switch (filter_component->operation) { + switch (filter_component->operation) { - case E_GW_FILTER_OP_EQUAL : + case E_GW_FILTER_OP_EQUAL : operation_name = "eq"; break; case E_GW_FILTER_OP_NOTEQUAL : @@ -135,22 +123,84 @@ e_gw_filter_append_to_soap_message (EGwFilter *filter, SoupSoapMessage *msg) case E_GW_FILTER_OP_NOTEXISTS : operation_name = "notExist"; break; - - - } - - if (operation_name != NULL) { + + } + + + if (operation_name != NULL) { + e_gw_message_write_string_parameter (msg, "op", NULL, operation_name); e_gw_message_write_string_parameter (msg, "field", NULL, filter_component->field_name); e_gw_message_write_string_parameter (msg, "value", NULL, filter_component->field_value); + } + + soup_soap_message_end_element (msg); +} + + + +static GSList* +append_complex_component (GSList *component_list, SoupSoapMessage *msg) +{ + FilterComponent *filter_component; + int num_of_condtions; + int i; + + filter_component = (FilterComponent* )component_list->data; + if (filter_component->operation == E_GW_FILTER_OP_AND || filter_component->operation == E_GW_FILTER_OP_OR + || filter_component->operation == E_GW_FILTER_OP_NOT ) { + + soup_soap_message_start_element (msg, "element", NULL, NULL); + if (filter_component->operation == E_GW_FILTER_OP_AND) + e_gw_message_write_string_parameter (msg, "op", NULL, "and"); + else if (filter_component->operation == E_GW_FILTER_OP_OR) + e_gw_message_write_string_parameter (msg, "op", NULL, "or"); + else + e_gw_message_write_string_parameter (msg, "op", NULL, "not"); + } + num_of_condtions = filter_component->num_of_conditions; + for ( i = 0; i < num_of_condtions && component_list; i++) { + component_list = g_slist_next (component_list); + filter_component = (FilterComponent *)component_list->data; + if (filter_component->operation == E_GW_FILTER_OP_AND || filter_component->operation == E_GW_FILTER_OP_OR + || filter_component->operation == E_GW_FILTER_OP_NOT ) { + component_list = append_complex_component (component_list, msg); } - soup_soap_message_end_element (msg); + else + append_child_component (filter_component, msg); + + } - if (g_slist_length (component_list) > 1) - soup_soap_message_end_element (msg); + soup_soap_message_end_element (msg); + + return component_list; +} +void +e_gw_filter_append_to_soap_message (EGwFilter *filter, SoupSoapMessage *msg) +{ + EGwFilterPrivate *priv; + GSList *component_list; + FilterComponent *filter_component; + + g_return_if_fail (E_IS_GW_FILTER (filter)); + g_return_if_fail (SOUP_IS_SOAP_MESSAGE (msg)); + + priv = filter->priv; + component_list = priv->component_list; + + soup_soap_message_start_element (msg, "filter", NULL, NULL); + for (; component_list != NULL; component_list = g_slist_next (component_list)) { + filter_component = (FilterComponent *) (component_list->data); + if (filter_component->operation == E_GW_FILTER_OP_AND || filter_component->operation == E_GW_FILTER_OP_OR + || filter_component->operation == E_GW_FILTER_OP_NOT) { + component_list = append_complex_component (component_list, msg); + } + else + append_child_component (filter_component, msg); soup_soap_message_end_element (msg); //end filter + } } static void diff --git a/servers/groupwise/e-gw-filter.h b/servers/groupwise/e-gw-filter.h index 2dcc49491..8947f392d 100644 --- a/servers/groupwise/e-gw-filter.h +++ b/servers/groupwise/e-gw-filter.h @@ -70,9 +70,9 @@ struct _EGwFilterClass { GType e_gw_filter_get_type (void); EGwFilter* e_gw_filter_new(void); -void e_gw_filter_group_type (EGwFilter *filter, int all_or_any); void e_gw_filter_add_filter_component (EGwFilter *filter, EGwFilterOpType operation, const char *field_name, const char *field_value); void e_gw_filter_append_to_soap_message (EGwFilter *filter, SoupSoapMessage *msg); +void e_gw_filter_group_conditions (EGwFilter *filter, EGwFilterOpType operation, int num_of_condtions); G_END_DECLS |