#define AUTO_DOWNLOAD_QUEUE_MAX 100
static void* worker_auto_download_queue(void *arg);
+static gint auto_download_compare_func(gconstpointer a, gconstpointer b, gpointer user_data);
INTERNAL_FUNC int emcore_start_auto_download_loop(int *err_code)
{
EM_DEBUG_EXCEPTION("auto download que is full...");
error = EMAIL_ERROR_EVENT_QUEUE_FULL;
ret = false;
- } else if (event_data->status == EMAIL_EVENT_STATUS_DIRECT) {
- event_data->status = EMAIL_EVENT_STATUS_WAIT;
- g_queue_push_head(g_auto_download_que, event_data);
- //WAKE_CONDITION_VARIABLE(_auto_downalod_available_signal);
- ret = true;
} else {
event_data->status = EMAIL_EVENT_STATUS_WAIT;
- g_queue_push_tail(g_auto_download_que, event_data);
+ g_queue_insert_sorted(g_auto_download_que, event_data, auto_download_compare_func, event_data);
//WAKE_CONDITION_VARIABLE(_auto_downalod_available_signal);
ret = true;
}
}
activity->activity_id = activity_list[di].activity_id;
- activity->status = 0;
+ activity->status = EMAIL_EVENT_STATUS_DIRECT;
activity->account_id = activity_list[di].account_id;
activity->mail_id = activity_list[di].mail_id;
activity->server_mail_id = activity_list[di].server_mail_id;
return ret;
}
-
+static gint auto_download_compare_func(gconstpointer a, gconstpointer b, gpointer user_data)
+{
+ email_event_auto_download *first = (email_event_auto_download*)a;
+ email_event_auto_download *second = (email_event_auto_download*)b;
+ if (first->server_mail_id == second->server_mail_id) return 0;
+ else if (first->server_mail_id > second->server_mail_id) return -1;
+ else return 1;
+ return 1;
+}