summaryrefslogtreecommitdiff
path: root/setting/src/email-setting-utils.c
blob: e637358ae050a5496dcc610075c8bd1be623e3b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "email-setting.h"
#include "email-setting-utils.h"
#include "email-view-manual-setup.h"
#include "email-view-account-setup.h"
#include "email-view-account-edit.h"
#include "email-view-sp-select.h"
#include "email-view-sync-schedule.h"
#include "email-view-sync-setup.h"
#include "stdarg.h"


Evas_Object *setting_get_notify(struct viewdata *vd, char *header,
		char *content, int btn_num, char *btn1_lb, popup_cb resp_cb1,
		char *btn2_lb, popup_cb resp_cb2)
{
	debug_log("");

	Evas_Object *notify;

	notify = elm_popup_add(vd->ugd->win);
	if (!notify) {
		debug_log("elm_popup_add returns NULL");
		return NULL;
	}
	evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	if (header) {
		elm_object_part_text_set(notify, "title,text", header);
	}

	if (content) {
		elm_object_text_set(notify, content);
	}

	if (btn_num == 1) {
		Evas_Object *btn1 = elm_button_add(notify);
		elm_object_style_set(btn1, "popup_button/default");
		elm_object_text_set(btn1, btn1_lb);
		elm_object_part_content_set(notify, "button1", btn1);
		evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd);
	}
	if (btn_num == 2) {
		Evas_Object *btn1 = elm_button_add(notify);
		elm_object_style_set(btn1, "popup_button/default");
		elm_object_text_set(btn1, btn1_lb);
		elm_object_part_content_set(notify, "button1", btn1);
		evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd);

		Evas_Object *btn2 = elm_button_add(notify);
		elm_object_style_set(btn2, "popup_button/default");
		elm_object_text_set(btn2, btn2_lb);
		elm_object_part_content_set(notify, "button2", btn2);
		evas_object_smart_callback_add(btn2, "clicked", resp_cb2, vd);
	}

	evas_object_show(notify);

	return notify;
}

Evas_Object *setting_get_pb_notify(struct viewdata *vd, char *header,
		int btn_num, char *btn1_lb, popup_cb resp_cb1,
		char *btn2_lb, popup_cb resp_cb2)
{
	debug_log("");

	Evas_Object *notify, *progressbar;

	notify = elm_popup_add(vd->ugd->win);
	if (!notify) {
		debug_log("elm_popup_add returns NULL");
		return NULL;
	}
	evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	if (header) {
		elm_object_part_text_set(notify, "title,text", header);
	}

	progressbar = elm_progressbar_add(notify);
	elm_object_style_set(progressbar, "pending_list");
	elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
	evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
	evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_show(progressbar);
	elm_progressbar_pulse(progressbar, EINA_TRUE);

	elm_object_content_set(notify, progressbar);

	if (btn_num == 1) {
		Evas_Object *btn1 = elm_button_add(notify);
		elm_object_style_set(btn1, "popup_button/default");
		elm_object_text_set(btn1, btn1_lb);
		elm_object_part_content_set(notify, "button1", btn1);
		evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd);
	}
	if (btn_num == 2) {
		Evas_Object *btn1 = elm_button_add(notify);
		elm_object_style_set(btn1, "popup_button/default");
		elm_object_text_set(btn1, btn1_lb);
		elm_object_part_content_set(notify, "button1", btn1);
		evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd);

		Evas_Object *btn2 = elm_button_add(notify);
		elm_object_style_set(btn2, "popup_button/default");
		elm_object_text_set(btn2, btn2_lb);
		elm_object_part_content_set(notify, "button2", btn2);
		evas_object_smart_callback_add(btn2, "clicked", resp_cb2, vd);
	}

	evas_object_show(notify);

	return notify;
}

Evas_Object *setting_get_list_notify(struct viewdata *vd, char *header,
		int btn_num, char *btn1_lb, popup_cb resp_cb1,
		char *btn2_lb, popup_cb resp_cb2, Evas_Object *content)
{
	debug_log("");

	Evas_Object *notify;

	notify = elm_popup_add(vd->ugd->win);
	if (!notify) {
		debug_log("elm_popup_add returns NULL");
		return NULL;
	}
	evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_style_set(notify, "menustyle");

	if (header) {
		elm_object_part_text_set(notify, "title,text", header);
	}

	if (btn_num == 1) {
		Evas_Object *btn1 = elm_button_add(notify);
		elm_object_style_set(btn1, "popup_button/default");
		elm_object_text_set(btn1, btn1_lb);
		elm_object_part_content_set(notify, "button1", btn1);
		evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd);
	}

	if (btn_num == 2) {
		Evas_Object *btn1 = elm_button_add(notify);
		elm_object_style_set(btn1, "popup_button/default");
		elm_object_text_set(btn1, btn1_lb);
		elm_object_part_content_set(notify, "button1", btn1);
		evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd);

		Evas_Object *btn2 = elm_button_add(notify);
		elm_object_style_set(btn2, "popup_button/default");
		elm_object_text_set(btn2, btn2_lb);
		elm_object_part_content_set(notify, "button2", btn2);
		evas_object_smart_callback_add(btn2, "clicked", resp_cb2, vd);
	}

	elm_object_content_set(notify, content);
	evas_object_show(notify);

	return notify;
}

Evas_Object *setting_get_small_notify(struct viewdata *vd, char *label)
{
	debug_log("");

	EmailSettingUGD *ugd = vd->ugd;

	if (ugd->small_noti) {
		evas_object_del(ugd->small_noti);
		ugd->small_noti = NULL;
	}

	if (ugd->small_noti_ly) {
		evas_object_del(ugd->small_noti_ly);
		ugd->small_noti_ly = NULL;
	}

	ugd->small_noti = elm_notify_add(ugd->layout_main);
	elm_notify_orient_set(ugd->small_noti, ELM_NOTIFY_ORIENT_BOTTOM);
	ugd->small_noti_ly = elm_layout_add(ugd->layout_main);
	elm_layout_theme_set(ugd->small_noti_ly, "standard", "selectioninfo", "vertical/bottom_64");
	elm_object_content_set(ugd->small_noti, ugd->small_noti_ly);
	char text[128] = {0,};
	snprintf(text, sizeof(text), "%s", label);
	edje_object_part_text_set(elm_layout_edje_get(ugd->small_noti_ly), "elm.text", text);
	elm_notify_timeout_set(ugd->small_noti, 2);
	evas_object_show(ugd->small_noti);

	return ugd->small_noti;
}

Evas_Object *setting_add_inner_layout(struct viewdata *vd)
{
	debug_log("");

	if (vd == NULL) {
		debug_log("vd == NULL");
		return NULL;
	}

	Evas_Object *ly = NULL;

	if (vd->ly == NULL) {
		debug_log("vd->ly == NULL");
		return NULL;
	}

	ly = elm_layout_add(vd->ugd->navi_bar);
	elm_layout_theme_set(ly, "layout", "application", "noindicator");
	evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

	return ly;
}

gboolean setting_get_validation(char *email_addr)
{
	debug_log("");
	int count_at = 0, i = 0;

	setting_delete_enter(email_addr);
	debug_log("email address is %s", email_addr);

	for (i = 0; email_addr[i]; i++) {
		if (email_addr[i] == '.' ||
			(email_addr[i] >= '0' && email_addr[i] <= '9') ||
			(email_addr[i] >= 'A' && email_addr[i] <= 'Z') ||
			(email_addr[i] >= 'a' && email_addr[i] <= 'z')) {
			debug_log("Valide ID %c", email_addr[i]);
		} else if (email_addr[i] == '@') {
			count_at++;
			if (count_at > 1) {
				debug_log("Invalid ID: '@' occurance more than once");
				return FALSE;
			}
		} else {
			debug_log("Invalid ID: Special character present");
			return FALSE;
		}

	}

	if (count_at != 1) {
		debug_log("Invalid ID: '@' not present");
		return FALSE;
	}

	return TRUE;
}

gboolean setting_new_acct_init(struct viewdata *vd)
{
	debug_log("");
	retv_if(vd == NULL, FALSE);
	EmailSettingUGD *ugd = vd->ugd;

	ugd->new_account = NULL;
	ugd->new_account = malloc(sizeof(email_account_t));
	if (!ugd->new_account)
		return FALSE;
	memset(ugd->new_account, 0x00, sizeof(email_account_t));

	return TRUE;

}

gboolean setting_new_acct_final(struct viewdata *vd)
{
	debug_log("");
	int r = 0;

	retv_if(vd == NULL, FALSE);
	EmailSettingUGD *ugd = vd->ugd;

	if (ugd->new_account != NULL) {
		r = email_engine_free_account_list(&(ugd->new_account), 1);
		retv_if(r == FALSE, FALSE);
	}
	ugd->new_account = NULL;
	return TRUE;
}

gboolean setting_update_acct_list(struct viewdata *vd)
{
	debug_log("");
	int r = 0;

	retv_if(vd == NULL, FALSE);
	EmailSettingUGD *ugd = vd->ugd;

	if (ugd->account_list != NULL) {
		r = email_engine_free_account_list(&(ugd->account_list), ugd->account_count);
		retv_if(r == FALSE, FALSE);
	}

	ugd->account_list = NULL;
	r = email_engine_get_account_list(&(ugd->account_count), &(ugd->account_list));
	retv_if(r == FALSE, FALSE);

	return TRUE;
}

gboolean setting_get_acct_full_data(int acctid, email_account_t **_account)
{
	debug_log("");
	int r = 0;

	if (*_account != NULL) {
		r = email_engine_free_account_list(_account, 1);
		retv_if(r == FALSE, FALSE);
	}
	*_account = NULL;
	r = email_engine_get_account_full_data(acctid, _account);
	retv_if(r == FALSE, FALSE);

	return TRUE;
}

void setting_edbus_event_receive(void *local_data, DBusMessage *message)
{
	debug_log("");

	DBusError error;
	EmailSettingUGD *ugd = (EmailSettingUGD *)local_data;
	RETURN_IF_FAIL(ugd != NULL);

	if (dbus_message_is_signal(message, "User.Email.StorageChange", "email")) {
		debug_log("User.Email.StorageChange");

		int subtype = 0;
		int data1 = 0;
		int data2 = 0;
		char *data3 = NULL;
		dbus_error_init(&error);

		if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
			DBUS_TYPE_INT32, &data1, DBUS_TYPE_INT32, &data2,
			DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID)) {
			debug_log("subtype: %d, data1: %d, data2: %d, date3: %s", subtype, data1, data2, data3);

			switch (subtype) {
			case NOTI_ACCOUNT_ADD:
				debug_log("account added");
				if (g_strcmp0(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP) == 0) {

					if (ugd->account_info >= HOTMAIL && ugd->account_info <= OTHERS) {
						if (!ugd->start_account_validation) {
							ug_destroy_me(ugd->ug);
						}
					} else {
						ug_destroy_me(ugd->ug);
					}
				} else {
					if (ugd->b_on_pause) {
						setting_refresh_view(ugd);
					}
				}

				break;

			case NOTI_ACCOUNT_UPDATE:
				debug_log("account updated");
				if (ugd->b_on_pause) {
					setting_refresh_view(ugd);
				}
				break;

			case NOTI_ACCOUNT_DELETE:
				if (ugd->b_on_pause) {
					debug_log("account deleted during pause status");
					setting_refresh_view(ugd);
				}

				break;

			default:
				debug_warning("unknown type");
				break;
			}
		} else {
			debug_critical("receive data error: %s", error.message);
			dbus_error_free(&error);
		}
	} else if (dbus_message_is_signal(message, "User.Email.NetworkStatus", "email")) {
		debug_log("User.Email.NetworkStatus");

		int subtype = 0;
		int data1 = 0;
		char *data2 = NULL;
		int data3 = 0;
		int data4 = 0;
		char *type = NULL;

		dbus_error_init(&error);

		if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype,
			DBUS_TYPE_INT32, &data1, DBUS_TYPE_STRING, &data2,
			DBUS_TYPE_INT32, &data3, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID)) {
			debug_log("subtype: %d, data1: %d, data2: %s, data3: %d, data4: %d", subtype, data1, data2, data3, data4);
			struct viewdata *vd;
			Viewtype top;

			switch (subtype) {
			case NOTI_VALIDATE_ACCOUNT_FINISH:
				/* Validation Success */
				debug_log("Validation Success");
				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					debug_log("Account edit view will be called");
					setting_edit_validation_success_cb(ugd);
				}
				break;

			case NOTI_VALIDATE_ACCOUNT_FAIL:
				/* Validation Failed */
				debug_log("validation failed");
				ugd->err_code = data4;
				type = setting_get_service_fail_type(ugd->err_code);
				debug_log("%s", type);
				g_free(type);

				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					debug_log("Account edit view will be called");
					setting_edit_validation_failed_cb(ugd, FALSE);
				}
				break;

			case NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FINISH:
				debug_log("validation_and_update finish");
				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					debug_log("Account edit view will be called");
					setting_edit_validation_success_cb(ugd);
				}
				break;

			case NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FAIL:
				debug_log("validation_and_update fail");

				/*if (ugd->handle != data3) {
					debug_log("handle is different");
					break;
				}*/

				ugd->err_code = data4;
				type = setting_get_service_fail_type(ugd->err_code);
				debug_log("%s", type);
				g_free(type);

				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					debug_log("Account edit view will be called");
					setting_edit_validation_failed_cb(ugd, FALSE);
				}
				break;

			case NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL:
				debug_log("validation_and_update cancel");

				/*if (ugd->handle != data3) {
					debug_log("handle is different");
					break;
				}*/

				ugd->err_code = data4;
				type = setting_get_service_fail_type(ugd->err_code);
				debug_log("%s", type);
				g_free(type);

				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					debug_log("Account edit view will be called");
					setting_edit_validation_failed_cb(ugd, TRUE);
				}
				break;

			case NOTI_VALIDATE_AND_CREATE_ACCOUNT_FINISH:
				debug_log("validation_and_create finish");
				ugd->account_id = data1;

				if (ugd->b_on_pause) {
					debug_log("account added during pause status");
					if (g_strcmp0(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP) != 0) {
						setting_refresh_view(ugd);
					}
				}

				if (!ugd->start_account_validation) {
					break;
				}
				ugd->start_account_validation = 0;

				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					if (ugd->manual_setup == 1 && ugd->wds_account_creation != 1) {
						debug_log("Server type view will be called");
						setting_manual_validation_success_cb(ugd);
					} else {
						debug_log("Other account view will be called");
						setting_account_validation_success_cb(ugd);
					}
				}
				break;

			case NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL:
				debug_log("validation_and_create faild");

				if (ugd->handle != data3) {
					debug_log("handle is different");
					break;
				}

				if (!ugd->start_account_validation) {
					break;
				}
				ugd->start_account_validation = 0;

				ugd->err_code = data4;
				type = setting_get_service_fail_type(ugd->err_code);
				debug_log("%s", type);
				g_free(type);

				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					if (ugd->manual_setup == 1 && ugd->wds_account_creation != 1) {
						debug_log("Server type view will be called");
						setting_manual_validation_failed_cb(ugd, FALSE);
					} else {
						debug_log("Other account view will be called");
						setting_account_validation_failed_cb(ugd, FALSE);
					}
				}
				break;

			case NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL:
				debug_log("validation_and_create cancel");

				if (ugd->handle != data3) {
					debug_log("handle is different");
					break;
				}

				if (!ugd->start_account_validation) {
					break;
				}
				ugd->start_account_validation = 0;

				ugd->err_code = data4;
				type = setting_get_service_fail_type(ugd->err_code);
				debug_log("%s", type);
				g_free(type);

				if (ugd->end_key_event != 1 && ugd->cancel_event != 1) {
					if (ugd->manual_setup == 1 && ugd->wds_account_creation != 1) {
						debug_log("Server type view will be called");
						setting_manual_validation_failed_cb(ugd, TRUE);
					} else {
						debug_log("Other account view will be called");
						setting_account_validation_failed_cb(ugd, TRUE);
					}
				}
				break;

			case NOTI_DOWNLOAD_START:
				top = ugd->view_st[ugd->view_top];
				vd = ugd->vd[top];
				if (vd->type == VIEW_SYNC_SETUP)
					setting_setup_sync_started(vd, (int)data1);
				else if (vd->type == VIEW_SYNC_SCHEDULE)
					setting_schedule_sync_started(vd, (int)data1);
				break;
			case NOTI_DOWNLOAD_FINISH:
			case NOTI_DOWNLOAD_FAIL:
			case NOTI_DOWNLOAD_CANCEL:
				top = ugd->view_st[ugd->view_top];
				vd = ugd->vd[top];
				if (vd->type == VIEW_SYNC_SETUP)
					setting_setup_sync_finished(vd, (int)data1);
				else if (vd->type == VIEW_SYNC_SCHEDULE)
					setting_schedule_sync_finished(vd, (int)data1);
				break;

			default:
				debug_warning("unknown type");
				break;
			}
		} else {
			debug_critical("receive data error: %s", error.message);
			dbus_error_free(&error);
		}
	} else {
		debug_warning("We receive dbus message, but we can't do anything");
	}
}

void setting_delete_enter(char *string)
{
	debug_log("");
	int i = 0;

	for (i = 0; string[i]; i++) {
		if (string[i] == 10) {
			debug_log("find enter %d", i);
			string[i] = 32;
		}
	}
}

char *setting_get_service_fail_type(int type)
{
	debug_log("");

	char *ret = NULL;
	char str[MAX_STR_LEN] = { 0, };

	if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) {
		ret = _("IDS_EMAIL_POP_NETWORK_BUSY");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) {
		snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15);
		return strdup(str);
	} else if (type == EMAIL_ERROR_CONNECTION_FAILURE) {
		ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_LOGIN_FAILURE) {
		ret = _("IDS_EMAIL_POP_INCORRECT_USER_NAME_OR_PASSWORD");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_AUTHENTICATE) {
		ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_CANCELLED) {
		ret = _("IDS_EMAIL_POP_DOWNLOAD_CANCELLED");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) {
		ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_NO_SUCH_HOST) {
		ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_INVALID_SERVER) {
		ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) {
		ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_NETWORK_NOT_AVAILABLE) {
		ret = N_("Network not available");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_SECURED_STORAGE_FAILURE) {
		ret = N_("Secure storage failure");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_TOO_MANY_LOGIN_FAILURE) {
		ret = N_("Too many login failure");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) {
		ret = N_("Failed by security policy");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_VALIDATE_ACCOUNT) {
		ret = N_("Validate account failure");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_FLIGHT_MODE) {
		ret = N_("Flight mode enabled");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_NO_SIM_INSERTED) {
		ret = N_("No SIM inserted");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_AUTH_REQUIRED) {
		ret = N_("Authentication required");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_SYSTEM_FAILURE) {
		ret = N_("Sytem failure");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_CANCELLED) {
		ret = N_("Canceled by user");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_CERTIFICATE_FAILURE) {
		ret = N_("Certificate failure");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_AUTH_NOT_SUPPORTED) {
		ret = N_("Authentication not supported");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_NO_RESPONSE) {
		ret = N_("No server response");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_DISCONNECTED) {
		ret = N_("Connection disconnected");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_CONNECTION_BROKEN) {
		ret = N_("Connection was broken");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_SOCKET_FAILURE) {
		ret = N_("Socket operation failed");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_DB_FAILURE) {
		ret = N_("DB operation failed");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_ALREADY_EXISTS) {
		ret = N_("Already exists");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_TLS_NOT_SUPPORTED) {
		ret = N_("Server not support TLS");
		return strdup(ret);
	} else if (type == EMAIL_ERROR_TLS_SSL_FAILURE) {
		ret = N_("TLS/SSL failure");
		return strdup(ret);
	} else {
		snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_INTERNAL_ERROR"), type);
		return strdup(str);
	}
}

/* EOF */