Fix favourites box count bug(N_SE-28207)
authorKim Jinho <jinho912.kim@samsung.com>
Tue, 12 Mar 2013 11:37:43 +0000 (20:37 +0900)
committerKim Jinho <jinho912.kim@samsung.com>
Tue, 12 Mar 2013 11:37:43 +0000 (20:37 +0900)
account/src/email-account-folder.c

index cebe64b..5e607f2 100755 (executable)
@@ -109,6 +109,8 @@ static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info);
 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
 
+static int _folder_get_favourite_mail_count(bool unread_only);
+
 //static void _changed_cb(void *data, Evas_Object *obj, void *event_info);
 //static void _focused_cb(void *data, Evas_Object *obj, void *event_info);
 //static void _unfocused_cb(void *data, Evas_Object *obj, void *event_info);
@@ -601,12 +603,7 @@ void _create_folder_view(EmailAccountUGD *ug_data)
                                                        ug_data->all_acc_unread_count[ACC_MAILBOX_TYPE_OUTBOX] += mailbox_list[j].unread_count;
                                                }
                                                        break;
-                                               case EMAIL_MAILBOX_TYPE_FLAGGED:
-                                               {
-                                                       ug_data->all_acc_read_count[ACC_MAILBOX_TYPE_FLAGGED] += mailbox_list[j].total_mail_count_on_local;
-                                                       ug_data->all_acc_unread_count[ACC_MAILBOX_TYPE_FLAGGED] += mailbox_list[j].unread_count;
-                                               }
-                                                       break;
+
                                                default:
                                                        break;
                                        }
@@ -616,6 +613,9 @@ void _create_folder_view(EmailAccountUGD *ug_data)
                        _make_folder_tree(alist + i, ug_data);
                }
 
+               ug_data->all_acc_read_count[ACC_MAILBOX_TYPE_FLAGGED] = _folder_get_favourite_mail_count(false);
+               ug_data->all_acc_unread_count[ACC_MAILBOX_TYPE_FLAGGED] = _folder_get_favourite_mail_count(true);
+
                ug_data->alist = alist;
        }
        else
@@ -3728,6 +3728,53 @@ static gboolean _folder_item_dim_state_get(email_mailbox_t *mlist, int folder_mo
 
        return FALSE;
 }
+static int _folder_get_favourite_mail_count(bool unread_only)
+{
+       debug_enter();
+
+       email_mail_list_item_t *mail_list = NULL;
+       email_list_filter_t *filter_list = NULL;
+       int cnt_filter_list = 1;
+       int mail_count = 0;
+       int err = 0;
+       int i = 0;
+
+       if(unread_only)
+               cnt_filter_list = cnt_filter_list + 2;
+
+       filter_list = malloc(sizeof(email_list_filter_t) * cnt_filter_list);
+       memset(filter_list, 0, sizeof(email_list_filter_t) * cnt_filter_list);
+
+       filter_list[i].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
+       filter_list[i].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD;
+       filter_list[i].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
+       filter_list[i].list_filter_item.rule.key_value.integer_type_value = 1;
+       i++;
+
+       if(unread_only) {
+               filter_list[i].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_OPERATOR;
+               filter_list[i].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_AND;
+               i++;
+
+               filter_list[i].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
+               filter_list[i].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD;
+               filter_list[i].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
+               filter_list[i].list_filter_item.rule.key_value.integer_type_value = 0;
+               i++;
+
+       }
+
+       err = email_get_mail_list_ex(filter_list, cnt_filter_list, NULL, 0, -1, -1, &mail_list, &mail_count);
+       if (err != EMAIL_ERROR_NONE)
+               debug_warning("email_get_mail_list_ex - err (%d)", err);
+
+       email_free_list_filter(&filter_list, cnt_filter_list);
+
+       debug_warning("mail_count(%d)", mail_count);
+       FREE(mail_list);
+
+       return mail_count;
+}
 
 // Codes for removing elm_editfield : START
 /*