summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-10-24 16:46:12 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-10-24 16:46:12 +0900
commit387edc5c45273dbb909f2c1f565c536f9755e9f4 (patch)
tree7b08e049f1c096c170b057b36821e20630eccdf9
parente19fb4a5f4276630b562ccbb55aa9080662f66d4 (diff)
downloademail-service-387edc5c45273dbb909f2c1f565c536f9755e9f4.tar.gz
email-service-387edc5c45273dbb909f2c1f565c536f9755e9f4.tar.bz2
email-service-387edc5c45273dbb909f2c1f565c536f9755e9f4.zip
-rwxr-xr-xCMakeLists.txt2
-rwxr-xr-xTC/TC_email_service/Makefile33
-rwxr-xr-xTC/TC_email_service/TC_Account/Makefile55
-rwxr-xr-xTC/TC_email_service/TC_Account/tslist8
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-add-account-with-validation.c137
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-add-account-with-validation.h29
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-add-account.c147
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-add-account.h35
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-delete-account.c121
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-delete-account.h36
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-free-account.c149
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-free-account.h35
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-get-account-list-refer.h36
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-get-account-list.c128
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-get-account-list.h36
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-get-account-refer.h36
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-get-account.c142
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-get-account.h36
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-update-account.c154
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-update-account.h36
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-validate-account.c155
-rwxr-xr-xTC/TC_email_service/TC_Account/uts-email-validate-account.h35
-rwxr-xr-xTC/TC_email_service/TC_Folder/Makefile51
-rwxr-xr-xTC/TC_email_service/TC_Folder/tslist5
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-add-mailbox.c161
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-add-mailbox.h31
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-delete-mailbox.c138
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-delete-mailbox.h31
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.c148
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.h32
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.c200
-rwxr-xr-xTC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.h34
-rwxr-xr-xTC/TC_email_service/TC_Init/Makefile52
-rwxr-xr-xTC/TC_email_service/TC_Init/tslist6
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-close-db.c63
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-close-db.h32
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-init-storage.c72
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-init-storage.h33
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-open-db.c64
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-open-db.h33
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-ping-service.c68
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-ping-service.h32
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-service-begin.c63
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-service-begin.h33
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-service-end.c66
-rwxr-xr-xTC/TC_email_service/TC_Init/uts-email-service-end.h32
-rw-r--r--TC/TC_email_service/TC_Message/Makefile89
-rwxr-xr-xTC/TC_email_service/TC_Message/tslist22
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-add-attachment.c278
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-add-attachment.h35
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-add-message.c211
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-add-message.h38
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-cancel-send-mail.c121
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-cancel-send-mail.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-clear-mail-data.c90
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-clear-mail-data.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-count-message.c228
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-count-message.h38
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-create-db-full.c137
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-create-db-full.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.c180
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-delete-attachment.c180
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-delete-attachment.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-delete-message.c237
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-delete-message.h38
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-attachment-info.c187
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-attachment-info.h37
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-mail-info.c197
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-mail-info.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-mail-list.c161
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-mail-list.h35
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-mailbox.c168
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-free-mailbox.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-attachment-info.c205
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-attachment-info.h38
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.c104
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-info.c209
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-info.h37
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.c215
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.h38
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-mail-list.h37
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-mailbox-list.c235
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-mailbox-list.h38
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-max-mail-count.c102
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-max-mail-count.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-get-thread-information.h35
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.c249
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.h37
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.c264
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.h38
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-send-retry.c119
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-send-retry.h36
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-update-message.c199
-rwxr-xr-xTC/TC_email_service/TC_Message/uts-email-update-message.h36
-rwxr-xr-xTC/TC_email_service/TC_Network/Makefile56
-rwxr-xr-xTC/TC_email_service/TC_Network/tslist10
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_activate_pdp.c144
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_activate_pdp.h34
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_cancel_job.c144
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_cancel_job.h34
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_deactivate_pdp.c128
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_deactivate_pdp.h34
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_download_attachment.c190
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_download_attachment.h35
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_download_body.c217
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_download_body.h35
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.c152
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.h33
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_get_network_status.c108
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_get_network_status.h31
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_get_pending_job.c169
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_get_pending_job.h35
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_send_mail.c219
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_send_mail.h35
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_send_saved.c184
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_send_saved.h35
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_sync_header.c186
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_sync_header.h35
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.c105
-rwxr-xr-xTC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.h33
-rwxr-xr-xTC/TC_email_service/TC_Rule/Makefile52
-rwxr-xr-xTC/TC_email_service/TC_Rule/tslist6
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-add-rule.c141
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-add-rule.h30
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-delete-rule.c191
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-delete-rule.h30
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-free-rule.c112
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-free-rule.h29
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-get-rule-list.c178
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-get-rule-list.h31
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-get-rule.c169
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-get-rule.h31
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-update-rule.c195
-rwxr-xr-xTC/TC_email_service/TC_Rule/uts-email-update-rule.h31
-rwxr-xr-xTC/TC_email_service/TC_Utility/uts-email-dummy-utility.c169
-rwxr-xr-xTC/TC_email_service/TC_Utility/uts-email-dummy-utility.h33
-rwxr-xr-xTC/TC_email_service/TC_Utility/uts-email-real-utility.c221
-rwxr-xr-xTC/TC_email_service/TC_Utility/uts-email-real-utility.h33
-rwxr-xr-xTC/TC_email_service/_export_env.sh19
-rwxr-xr-xTC/_export_target_env.sh17
-rwxr-xr-xTC/build.sh20
-rwxr-xr-xTC/execute.sh17
-rwxr-xr-xTC/making_new_tet_scen.py70
-rw-r--r--TC/tet_scen61
-rwxr-xr-xTC/tetbuild.cfg25
-rwxr-xr-xTC/tetclean.cfg12
-rwxr-xr-xTC/tetexec.cfg16
-rwxr-xr-xTC/tslist.txt6
-rwxr-xr-xemail-api/doc/email-service_doc.h2
-rwxr-xr-xemail-api/email-api-account.c189
-rwxr-xr-xemail-api/email-api-etc.c51
-rwxr-xr-xemail-api/email-api-init.c41
-rwxr-xr-xemail-api/email-api-mail.c231
-rwxr-xr-xemail-api/email-api-mailbox.c313
-rwxr-xr-xemail-api/email-api-network.c407
-rwxr-xr-xemail-api/email-api-rule.c26
-rwxr-xr-xemail-api/email-api-smime.c134
-rwxr-xr-xemail-api/include/email-api-account.h2
-rwxr-xr-xemail-api/include/email-api-etc.h2
-rwxr-xr-xemail-api/include/email-api-init.h2
-rwxr-xr-xemail-api/include/email-api-mail.h2
-rwxr-xr-xemail-api/include/email-api-mailbox.h2
-rwxr-xr-xemail-api/include/email-api-network.h45
-rwxr-xr-xemail-api/include/email-api-rule.h2
-rwxr-xr-xemail-api/include/email-api-smime.h20
-rwxr-xr-xemail-common-use/email-convert.c260
-rwxr-xr-xemail-common-use/email-utilities.c87
-rwxr-xr-xemail-common-use/include/email-debug-log.h14
-rwxr-xr-xemail-common-use/include/email-errors.h12
-rwxr-xr-xemail-common-use/include/email-internal-types.h141
-rwxr-xr-xemail-common-use/include/email-types.h134
-rwxr-xr-xemail-common-use/include/email-utilities.h6
-rwxr-xr-xemail-core/CMakeLists.txt42
-rwxr-xr-xemail-core/email-core-account.c509
-rwxr-xr-xemail-core/email-core-alarm.c13
-rwxr-xr-xemail-core/email-core-auto-download.c65
-rwxr-xr-xemail-core/email-core-cert.c147
-rw-r--r--email-core/email-core-container.c441
-rwxr-xr-xemail-core/email-core-event.c120
-rwxr-xr-xemail-core/email-core-gmime.c589
-rwxr-xr-xemail-core/email-core-imap-idle.c177
-rwxr-xr-xemail-core/email-core-imap-mailbox.c109
-rwxr-xr-xemail-core/email-core-mail.c2758
-rwxr-xr-xemail-core/email-core-mailbox-sync.c2515
-rwxr-xr-xemail-core/email-core-mailbox.c318
-rwxr-xr-xemail-core/email-core-mime.c5050
-rwxr-xr-xemail-core/email-core-mm-callbacks.c19
-rw-r--r--email-core/email-core-pgp.c132
-rwxr-xr-xemail-core/email-core-signal.c95
-rwxr-xr-xemail-core/email-core-smime.c269
-rwxr-xr-xemail-core/email-core-smtp.c708
-rwxr-xr-xemail-core/email-core-task-manager.c1324
-rwxr-xr-xemail-core/email-core-tasks.c119
-rwxr-xr-xemail-core/email-core-timer.c11
-rwxr-xr-xemail-core/email-core-utils.c980
-rwxr-xr-xemail-core/email-network/email-network.c6
-rwxr-xr-xemail-core/email-storage/email-storage.c2016
-rwxr-xr-xemail-core/email-storage/include/email-storage.h420
-rwxr-xr-xemail-core/include/email-core-account.h32
-rwxr-xr-xemail-core/include/email-core-alarm.h3
-rwxr-xr-xemail-core/include/email-core-auto-download.h5
-rwxr-xr-xemail-core/include/email-core-cert.h4
-rw-r--r--email-core/include/email-core-container.h45
-rwxr-xr-xemail-core/include/email-core-event.h2
-rw-r--r--email-core/include/email-core-gmime.h5
-rwxr-xr-xemail-core/include/email-core-imap-mailbox.h15
-rwxr-xr-xemail-core/include/email-core-mail.h134
-rwxr-xr-xemail-core/include/email-core-mailbox-sync.h35
-rwxr-xr-xemail-core/include/email-core-mailbox.h26
-rwxr-xr-xemail-core/include/email-core-mime.h4
-rwxr-xr-xemail-core/include/email-core-smime.h6
-rwxr-xr-xemail-core/include/email-core-smtp.h24
-rwxr-xr-xemail-core/include/email-core-task-manager.h6
-rwxr-xr-xemail-core/include/email-core-tasks.h5
-rwxr-xr-xemail-core/include/email-core-utils.h53
-rwxr-xr-xemail-daemon/CMakeLists.txt12
-rwxr-xr-xemail-daemon/email-daemon-account.c134
-rwxr-xr-xemail-daemon/email-daemon-auto-poll.c23
-rwxr-xr-xemail-daemon/email-daemon-emn.c8
-rwxr-xr-xemail-daemon/email-daemon-etc.c99
-rwxr-xr-xemail-daemon/email-daemon-event.c459
-rwxr-xr-xemail-daemon/email-daemon-init.c177
-rwxr-xr-xemail-daemon/email-daemon-mail.c352
-rwxr-xr-xemail-daemon/email-daemon-mailbox.c80
-rwxr-xr-xemail-daemon/include/email-daemon-auto-poll.h2
-rwxr-xr-xemail-daemon/include/email-daemon.h108
-rwxr-xr-xemail-daemon/main.c1352
-rwxr-xr-xemail-ipc/CMakeLists.txt2
-rwxr-xr-xemail-ipc/email-activation/email-dbus-activation.c22
-rwxr-xr-xemail-ipc/email-ipc-api.c64
-rwxr-xr-xemail-ipc/email-ipc-api/email-ipc-api-info.c4
-rwxr-xr-xemail-ipc/email-ipc-api/email-ipc-param-list.c32
-rwxr-xr-xemail-ipc/email-ipc-api/include/email-ipc-api-info.h12
-rwxr-xr-xemail-ipc/email-ipc-api/include/email-ipc-param-list.h2
-rwxr-xr-xemail-ipc/email-ipc-proxy.c1
-rwxr-xr-xemail-ipc/email-proxy/email-proxy-main.c2
-rwxr-xr-xemail-ipc/email-proxy/email-proxy-socket.c74
-rwxr-xr-xemail-ipc/email-socket/email-ipc-socket.c4
-rwxr-xr-xemail-ipc/email-stub/email-stub-main.c1
-rwxr-xr-xemail-ipc/email-stub/email-stub-task-manager.c29
-rwxr-xr-xemail-ipc/email-stub/email-stub-task.c1
-rwxr-xr-xemail-ipc/include/email-ipc.h3
-rwxr-xr-xemail-service.manifest138
-rw-r--r--email-service.rule20
-rwxr-xr-xpackaging/email-service.service3
-rwxr-xr-xpackaging/email-service.spec79
-rwxr-xr-xres/email-service.sql10
-rwxr-xr-xutilities/CMakeLists.txt6
-rwxr-xr-xutilities/test-application/main.c6
-rwxr-xr-xutilities/test-application/testapp-account.c2
-rw-r--r--utilities/test-application/testapp-gmime.c1
-rwxr-xr-xutilities/test-application/testapp-mail.c155
-rwxr-xr-xutilities/test-application/testapp-others.c2
255 files changed, 12018 insertions, 25673 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4978b7a..a116a6f 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,7 +54,7 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/email-service.pc DESTINATION lib/pkgconfig)
# LICENSE file
INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license/email-service)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/email-service.rule DESTINATION /etc/smack/accesses.d RENAME email-service.rule)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/email-service.rule DESTINATION /etc/smack/accesses.d RENAME email-service.rule)
#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/ DESTINATION /opt/usr/data/email/res/image FILES_MATCHING PATTERN "*.png")
#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/ DESTINATION /opt/usr/data/email/res FILES_MATCHING PATTERN "*.sql")
diff --git a/TC/TC_email_service/Makefile b/TC/TC_email_service/Makefile
deleted file mode 100755
index ddb5074..0000000
--- a/TC/TC_email_service/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-testbuildtype=normal
-#export testbuildtype
-
-all: TCInit TCAccount TCFolder TCRule TCNetwork TCMessage
- echo done
-
-TCInit:
- make -s -C TC_Init
-
-TCAccount:
- make -s -C TC_Account
-
-
-TCFolder:
- make -s -C TC_Folder
-
-TCRule:
- make -s -C TC_Rule
-
-TCNetwork:
- make -s -C TC_Network
-
-TCMessage:
- make -s -C TC_Message
-
-clean:
- make clean -C TC_Init
- make clean -C TC_Account
- make clean -C TC_Folder
- make clean -C TC_Rule
- make clean -C TC_Network
- make clean -C TC_Message
-
diff --git a/TC/TC_email_service/TC_Account/Makefile b/TC/TC_email_service/TC_Account/Makefile
deleted file mode 100755
index 557a5ee..0000000
--- a/TC/TC_email_service/TC_Account/Makefile
+++ /dev/null
@@ -1,55 +0,0 @@
-###################################################
-# add your TestCase List Here
-#
-# e.g.,
-# TC1 = utc_frameworkName_apiName_func
-# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
-TARGETS = uts-email-add-account \
- uts-email-add-account-with-validation \
- uts-email-free-account \
- uts-email-get-account \
- uts-email-get-account-list \
- uts-email-update-account \
- uts-email-validate-account \
- uts-email-delete-account
-# uts-email-get-account-list-refer \
- uts-email-get-account-refer
-###################################################
-# add your Package Config Info Here
-#
-# e.g.,
-# PKGS=calendar
-PKGS= email-service
-
-LIBS = `pkg-config --libs $(PKGS)`
-LIBS += `pkg-config --libs glib-2.0`
-LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
-LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
-
-INCS = -I. `pkg-config --cflags $(PKGS)`
-INCS += -I. `pkg-config --cflags glib-2.0`
-INCS += -I$(TET_ROOT)/inc/tet3
-INCS += -I$(TET_SUITE_ROOT)/TC_email_service/TC_Utility
-
-UTIL_SRC = $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-dummy-utility.c
-UTIL_SRC += $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-real-utility.c
-
-CFLAGS = $(INCS)
-CFLAGS += -D_TETWARE_MODE
-LDFLAGS = $(LIBS)
-
-###################################################
-# Modify here
-# depending on the Test Case you want to build
-#
-# e.g.,
-# TCLIST = $(TC1) $(TC2)
-all : $(TARGETS)
-
-$(TARGETS) : %: %.c
- $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
-
-clean :
- rm -rf $(TARGETS)
-
diff --git a/TC/TC_email_service/TC_Account/tslist b/TC/TC_email_service/TC_Account/tslist
deleted file mode 100755
index 3f2b3ed..0000000
--- a/TC/TC_email_service/TC_Account/tslist
+++ /dev/null
@@ -1,8 +0,0 @@
-uts-email-add-account
-uts-email-validate-account
-uts-email-update-account
-uts-email-add-account-with-validation
-uts-email-get-account
-uts-email-get-account-list
-uts-email-free-account
-uts-email-delete-account
diff --git a/TC/TC_email_service/TC_Account/uts-email-add-account-with-validation.c b/TC/TC_email_service/TC_Account/uts-email-add-account-with-validation.c
deleted file mode 100755
index 72319c7..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-add-account-with-validation.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-#include "uts-email-add-account-with-validation.h"
-
-sqlite3 *sqlite_emmb;
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-/*Testcase : uts_Email_Add_Account_With_Validation_01
- TestObjective : To add and validate an email account
- APIs Tested : int email_add_account_with_validation(email_account_t *account, unsigned *handle)
- */
-
-static void uts_Email_Add_Account_With_Validation_01()
-{
- email_account_t *account = NULL;
- int handle;
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Add_Account_With_Validation_01 Begin\n");
- account = (email_account_t *)malloc(sizeof(email_account_t));
- if (account) {
- memset(account, 0x00, sizeof(email_account_t));
-
- account->account_name = strdup("GmailImap");
- account->user_display_name = strdup("samsungtest");
- account->user_email_address = strdup("samsungtest09@gmail.com");
- account->reply_to_address = strdup("samsungtest09@gmail.com");
- account->return_address = strdup("samsungtest09@gmail.com");
- account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
- account->incoming_server_address= strdup("imap.gmail.com");
- account->incoming_server_port_number = 993;
- account->incoming_server_secure_connection = 1;
- account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_NEW;
- account->incoming_server_user_name = strdup("Samsung Test 09");
- account->incoming_server_password = strdup("samsung09");
- account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
- account->outgoing_server_address = strdup("smtp.gmail.com");
- account->outgoing_server_port_number = 465;
- account->outgoing_server_secure_connection = 1;
- account->outgoing_server_need_authentication = 1;
- account->outgoing_server_user_name = strdup("samsungtest09");
- account->outgoing_server_password = strdup("samsung09");
- account->pop_before_smtp = 0;
- account->incoming_server_requires_apop = 0;
- account->auto_download_size = 0; /* downloading option, 0 is subject only, 1 is text body, 2 is normal */
- account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3 */
- account->logo_icon_path = NULL;
- account->options.priority = 3;
- account->options.keep_local_copy = 0;
- account->options.req_delivery_receipt = 0;
- account->options.req_read_receipt = 0;
- account->options.download_limit = 0;
- account->options.block_address = 0;
- account->options.block_subject = 0;
- account->options.display_name_from = NULL;
- account->options.reply_with_body = 0;
- account->options.forward_with_files = 0;
- account->options.add_myname_card = 0;
- account->options.add_signature = 0;
- account->options.signature = strdup("Gmail POP3 Signature");
- account->check_interval = 0;
-
- err_code = email_add_account_with_validation(account, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email add account_with_validation success : accountID[%d]\n", account->account_id);
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add account_with_validation failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_account(&account, 1);
- }
-}
-
-/*Testcase : uts_Email_Add_Account_With_Validation_02
- TestObjective : To validate parameter for account in add an email account with validation
- APIs Tested : int email_add_account_with_validation(email_account_t *account, unsigned *handle)
- */
-
-static void uts_Email_Add_Account_With_Validation_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_account_t *pAccount = NULL ;
- int handle;
-
- tet_infoline("uts_Email_Add_Account_With_Validation_02 : Begin\n");
-
- err_code = email_add_account_with_validation(pAccount, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email add account with validation success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add account with validation failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-add-account-with-validation.h b/TC/TC_email_service/TC_Account/uts-email-add-account-with-validation.h
deleted file mode 100755
index 45bb09b..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-add-account-with-validation.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Add_Account_With_Validation_01(void);
-static void uts_Email_Add_Account_With_Validation_02(void);
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Add_Account_With_Validation_01, 1}, { uts_Email_Add_Account_With_Validation_02, 2}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-add-account.c b/TC/TC_email_service/TC_Account/uts-email-add-account.c
deleted file mode 100755
index c307ebb..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-add-account.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-add-account.h"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Add_Account_01
- TestObjective : To add an email account
- APIs Tested : int email_add_account(email_account_t *account)
- */
-
-static void uts_Email_Add_Account_01()
-{
- email_account_t *account = NULL;
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Add_Account_01 Begin\n");
- account = (email_account_t *)malloc(sizeof(email_account_t));
- if (account) {
- memset(account , 0x00, sizeof(email_account_t));
-
- account->account_name = strdup("Gmail POP");
- account->user_display_name = strdup("samsungtest09");
- account->user_email_address = strdup("samsungtest09@gmail.com");
- account->reply_to_address = strdup("samsungtest09@gmail.com");
- account->return_address = strdup("samsungtest09@gmail.com");
- account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
- account->incoming_server_address= strdup("pop.gmail.com");
- account->incoming_server_port_number = 995;
- account->incoming_server_secure_connection = 1;
- account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_NEW;
- account->incoming_server_user_name = strdup("samsungtest09");
- account->incoming_server_password = strdup("samsung09");
- account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
- account->outgoing_server_address = strdup("smtp.gmail.com");
- account->outgoing_server_port_number = 465;
- account->outgoing_server_secure_connection = 1;
- account->outgoing_server_need_authentication = 1;
- account->outgoing_server_user_name = strdup("samsungtest09");
- account->outgoing_server_password = strdup("samsung09");
- account->pop_before_smtp = 0;
- account->incoming_server_requires_apop = 0;
- account->auto_download_size = 0; /* downloading option, 0 is subject only, 1 is text body, 2 is normal */
- account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3 */
- account->logo_icon_path = NULL;
- account->options.priority = 3;
- account->options.keep_local_copy = 0;
- account->options.req_delivery_receipt = 0;
- account->options.req_read_receipt = 0;
- account->options.download_limit = 0;
- account->options.block_address = 0;
- account->options.block_subject = 0;
- account->options.display_name_from = NULL;
- account->options.reply_with_body = 0;
- account->options.forward_with_files = 0;
- account->options.add_myname_card = 0;
- account->options.add_signature = 0;
- account->options.signature = strdup("Gmail POP3 Signature");
- account->check_interval = 0;
-
- err_code = email_add_account(account);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email add account success : accountID[%d]\n", account->account_id);
- tet_result(TET_PASS);
- g_accountId = account->account_id;
- }
- else {
-
- tet_printf("Email add account failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_account(&account, 1);
-
- }
-
-}
-
-
-/*Testcase : uts_Email_Add_Account_02
- TestObjective : To validate parameter for add an email account
- APIs Tested : int email_add_account(email_account_t *account)
- */
-static void uts_Email_Add_Account_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_account_t *pAccount = NULL ;
-
- tet_infoline("uts_Email_Add_Account_02 : Begin\n");
-
- err_code = email_add_account(pAccount);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email add account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add account failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-add-account.h b/TC/TC_email_service/TC_Account/uts-email-add-account.h
deleted file mode 100755
index 7bd6af9..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-add-account.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Add_Account_01(void);
-static void uts_Email_Add_Account_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Add_Account_01, 1}, { uts_Email_Add_Account_02, 2}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-delete-account.c b/TC/TC_email_service/TC_Account/uts-email-delete-account.c
deleted file mode 100755
index 584ef95..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-delete-account.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-delete-account.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Delete_Account_01
- TestObjective : To delete an email account
- APIs Tested : int email_delete_account(int account_id)
- */
-
-static void uts_Email_Delete_Account_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int account_id = 0;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_infoline("uts_Email_Delete_Account_01 : Begin\n");
- account_id = g_accountId;
-
-
- err_code = email_delete_account(account_id);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email delete account : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete account failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Delete_Account_02
- TestObjective : To validate parameter for delete an email account
- APIs Tested : int email_delete_account(int account_id)
- */
-
-static void uts_Email_Delete_Account_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int account_id = -1;
-
- tet_infoline("uts_Email_Delete_Account_02 : Begin\n");
-
- err_code = email_delete_account(account_id);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email delete account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete account failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-delete-account.h b/TC/TC_email_service/TC_Account/uts-email-delete-account.h
deleted file mode 100755
index 976c228..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-delete-account.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "../TC_Utility/uts-email-dummy-utility.h"
-/* #include "uts-email-dummy-utility.h */
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Delete_Account_01(void);
-static void uts_Email_Delete_Account_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Delete_Account_01, 1}, { uts_Email_Delete_Account_02, 2}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-free-account.c b/TC/TC_email_service/TC_Account/uts-email-free-account.c
deleted file mode 100755
index 6814b85..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-free-account.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-free-account.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Free_Account_01
- TestObjective : To free an email account
- APIs Tested : int email_free_account(email_account_t **account_list, int count)
- */
-
-static void uts_Email_Free_Account_01()
-{
- email_account_t *account = NULL;
- int handle;
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Free_Account_01 Begin\n");
- account = (email_account_t *)malloc(sizeof(email_account_t));
- if (account) {
- memset(account, 0x00, sizeof(email_account_t));
-
- account->account_name = strdup("Gmail Account");
- account->user_display_name = strdup("samsungtest");
- account->user_email_address = strdup("samsungtest09@gmail.com");
- account->reply_to_address = strdup("samsungtest09@gmail.com");
- account->return_address = strdup("samsungtest09@gmail.com");
- account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
- account->incoming_server_address= strdup("pop.gmail.com");
- account->incoming_server_port_number = 995;
- account->incoming_server_secure_connection = 1;
- account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_NEW;
- account->incoming_server_user_name = strdup("samsungtest09");
- account->incoming_server_password = strdup("samsung09");
- account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
- account->outgoing_server_address= strdup("smtp.gmail.com");
- account->outgoing_server_port_number = 465;
- account->outgoing_server_secure_connection = 1;
- account->outgoing_server_need_authentication = 1;
- account->outgoing_server_user_name = strdup("samsungtest09");
- account->outgoing_server_password = strdup("samsung09");
- account->pop_before_smtp = 0;
- account->incoming_server_requires_apop = 0;
- account->auto_download_size = 0; /* downloading option, 0 is subject only, 1 is text body, 2 is normal */
- account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3 */
- account->logo_icon_path = NULL;
- account->options.priority = 3;
- account->options.keep_local_copy = 0;
- account->options.req_delivery_receipt = 0;
- account->options.req_read_receipt = 0;
- account->options.download_limit = 0;
- account->options.block_address = 0;
- account->options.block_subject = 0;
- account->options.display_name_from = NULL;
- account->options.reply_with_body = 0;
- account->options.forward_with_files = 0;
- account->options.add_myname_card = 0;
- account->options.add_signature = 0;
- account->options.signature = strdup("Gmail POP3 Signature");
- account->check_interval = 0;
-
- err_code = email_add_account(account);
- if (EMAIL_ERROR_NONE == err_code)
- tet_printf("Email add account success : accountID[%d]\n", account->account_id);
- else
- tet_printf("Email add account_with_validation failed : error_code[%d]\n", err_code);
- err_code = email_free_account(&account, 1);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email free account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email free account : Failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
-}
-
-/*Testcase : uts_Email_Free_Account_02
- TestObjective : To validate parameter for account_list in add free email account
- APIs Tested : int email_free_account(email_account_t **account_list, int count)
- */
-
-static void uts_Email_Free_Account_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Free_Account_02 : Begin\n");
-
- err_code = email_free_account(NULL, 1);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email free account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email free account failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-free-account.h b/TC/TC_email_service/TC_Account/uts-email-free-account.h
deleted file mode 100755
index ff46972..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-free-account.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Free_Account_01(void);
-static void uts_Email_Free_Account_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Free_Account_01, 1}, { uts_Email_Free_Account_02, 2}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-get-account-list-refer.h b/TC/TC_email_service/TC_Account/uts-email-get-account-list-refer.h
deleted file mode 100755
index b913edc..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-get-account-list-refer.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Account_List_Refer_01(void);
-static void uts_Email_Get_Account_List_Refer_02(void);
-static void uts_Email_Get_Account_List_Refer_03(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Account_List_Refer_01, 1}, { uts_Email_Get_Account_List_Refer_02, 2}, { uts_Email_Get_Account_List_Refer_03, 3}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-get-account-list.c b/TC/TC_email_service/TC_Account/uts-email-get-account-list.c
deleted file mode 100755
index 97a72b5..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-get-account-list.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-account-list.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Account_List_01
- TestObjective : To get account list
- APIs Tested : int email_get_account_list(email_account_t **account, int *count)
- */
-
-static void uts_Email_Get_Account_List_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_infoline("uts_Email_Get_Account_List_01 : Begin\n");
-
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- for (i ; i < count;i++)
- tet_printf("account_id[%d] account_name[%s] email_addr[%s]\n",
- pAccount[i].account_id, pAccount[i].account_name, pAccount[i].user_email_address);
-
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Account_List_02
- TestObjective : To validate parameter for account_list in get account list
- APIs Tested : int email_get_account_list(email_account_t **account_list, int *count)
- */
-
-static void uts_Email_Get_Account_List_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
-
- tet_infoline("uts_Email_Get_Account_List_02 : Begin\n");
-
- err_code = email_get_account_list(NULL, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get account list success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get account list failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Account_List_03
- TestObjective : To validate parameter for count in get account list
- APIs Tested : int email_get_account_list(email_account_t **account, int *count)
- */
-
-static void uts_Email_Get_Account_List_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_account_t *pAccount = NULL ;
-
- tet_infoline("uts_Email_Get_Account_List_03 : Begin\n");
-
- err_code = email_get_account_list(&pAccount, 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get account list success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get account list failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-get-account-list.h b/TC/TC_email_service/TC_Account/uts-email-get-account-list.h
deleted file mode 100755
index c0d2fbe..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-get-account-list.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Account_List_01(void);
-static void uts_Email_Get_Account_List_02(void);
-static void uts_Email_Get_Account_List_03(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Account_List_01, 1}, { uts_Email_Get_Account_List_02, 2}, { uts_Email_Get_Account_List_03, 3}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-get-account-refer.h b/TC/TC_email_service/TC_Account/uts-email-get-account-refer.h
deleted file mode 100755
index fb6ed38..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-get-account-refer.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Account_Refer_01(void);
-static void uts_Email_Get_Account_Refer_02(void);
-static void uts_Email_Get_Account_Refer_03(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Account_Refer_01, 1}, { uts_Email_Get_Account_Refer_02, 2}, { uts_Email_Get_Account_Refer_03, 3}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-get-account.c b/TC/TC_email_service/TC_Account/uts-email-get-account.c
deleted file mode 100755
index e6fc5e4..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-get-account.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-account.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
-
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Account_01
- TestObjective : To get account information based on account id
- APIs Tested : int email_get_account(int account_id, int pulloption, email_account_t **account)
- */
-
-static void uts_Email_Get_Account_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_account_t *pAccount = NULL ;
-
- tet_infoline("uts_Email_Account_01 : Begin\n");
-
- err_code = email_get_account(g_accountId, GET_FULL_DATA, &pAccount);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account success\n");
- tet_printf("account_name[%s]\n email_addr[%s]\n", pAccount->account_name, pAccount->user_email_address);
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get account failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
-
-/*Testcase : uts_Email_Get_Account_02
- TestObjective : To validate parameter for account_id in get account information based on account id
- APIs Tested : int email_get_account(int account_id, int pulloption, email_account_t **account)
- */
-
-static void uts_Email_Get_Account_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int account_id = -1;
- email_account_t *pAccount = NULL ;
-
- tet_infoline("uts_Email_Get_Account_02 : Begin\n");
-
- err_code = email_get_account(account_id, GET_FULL_DATA, &pAccount);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get account failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Account_03
- TestObjective : To validate parameter for account in get account information based on account id
- APIs Tested : int email_get_account(int account_id, int pulloption, email_account_t **account)
- */
-
-static void uts_Email_Get_Account_03()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Get_Account_03 : Begin\n");
-
- err_code = email_get_account(g_accountId, GET_FULL_DATA, NULL);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get account failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-get-account.h b/TC/TC_email_service/TC_Account/uts-email-get-account.h
deleted file mode 100755
index 2207ee9..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-get-account.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Account_01(void);
-static void uts_Email_Get_Account_02(void);
-static void uts_Email_Get_Account_03(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Account_01, 1}, { uts_Email_Get_Account_02, 2}, { uts_Email_Get_Account_03, 3}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-update-account.c b/TC/TC_email_service/TC_Account/uts-email-update-account.c
deleted file mode 100755
index 509712f..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-update-account.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-update-account.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id ;
- email_free_account(&pAccount, count);
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Update_Account_01
- TestObjective : To update account information of an email account
- APIs Tested : int email_update_account(int account_id, email_account_t *new_account)
- */
-
-static void uts_Email_Update_Account_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_account_t *pNewAccount = NULL ;
-
- tet_infoline("uts_Email_Update_Account_01 : Begin\n");
-
- err_code = email_get_account(g_accountId, GET_FULL_DATA, &pNewAccount);
- tet_printf("account_id[%d] account_name[%s] email_addr[%s]\n",
- pNewAccount[i].account_id, pNewAccount[i].account_name, pNewAccount[i].user_email_address);
-
- pNewAccount[i].account_name = strdup("Test_Tc");
- pNewAccount[i].user_email_address = strdup("Test@gmail.com");
-
- err_code = email_update_account(pNewAccount->account_id , pNewAccount);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email update account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email update account failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
-
-/*Testcase : uts_Email_Update_Account_02
- TestObjective : To validate update account parameter.
- APIs tested : Tint email_update_account(int account_id, email_account_t *new_account);
- */
-
-static void uts_Email_Update_Account_02()
-{
- int account_id;
- int err_code = EMAIL_ERROR_NONE;
- email_account_t *pAccount = NULL;
-
- tet_infoline("uts_Email_Account_02 : Begin\n");
- account_id = -1;
-
- pAccount = (email_account_t *) malloc(sizeof(email_account_t));
- memset(pAccount, 0x00, sizeof(email_account_t));
-
- pAccount->account_name = strdup("UpdateTest");
-
- err_code = email_update_account(account_id, pAccount);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf(" email Update Account Falied : \n");
- tet_result (TET_FAIL);
- }
- else {
- tet_printf ("email Update Account successful \n");
- tet_result (TET_PASS);
- }
- }
-
-
-
-/*Testcase : uts_Email_Update_Account_03
- TestObjective : To validate update account parameter.
- APIs tested : Tint email_update_account(int account_id, email_account_t *new_account);
- */
-
-static void uts_Email_Update_Account_03()
-{
- int account_id = 1;
- int err_code = EMAIL_ERROR_NONE;
- email_account_t *pAccount = NULL;
-
- tet_infoline("utc_Email_Account_14 : Begin\n");
-
- err_code = email_update_account(account_id, pAccount);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf(" email Update Account : Falied\n");
- tet_result (TET_FAIL);
- }
- else {
- tet_printf ("email Update Account : successful \n");
- tet_result (TET_PASS);
- }
- }
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-update-account.h b/TC/TC_email_service/TC_Account/uts-email-update-account.h
deleted file mode 100755
index bcd1863..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-update-account.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Update_Account_01(void);
-static void uts_Email_Update_Account_02(void);
-static void uts_Email_Update_Account_03(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Update_Account_01, 1}, { uts_Email_Update_Account_02, 2}, { uts_Email_Update_Account_03, 3}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Account/uts-email-validate-account.c b/TC/TC_email_service/TC_Account/uts-email-validate-account.c
deleted file mode 100755
index 6ad6686..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-validate-account.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-validate-account.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Validate_Account_01
- TestObjective : To validate an email account
- APIs Tested : int email_validate_account(int account_id, unsigned *handle)
- */
-
-static void uts_Email_Validate_Account_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_account_t *account = NULL;
-
- tet_infoline("uts_Email_Validate_Account_01 : Begin\n");
-
- account = (email_account_t *)malloc(sizeof(email_account_t));
- if (account) {
- memset(account , 0x00, sizeof(email_account_t));
-
- account->account_name = strdup("Gmail1 POP");
- account->user_display_name = strdup("samsung");
- account->user_email_address = strdup("samsungtest09@gmail.com");
- account->reply_to_address = strdup("samsungtest09@gmail.com");
- account->return_address = strdup("samsungtest09@gmail.com");
- account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
- account->incoming_server_address= strdup("pop.gmail.com");
- account->incoming_server_port_number = 995;
- account->incoming_server_secure_connection = 1;
- account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_NEW;
- account->incoming_server_user_name = strdup("samsungtest09");
- account->incoming_server_password = strdup("samsung09");
- account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
- account->outgoing_server_address= strdup("smtp.gmail.com");
- account->outgoing_server_port_number = 465;
- account->outgoing_server_secure_connection = 1;
- account->outgoing_server_need_authentication = 1;
- account->outgoing_server_user_name = strdup("samsungtest09");
- account->outgoing_server_password = strdup("samsung09");
- account->pop_before_smtp = 0;
- account->incoming_server_requires_apop = 0;
- account->auto_download_size = 0; /* downloading option, 0 is subject only, 1 is text body, 2 is normal */
- account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3 */
- account->logo_icon_path = NULL;
- account->options.priority = 3;
- account->options.keep_local_copy = 0;
- account->options.req_delivery_receipt = 0;
- account->options.req_read_receipt = 0;
- account->options.download_limit = 0;
- account->options.block_address = 0;
- account->options.block_subject = 0;
- account->options.display_name_from = NULL;
- account->options.reply_with_body = 0;
- account->options.forward_with_files = 0;
- account->options.add_myname_card = 0;
- account->options.add_signature = 0;
- account->options.signature = strdup("Gmail POP3 Signature");
- account->check_interval = 0;
-
- err_code = email_add_account(account);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email add account success : accountID[%d]\n", account->account_id);
- err_code = email_validate_account(account->account_id, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email validate account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email validate account failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
-
- tet_printf("Email add account failed : err_code[%d]n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- email_free_account(&account, 1);
- }
-
-}
-
-/*Testcase : uts_Email_Validate_Account_02
- TestObjective : To validate paramete for account_id in validate an email account
- APIs Tested : int email_validate_account(int account_id, unsigned *handle)
- */
-
-static void uts_Email_Validate_Account_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int account_id = -1;
-
- tet_infoline("uts_Email_Validate_Account_05 : Begin\n");
-
- err_code = email_validate_account(account_id, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email validate account success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email validate account failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Account/uts-email-validate-account.h b/TC/TC_email_service/TC_Account/uts-email-validate-account.h
deleted file mode 100755
index 5189fdc..0000000
--- a/TC/TC_email_service/TC_Account/uts-email-validate-account.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Validate_Account_01(void);
-static void uts_Email_Validate_Account_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Validate_Account_01, 1}, { uts_Email_Validate_Account_02, 2}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Folder/Makefile b/TC/TC_email_service/TC_Folder/Makefile
deleted file mode 100755
index a35443e..0000000
--- a/TC/TC_email_service/TC_Folder/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-###################################################
-# add your TestCase List Here
-#
-# e.g.,
-# TC1 = utc_frameworkName_apiName_func
-# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
-TARGETS = uts-email-add-mailbox \
- uts-email-get-mailbox-list \
- uts-email-get-mailbox-by-mailboxtype \
- uts-email-delete-mailbox
-
-# uts-email-get-sync-mailbox-list (deprecated function)
-###################################################
-# add your Package Config Info Here
-#
-# e.g.,
-# PKGS=calendar
-PKGS= email-service
-
-LIBS = `pkg-config --libs $(PKGS)`
-LIBS += `pkg-config --libs glib-2.0`
-LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
-LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
-
-INCS = -I. `pkg-config --cflags $(PKGS)`
-INCS += -I. `pkg-config --cflags glib-2.0`
-INCS += -I$(TET_ROOT)/inc/tet3
-INCS += -I$(TET_SUITE_ROOT)/TC_email_service/TC_Utility
-
-UTIL_SRC = $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-dummy-utility.c
-UTIL_SRC += $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-real-utility.c
-
-CFLAGS = $(INCS)
-CFLAGS += -D_TETWARE_MODE
-LDFLAGS = $(LIBS)
-
-###################################################
-# Modify here
-# depending on the Test Case you want to build
-#
-# e.g.,
-# TCLIST = $(TC1) $(TC2)
-all : $(TARGETS)
-
-$(TARGETS) : %: %.c
- $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
-
-clean :
- rm -rf $(TARGETS)
-
diff --git a/TC/TC_email_service/TC_Folder/tslist b/TC/TC_email_service/TC_Folder/tslist
deleted file mode 100755
index f16ff20..0000000
--- a/TC/TC_email_service/TC_Folder/tslist
+++ /dev/null
@@ -1,5 +0,0 @@
-uts-email-add-mailbox
-uts-email-get-mailbox-list
-uts-email-get-mailbox-by-mailboxtype
-uts-email-delete-mailbox
-
diff --git a/TC/TC_email_service/TC_Folder/uts-email-add-mailbox.c b/TC/TC_email_service/TC_Folder/uts-email-add-mailbox.c
deleted file mode 100755
index df9dd93..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-add-mailbox.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-add-mailbox.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Add_Mailbox_01
- TestObjective : To add a new mailbox to an account only localy
- APIs Tested : int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, unsigned *handle)
- */
-
-static void uts_Email_Add_Mailbox_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t mbox;
- int local_yn = 1;
- int handle;
-
- tet_infoline("uts_Email_Add_Mailbox_01 Begin\n");
-
- memset(&mbox , 0x00, sizeof(email_mailbox_t));
- mbox.mailbox_name = strdup("Test");
- mbox.alias = strdup("Test");
- mbox.local = local_yn;
- mbox.mailbox_type = 7;
- mbox.account_id = g_accountId;
- err_code = email_add_mailbox(&mbox , 0, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email add mailbox Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Add_Mailbox_02
- TestObjective : To add a new mailbox to an account on server as well as in local also
- APIs Tested : int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, unsigned *handle)
- */
-
-static void uts_Email_Add_Mailbox_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t mbox;
- int local_yn = 0;
- int handle;
-
- tet_infoline("uts_Email_Add_Mailbox_02 Begin\n");
-
- memset(&mbox , 0x00, sizeof(email_mailbox_t));
- mbox.mailbox_name = strdup("Test");
- mbox.alias = strdup("Test");
- mbox.local = local_yn;
- mbox.mailbox_type = 7;
-
- mbox.account_id = g_accountId;
- err_code = email_add_mailbox(&mbox , 1, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email add mailbox on server and in local : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Add_Mailbox_03
- TestObjective : To validate parameter for add a new mailbox
- APIs Tested : int email_add_mailbox(email_mailbox_t *new_mailbox, int on_server, unsigned *handle)
- */
-
-static void uts_Email_Add_Mailbox_03()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *mbox = NULL;
- int local_yn = 0;
- int handle;
- int count = 0;
-
- tet_infoline("uts_Email_Add_Mailbox_03 Begin\n");
-
- err_code = email_add_mailbox(mbox , 1, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email add mailbox validate parameter : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add mailbox failed validate parameter\n");
- tet_result(TET_FAIL);
- }
-
-}
-
-
diff --git a/TC/TC_email_service/TC_Folder/uts-email-add-mailbox.h b/TC/TC_email_service/TC_Folder/uts-email-add-mailbox.h
deleted file mode 100755
index 3d528bb..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-add-mailbox.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Add_Mailbox_01(void);
-static void uts_Email_Add_Mailbox_02(void);
-static void uts_Email_Add_Mailbox_03(void);
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Add_Mailbox_01, 1}, {uts_Email_Add_Mailbox_02, 2}, {uts_Email_Add_Mailbox_03, 3}, {NULL, 0}};
diff --git a/TC/TC_email_service/TC_Folder/uts-email-delete-mailbox.c b/TC/TC_email_service/TC_Folder/uts-email-delete-mailbox.c
deleted file mode 100755
index 93e61da..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-delete-mailbox.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "email-api-account.h"
-#include "uts-email-delete-mailbox.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- int err_code = EMAIL_ERROR_NONE;
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Delete_Mailbox_01
- TestObjective : To delete mailbox
- APIs Tested : int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle)
- */
-
-static void uts_Email_Delete_Mailbox_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *pMailbox = NULL;
- int count = 0;
- int i = 0;
- int handle;
- int on_server ;
-
- tet_infoline("uts_Email_Delete_Mailbox_01 : Begin\n");
-
- err_code = email_get_mailbox_list(g_accountId , 1, &pMailbox, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mailbox list : Success\n");
- if (count > 0) {
- i = 0;
- on_server = pMailbox[i].local;
- err_code = email_delete_mailbox(pMailbox[i].mailbox_id, on_server, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("email delete mailbox : Success\n");
- tet_result(TET_PASS);
- email_delete_account(g_accountId);
- }
- else {
- tet_printf("Email delete mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- }
- else {
- tet_printf("Email get mailbox list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
-}
-
-
-/*Testcase : uts_Email_Delete_Mailbox_02
- TestObjective : To validate parameter for mailbox in delete mailbox
- APIs Tested : int email_delete_mailbox(int input_mailbox_id, int input_on_server, unsigned* output_handle)
- */
-
-static void uts_Email_Delete_Mailbox_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int handle;
- int on_server = 0 ;
-
- tet_infoline("uts_Email_Delete_Mailbox_02 : Begin\n");
-
- err_code = email_delete_mailbox(0, on_server, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("email delete mailbox : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete mailbox failed\n");
- tet_result(TET_FAIL);
- }
-
-}
-
diff --git a/TC/TC_email_service/TC_Folder/uts-email-delete-mailbox.h b/TC/TC_email_service/TC_Folder/uts-email-delete-mailbox.h
deleted file mode 100755
index 54513b6..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-delete-mailbox.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Delete_Mailbox_01(void);
-static void uts_Email_Delete_Mailbox_02(void);
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Delete_Mailbox_01, 1}, {uts_Email_Delete_Mailbox_02, 2}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.c b/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.c
deleted file mode 100755
index 1cf7795..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-mailbox-by-mailboxtype.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- tet_printf("g_accountId [%d], count[%d]\n", g_accountId, count);
- email_free_account(&pAccount, count);
-
- }
-
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Mailbox_By_Mailboxtype_01
- TestObjective : To get mailbox by mailbox type
- APIs Tested : int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t **mailbox)
- */
-
-static void uts_Email_Get_Mailbox_By_Mailboxtype_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *pMailbox = NULL;
- int mailbox_type = EMAIL_MAILBOX_TYPE_INBOX;
-
- tet_infoline("uts_Email_Get_Mailbox_By_Mailboxtype_01 : Begin\n");
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId , mailbox_type, &pMailbox);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mailbox by mailbox type : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_By_Mailboxtype_02
- TestObjective : To validate parameter for account_id in get mailbox by mailbox_type
- APIs Tested : int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t **mailbox)
- */
-
-static void uts_Email_Get_Mailbox_By_Mailboxtype_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *pMailbox = NULL;
- int account_id = -1;
- int mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED;
-
- tet_infoline("uts_Email_Get_Mailbox_By_Mailboxtype_02 : Begin\n");
-
- err_code = email_get_mailbox_by_mailbox_type(account_id , mailbox_type, &pMailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get mailbox by mailbox type : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mailbox by mailbox type failed : \n");
- tet_result(TET_FAIL);
- }
-
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_By_Mailboxtype_03
- TestObjective : To validate parameter for mailbox in get mailbox by mailbox_type
- APIs Tested : int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t **mailbox)
- */
-
-static void uts_Email_Get_Mailbox_By_Mailboxtype_03()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED;
-
- tet_infoline("uts_Email_Get_Mailbox_By_Mailboxtype_03 : Begin\n");
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId , mailbox_type, NULL);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get mailbox by mailbox type : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mailbox by mailbox type failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.h b/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.h
deleted file mode 100755
index 55deffa..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Mailbox_By_Mailboxtype_01(void);
-static void uts_Email_Get_Mailbox_By_Mailboxtype_02(void);
-static void uts_Email_Get_Mailbox_By_Mailboxtype_03(void);
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Get_Mailbox_By_Mailboxtype_01, 1}, {uts_Email_Get_Mailbox_By_Mailboxtype_02, 2}, {uts_Email_Get_Mailbox_By_Mailboxtype_03, 3}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.c b/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.c
deleted file mode 100755
index b4b2754..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-mailbox-list.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_01
- TestObjective : To get all local folderlist
- APIs Tested : int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *pMailbox_list = NULL;
- int count = 0;
- int local_yn = 0;
-
- tet_infoline("uts_Email_Get_Mailbox_List_01 Begin\n");
-
- err_code = email_get_mailbox_list(g_accountId, local_yn, &pMailbox_list, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get all local mailboxes : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all local mailboxes failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_02
- TestObjective : To get all server mailbox list as well as local folderlist
- APIs Tested : int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *pMailbox_list = NULL;
- int local_yn = 1;
- int count = 0;
-
- tet_infoline("uts_Email_Get_Mailbox_List_02 Begin\n");
-
- err_code = email_get_mailbox_list(g_accountId , local_yn, &pMailbox_list, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get all server & local mailboxes : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all server & local mailboxes failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_03
- TestObjective : To validate parameter for account_id in get all mailbox list
- APIs Tested : int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_03()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *pMailbox_list = NULL;
- int local_yn = 1;
- int count = 0;
- int account_id = -1;
-
- tet_infoline("uts_Email_Get_Mailbox_List_03 Begin\n");
-
- err_code = email_get_mailbox_list(account_id , local_yn, &pMailbox_list, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get all mailboxes validate parameter : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all mailboxes validate parameter failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_04
- TestObjective : To validate parameter for mailbox_list in get all mailbox list
- APIs Tested : int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_04()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int local_yn = 1;
- int count = 0;
- int account_id = 1;
-
- tet_infoline("uts_Email_Get_Mailbox_List_04 Begin\n");
-
- err_code = email_get_mailbox_list(account_id , local_yn, NULL, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get all mailboxes validate parameter : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all mailboxes validate parameter failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_05
- TestObjective : To validate parameter for count in get all mailbox list
- APIs Tested : int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_05()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_mailbox_t *pMailbox_list = NULL;
- int local_yn = 1;
- int account_id = 1;
-
- tet_infoline("uts_Email_Get_Mailbox_List_05 Begin\n");
-
- err_code = email_get_mailbox_list(account_id , local_yn, &pMailbox_list, 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get all mailboxes validate parameter : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all mailboxes validate parameter failed : \n");
- tet_result(TET_FAIL);
- }
-}
diff --git a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.h b/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.h
deleted file mode 100755
index 0c45d7f..0000000
--- a/TC/TC_email_service/TC_Folder/uts-email-get-mailbox-list.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Mailbox_List_01(void);
-static void uts_Email_Get_Mailbox_List_02(void);
-static void uts_Email_Get_Mailbox_List_03(void);
-static void uts_Email_Get_Mailbox_List_04(void);
-static void uts_Email_Get_Mailbox_List_05(void);
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Get_Mailbox_List_01, 1}, {uts_Email_Get_Mailbox_List_02, 2}, {uts_Email_Get_Mailbox_List_03, 3}, {uts_Email_Get_Mailbox_List_04, 4}, {uts_Email_Get_Mailbox_List_05, 5}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Init/Makefile b/TC/TC_email_service/TC_Init/Makefile
deleted file mode 100755
index bd39e8a..0000000
--- a/TC/TC_email_service/TC_Init/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-###################################################
-# add your TestCase List Here
-#
-# e.g.,
-# TC1 = utc_frameworkName_apiName_func
-# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
-TARGETS = uts-email-service-begin \
- uts-email-open-db \
- uts-email-init-storage \
- uts-email-ping-service \
- uts-email-service-end \
- uts-email-close-db
-
-###################################################
-# add your Package Config Info Here
-#
-# e.g.,
-# PKGS=calendar
-PKGS= email-service
-
-LIBS = `pkg-config --libs $(PKGS)`
-LIBS += `pkg-config --libs glib-2.0`
-LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
-LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
-
-INCS = -I. `pkg-config --cflags $(PKGS)`
-INCS += -I. `pkg-config --cflags glib-2.0`
-INCS += -I$(TET_ROOT)/inc/tet3
-INCS += -I$(TET_SUITE_ROOT)/TC_email_service/TC_Utility
-
-UTIL_SRC = $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-dummy-utility.c
-UTIL_SRC += $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-real-utility.c
-
-CFLAGS = $(INCS)
-CFLAGS += -D_TETWARE_MODE
-LDFLAGS = $(LIBS)
-
-###################################################
-# Modify here
-# depending on the Test Case you want to build
-#
-# e.g.,
-# TCLIST = $(TC1) $(TC2)
-all : $(TARGETS)
-
-$(TARGETS) : %: %.c
- $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
-
-clean :
- rm -rf $(TARGETS)
-
diff --git a/TC/TC_email_service/TC_Init/tslist b/TC/TC_email_service/TC_Init/tslist
deleted file mode 100755
index f6be9c5..0000000
--- a/TC/TC_email_service/TC_Init/tslist
+++ /dev/null
@@ -1,6 +0,0 @@
-uts-email-service-begin
-uts-email-open-db
-uts-email-init-storage
-uts-email-ping-service
-uts-email-close-db
-uts-email-service-end
diff --git a/TC/TC_email_service/TC_Init/uts-email-close-db.c b/TC/TC_email_service/TC_Init/uts-email-close-db.c
deleted file mode 100755
index a362ad4..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-close-db.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-close-db.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Close_Db_01
- TestObjective : To close db
- APIs Tested : int email_close_db()
- */
-
-static void uts_Email_Close_Db_01()
-{
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email Close DB failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Init/uts-email-close-db.h b/TC/TC_email_service/TC_Init/uts-email-close-db.h
deleted file mode 100755
index 67e3139..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-close-db.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Close_Db_01(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Close_Db_01, 1}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Init/uts-email-init-storage.c b/TC/TC_email_service/TC_Init/uts-email-init-storage.c
deleted file mode 100755
index ebe9a61..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-init-storage.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-init-storage.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Init_Storage_01
- TestObjective : To initialize email storage
- APIs Tested : int email_init_storage()
- */
-
-static void uts_Email_Init_Storage_01()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Init_Storage_01");
- err_code = email_init_storage();
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("email init storage : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("uts_Email_Init_Storage_01 failed : err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Init/uts-email-init-storage.h b/TC/TC_email_service/TC_Init/uts-email-init-storage.h
deleted file mode 100755
index fe13ede..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-init-storage.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Init_Storage_01(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Init_Storage_01, 1}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Init/uts-email-open-db.c b/TC/TC_email_service/TC_Init/uts-email-open-db.c
deleted file mode 100755
index 19a9827..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-open-db.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-open-db.h"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Open_Db_01
- TestObjective : To Open Db
- APIs Tested : int email_open_db()
- */
-
-static void uts_Email_Open_Db_01()
-{
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email open DB failed\n");
- tet_result(TET_FAIL);
- }
-}
diff --git a/TC/TC_email_service/TC_Init/uts-email-open-db.h b/TC/TC_email_service/TC_Init/uts-email-open-db.h
deleted file mode 100755
index d5cfa6c..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-open-db.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Open_Db_01(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Open_Db_01, 1}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Init/uts-email-ping-service.c b/TC/TC_email_service/TC_Init/uts-email-ping-service.c
deleted file mode 100755
index 067766b..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-ping-service.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-ping-service.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Ping_Service_01
- TestObjective : To ping email service
- APIs Tested : int email_ping_service()
- */
-
-static void uts_Email_Ping_Service_01()
-{
- if (EMAIL_ERROR_NONE == email_ping_service()) {
- tet_infoline("uts_Email_Ping_Service_01 : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email Ping Service Failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Init/uts-email-ping-service.h b/TC/TC_email_service/TC_Init/uts-email-ping-service.h
deleted file mode 100755
index d06de7d..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-ping-service.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Ping_Service_01(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Ping_Service_01, 1}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Init/uts-email-service-begin.c b/TC/TC_email_service/TC_Init/uts-email-service-begin.c
deleted file mode 100755
index 471a438..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-service-begin.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-service-begin.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Service_Begin_01
- TestObjective : To start email service
- APIs Tested : int email_service_begin()
- */
-
-static void uts_Email_Service_Begin_01()
-{
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- tet_result(TET_PASS);
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_result(TET_FAIL);
- tet_infoline("Email service not started\n");
- }
-
-}
-
-
diff --git a/TC/TC_email_service/TC_Init/uts-email-service-begin.h b/TC/TC_email_service/TC_Init/uts-email-service-begin.h
deleted file mode 100755
index ff07069..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-service-begin.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Service_Begin_01(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Service_Begin_01, 1}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Init/uts-email-service-end.c b/TC/TC_email_service/TC_Init/uts-email-service-end.c
deleted file mode 100755
index c7a3a25..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-service-end.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-service-end.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Service_End_01
- TestObjective : To close email service
- APIs Tested : int email_service_end()
- */
-
-static void uts_Email_Service_End_01()
-{
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
-
- if (EMAIL_ERROR_NONE == email_service_end()) {
- tet_infoline("Email service close Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email service end failed\n");
- tet_result(TET_FAIL);
- }
- }
- else
- tet_infoline("Email Close DB failed\n");
-
-}
-
-
diff --git a/TC/TC_email_service/TC_Init/uts-email-service-end.h b/TC/TC_email_service/TC_Init/uts-email-service-end.h
deleted file mode 100755
index aef969f..0000000
--- a/TC/TC_email_service/TC_Init/uts-email-service-end.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Service_End_01(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Service_End_01, 1}, {NULL, 0}
-
-
-};
diff --git a/TC/TC_email_service/TC_Message/Makefile b/TC/TC_email_service/TC_Message/Makefile
deleted file mode 100644
index cf19547..0000000
--- a/TC/TC_email_service/TC_Message/Makefile
+++ /dev/null
@@ -1,89 +0,0 @@
-###################################################
-# add your TestCase List Here
-#
-# e.g.,
-# TC1 = utc_frameworkName_apiName_func
-# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
-TARGETS = uts-email-add-message \
- uts-email-add-attachment \
- uts-email-update-message \
- uts-email-count-message \
- uts-email-delete-message \
- uts-email-delete-attachment \
- uts-email-get-info \
- uts-email-free-mail-info \
- uts-email-get-disk-space-usage \
- uts-email-get-max-mail-count \
- uts-email-cancel-send-mail \
- uts-email-send-retry \
- uts-email-get-mail-list-ex \
- uts-email-get-attachment-info \
- uts-email-free-attachment-info \
- uts-email-move-mail-to-folder \
- uts-email-move-all-mails-to-folder \
- uts-email-get-mailbox-list \
- uts-email-delete-all-message-in-folder \
- uts-email-free-mailbox \
- uts-email-create-db-full \
- uts-email-clear-mail-data \
-
-# uts-email-query-message \
- uts-email-add-query-message \
- uts-email-release-query-message \
- uts-email-get-list-by-emails \
- uts-email-get-mail-list-for-thread-view \
- uts-email-get-mail-list-of-thread \
- uts-email-get-mail-list-of-sender \
- uts-email-get-thread-information \
- uts-email-searched-mail-list \
- uts-email-get-searched-mail-list_by-count \
- uts-email-get-mail-list-by-count \
- uts-email-convert-mailbox-name-to-utf8 \
- uts-email-convert-text-utf8 \
- uts-email-convert-utf8-text \
- uts-email-get-mail-during-sync \
- uts-email-count-message-with-searching \
- uts-email-get-rfc-822 \
- uts-email-parse-rfc-822 \
- uts-email-free-envelope \
- uts-email-get-temp-file-size \
- uts-email-get-mail-list (deprecated function)
-###################################################
-# add your Package Config Info Here
-#
-# e.g.,
-# PKGS=calendar
-PKGS= email-service
-
-LIBS = `pkg-config --libs $(PKGS)`
-LIBS += `pkg-config --libs glib-2.0`
-LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
-LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
-
-INCS = `pkg-config --cflags $(PKGS)`
-INCS += `pkg-config --cflags glib-2.0`
-INCS += -I$(TET_ROOT)/inc/tet3
-INCS += -I$(TET_SUITE_ROOT)/TC_Utility/include
-
-UTIL_SRC = $(TET_SUITE_ROOT)/TC_Utility/uts-email-dummy-utility.c
-UTIL_SRC += $(TET_SUITE_ROOT)/TC_Utility/uts-email-real-utility.c
-
-CFLAGS = $(INCS)
-CFLAGS += -D_TETWARE_MODE
-LDFLAGS = $(LIBS)
-
-###################################################
-# Modify here
-# depending on the Test Case you want to build
-#
-# e.g.,
-# TCLIST = $(TC1) $(TC2)
-all : $(TARGETS)
-
-$(TARGETS) : %: %.c
- $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
-
-clean :
- rm -rf $(TARGETS)
-
diff --git a/TC/TC_email_service/TC_Message/tslist b/TC/TC_email_service/TC_Message/tslist
deleted file mode 100755
index b178c86..0000000
--- a/TC/TC_email_service/TC_Message/tslist
+++ /dev/null
@@ -1,22 +0,0 @@
-uts-email-add-message
-uts-email-add-attachment
-uts-email-get-info
-uts-email-get-attachment-info
-uts-email-get-mail-list-ex
-uts-email-get-disk-space-usage
-uts-email-get-max-mail-count
-uts-email-get-mailbox-list
-uts-email-update-message
-uts-email-count-message
-uts-email-cancel-send-mail
-uts-email-send-retry
-uts-email-move-mail-to-folder
-uts-email-move-all-mails-to-folder
-uts-email-free-mail-info
-uts-email-free-attachment-info
-uts-email-free-mailbox
-uts-email-delete-attachment
-uts-email-delete-message
-uts-email-delete-all-message-in-folder
-uts-email-create-db-full
-uts-email-clear-mail-data
diff --git a/TC/TC_email_service/TC_Message/uts-email-add-attachment.c b/TC/TC_email_service/TC_Message/uts-email-add-attachment.c
deleted file mode 100755
index 951d451..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-add-attachment.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-add-attachment.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mailbox_t mbox;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin())
- {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- } else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- } else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- } else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- } else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- } else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- } else
- tet_infoline("Email open DB failed\n");
- } else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Add_Attachment_01
- TestObjective : To add attachment to mail
- APIs Tested : int email_add_attachment(int mail_id, email_attachment_data_t* attachment)
- */
-
-static void uts_Email_Add_Attachment_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_attachment_data_t attachment;
- email_mail_list_item_t *mail_list = NULL;
- email_account_t *account = NULL ;
- FILE *fp = NULL;
-
-
- tet_infoline("uts_Email_Add_Attachment_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code)
- {
- tet_infoline("Email get account list success\n");
- if (count > 0)
- {
- g_accountId = account[i].account_id;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail list : success\n");
- if (count > 0) {
- memset(&attachment, 0x00, sizeof(email_attachment_data_t));
- attachment.attachment_name = strdup("Test attachment");
- attachment.attachment_path = strdup("/tmp/mail.txt");
- fp = fopen("/tmp/mail.txt", "w");
- fprintf(fp, "xxxxxxxxx");
- fclose(fp);
- i = 0;
- err_code = email_add_attachment(mail_list[i].mail_id , &attachment);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email add attachment : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add attachment : Failed err_code[%d]", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_infoline("No Mails in mailbox\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get mail list : Failed err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_infoline("NO email account found : success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
-}
-
-
-/*Testcase : uts_Email_Add_Attchment_02
- TestObjective : To validate parameter for mailbox in add attachment to mail
- APIs Tested : int email_add_attachment(int mail_id, email_attachment_data_t* attachment)
- */
-
-static void uts_Email_Add_Attachment_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_attachment_data_t attachment;
-
- tet_infoline("uts_Email_Add_attachment_02 Begin\n");
-
- memset(&attachment, 0x00, sizeof(email_attachment_data_t));
- attachment.attachment_name = strdup("Test");
-
- err_code = email_add_attachment(1 , &attachment);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email add attachment : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add attachment : Failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Add_Attchment_03
- TestObjective : To validate parameter for mailbox account_id in add attachment to mail
- APIs Tested : int email_add_attachment(int mail_id, email_attachment_data_t* attachment)
- */
-
-static void uts_Email_Add_Attachment_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = 1;
- email_attachment_data_t attachment;
-
- tet_infoline("uts_Email_Add_attachment_02 Begin\n");
-
- memset(&attachment, 0x00, sizeof(email_attachment_data_t));
- attachment.attachment_name = strdup("Test");
-
- err_code = email_add_attachment(mail_id , &attachment);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email add attachment : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add attachment : Failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Add_Attchment_04
- TestObjective : To validate parameter for mail_id in add attachment to mail
- APIs Tested : int email_add_attachment(int mail_id, email_attachment_data_t* attachment)
- */
-
-static void uts_Email_Add_Attachment_04()
-{
- int err_code = EMAIL_ERROR_NONE;
- int i = 0;
- email_attachment_data_t attachment;
-
- tet_infoline("uts_Email_Add_attachment_04 Begin\n");
-
-
- memset(&attachment, 0x00, sizeof(email_attachment_data_t));
- attachment.attachment_name = strdup("Test");
-
- err_code = email_add_attachment( 0 , &attachment);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email add attachment : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add attachment : Failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Add_Attchment_05
- TestObjective : To validate parameter for mailbox in add attachment to mail
- APIs Tested : int email_add_attachment(int mail_id, email_attachment_data_t* attachment)
- */
-
-static void uts_Email_Add_Attachment_05()
-{
- int err_code = EMAIL_ERROR_NONE;
- int i = 0;
-
- tet_infoline("uts_Email_Add_attachment_05 Begin\n");
-
- err_code = email_add_attachment( 1 , NULL);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email add attachment : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add attachment : Failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-add-attachment.h b/TC/TC_email_service/TC_Message/uts-email-add-attachment.h
deleted file mode 100755
index b0ae23e..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-add-attachment.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Add_Attachment_01(void);
-static void uts_Email_Add_Attachment_02(void);
-static void uts_Email_Add_Attachment_03(void);
-static void uts_Email_Add_Attachment_04(void);
-static void uts_Email_Add_Attachment_05(void);
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Add_Attachment_01, 1}, { uts_Email_Add_Attachment_02, 2}, { uts_Email_Add_Attachment_03, 3}, { uts_Email_Add_Attachment_04, 4}, { uts_Email_Add_Attachment_05, 5}, {NULL, 0}
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-add-message.c b/TC/TC_email_service/TC_Message/uts-email-add-message.c
deleted file mode 100755
index 7a16a13..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-add-message.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-add-message.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mailbox_t mbox;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Add_Message_01
- TestObjective : To save message
- APIs Tested : int email_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas)
- */
-
-static void uts_Email_Add_Message_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_mail_data_t *test_mail_data = NULL;
- email_attachment_data_t *attachment_data = NULL;
- email_meeting_request_t *meeting_req = NULL;
-
- FILE *fp;
- email_option_t option;
- int count = 0;
- int i = 0;
- email_account_t *account = NULL ;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("uts_Email_Add_Message_01 Begin\n");
-
-
- memset(&option, 0x00, sizeof(email_option_t));
- option.keep_local_copy = 1;
-
-
- test_mail_data = malloc(sizeof(email_mail_data_t));
- memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
-
- attachment_data = malloc(sizeof(email_attachment_data_t));
- memset(attachment_data, 0x00, sizeof(email_attachment_data_t));
-
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- if (count > 0) {
- test_mail_data->account_id = account[i].account_id;
- g_accountId = account[i].account_id;
- test_mail_data->flags_draft_field = 1;
-
- tet_printf("g_accountId[%d]\n", g_accountId);
-
- test_mail_data->full_address_from = strdup("<samsungtest09@gmail.com>");
- test_mail_data->full_address_to = strdup("<samsungtest09@gmail.com>");
- test_mail_data->subject = strdup("Test");
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId , EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return ;
- }
-
- test_mail_data->mailbox_id = mailbox->mailbox_id;
- test_mail_data->mailbox_type = mailbox->mailbox_type;
-
- test_mail_data->save_status = 1;
- test_mail_data->body_download_status = 1;
-
- fp = fopen("/tmp/mail.txt", "w");
- fprintf(fp, "xxxxxxxxx");
- fclose(fp);
- test_mail_data->file_path_plain = strdup("/tmp/mail.txt");
- test_mail_data->attachment_count = 1;
-
- fp = fopen("/tmp/attach.txt", "w");
- fprintf(fp, "Simple Attachment");
- fclose(fp);
-
- attachment_data->attachment_name = strdup("Attach");
- attachment_data->attachment_path = strdup("/tmp/attach.txt");
- attachment_data->save_status = 1;
-
- err_code = email_add_mail(test_mail_data, attachment_data, 1, NULL, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email add message Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add message failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_infoline("NO email account found : success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- tet_infoline("Free email data\n");
-
- email_free_attachment_data(&attachment_data, 1);
- email_free_mail_data(&test_mail_data, 1);
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Add_Message_02
- TestObjective : To validate parameter for mail in add message
- APIs Tested : int email_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas)
- */
-
-static void uts_Email_Add_Message_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
-
- tet_infoline("uts_Email_Add_Message_02 Begin\n");
-
- err_code = email_add_mail(NULL, NULL, 0, NULL, 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email add message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email add message : failed \n");
- tet_result(TET_FAIL);
- }
-
-
-}
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-add-message.h b/TC/TC_email_service/TC_Message/uts-email-add-message.h
deleted file mode 100755
index 7b17539..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-add-message.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Add_Message_01(void);
-static void uts_Email_Add_Message_02(void);
-
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- {uts_Email_Add_Message_01, 1}, {uts_Email_Add_Message_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-cancel-send-mail.c b/TC/TC_email_service/TC_Message/uts-email-cancel-send-mail.c
deleted file mode 100755
index ac422ec..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-cancel-send-mail.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-cancel-send-mail.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Cancel_Send_Mail_01
- TestObjective : To get the total count and unread count of all mailboxes
- APIs Tested : int email_cancel_sending_mail(int mail_id)
- */
-
-static void uts_Email_Cancel_Send_Mail_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_mail_list_item_t *mail_list = NULL;
- int account_id = 0;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_infoline("uts_Email_Cancel_Send_Mail_01 Begin\n");
-
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE != err_code || count <= 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(pAccount[0].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- err_code = email_cancel_sending_mail(mail_list[i].mail_id);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email Cancel Send Mail Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Cancel Send Mail Failed\n");
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_printf("email_get_mail_list() Failed : failed error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Cancel_Send_Mail_02
- TestObjective : To validate parameter for mail_id in cancel send mail
- APIs Tested : int email_cancel_sending_mail(int mail_id)
- */
-
-static void uts_Email_Cancel_Send_Mail_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = -1;
-
- tet_infoline("uts_Email_Cancel_Send_Mail_02 Begin\n");
-
- err_code = email_cancel_sending_mail(mail_id);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email Cancel Send Mail Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Cancel Send Mail failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-cancel-send-mail.h b/TC/TC_email_service/TC_Message/uts-email-cancel-send-mail.h
deleted file mode 100755
index 309b6b3..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-cancel-send-mail.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Cancel_Send_Mail_01(void);
-static void uts_Email_Cancel_Send_Mail_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Cancel_Send_Mail_01, 1}, { uts_Email_Cancel_Send_Mail_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-clear-mail-data.c b/TC/TC_email_service/TC_Message/uts-email-clear-mail-data.c
deleted file mode 100755
index 81037e0..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-clear-mail-data.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-clear-mail-data.h"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Clear_Mail_Data_01
- TestObjective : To Clear Mail data
- APIs Tested : int email_clear_mail_data()
- */
-
-static void uts_Email_Clear_Mail_Data_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- err_code = email_clear_mail_data();
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email clear mail data Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email clear mail data failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- }
-
-
-/*Testcase : uts_Email_Clear_Mail_Data_02
- TestObjective : To validate parameter
- APIs Tested : int email_clear_mail_data()
- */
-
-static void uts_Email_Clear_Mail_Data_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- /* this function has no paramete */
- tet_result(TET_PASS);
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-clear-mail-data.h b/TC/TC_email_service/TC_Message/uts-email-clear-mail-data.h
deleted file mode 100755
index 0a4bbec..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-clear-mail-data.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Clear_Mail_Data_01(void);
-static void uts_Email_Clear_Mail_Data_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Clear_Mail_Data_01, 1}, { uts_Email_Clear_Mail_Data_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-count-message.c b/TC/TC_email_service/TC_Message/uts-email-count-message.c
deleted file mode 100755
index 410a68e..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-count-message.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-count-message.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Count_Message_01
- TestObjective : To get mail count for mailbox
- APIs Tested : int email_count_mail(email_list_filter_t *input_filter_list, int input_filter_count, int *output_total_mail_count, int *output_unseen_mail_count)
- */
-
-static void uts_Email_Count_Message_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int total = 0;
- int unseen = 0;
- email_list_filter_t *filter_list = NULL;
-
- tet_infoline("utc_Email_Count_Message_01 Begin\n");
-
- filter_list = malloc(sizeof(email_list_filter_t) * 3);
- memset(filter_list, 0 , sizeof(email_list_filter_t) * 3);
-
- filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
- filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE;
- filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
- filter_list[0].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_INBOX;
- filter_list[0].list_filter_item.rule.case_sensitivity = false;
-
- err_code = email_count_mail(filter_list, 1, &total, &unseen);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email count message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email count message : failed error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-/*Testcase : uts_Email_Count_Message_02
- TestObjective : To validate parameter for mailbox in get mail count for mailbox
- APIs Tested : int email_count_mail(email_list_filter_t *input_filter_list, int input_filter_count, int *output_total_mail_count, int *output_unseen_mail_count)
- */
-
-static void uts_Email_Count_Message_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int total = 0;
- int unseen = 0;
-
- tet_infoline("utc_Email_Count_Message_02 Begin\n");
-
- err_code = email_count_mail(NULL, 1, &total, &unseen);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email count message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email count message : failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-/*Testcase : uts_Email_Count_Message_03
- TestObjective : To validate parameter for total in get mail count for mailbox
- APIs Tested : int email_count_mail(email_list_filter_t *input_filter_list, int input_filter_count, int *output_total_mail_count, int *output_unseen_mail_count)
- */
-
-static void uts_Email_Count_Message_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int unseen = 0;
- email_list_filter_t *filter_list = NULL;
-
- tet_infoline("utc_Email_Count_Message_03 Begin\n");
-
- filter_list = malloc(sizeof(email_list_filter_t) * 3);
- memset(filter_list, 0 , sizeof(email_list_filter_t) * 3);
-
- filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
- filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE;
- filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
- filter_list[0].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_SENTBOX;
- filter_list[0].list_filter_item.rule.case_sensitivity = false;
-
- err_code = email_count_mail(filter_list, 1, 0, &unseen);
-
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email count message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email count message : failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-/*Testcase : uts_Email_Count_Message_04
- TestObjective : To validate parameter for seen in get mail count for mailbox
- APIs Tested : int email_count_mail(email_list_filter_t *input_filter_list, int input_filter_count, int *output_total_mail_count, int *output_unseen_mail_count)
- */
-
-static void uts_Email_Count_Message_04()
-{
- int err_code = EMAIL_ERROR_NONE;
- int total = 0;
- email_list_filter_t *filter_list = NULL;
-
- tet_infoline("utc_Email_Count_Message_04 Begin\n");
-
- filter_list = malloc(sizeof(email_list_filter_t) * 3);
- memset(filter_list, 0 , sizeof(email_list_filter_t) * 3);
-
- filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
- filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE;
- filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
- filter_list[0].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_SENTBOX;
- filter_list[0].list_filter_item.rule.case_sensitivity = false;
-
- err_code = email_count_mail(filter_list, 1, &total, 0);
-
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email count message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email count message : failed \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-count-message.h b/TC/TC_email_service/TC_Message/uts-email-count-message.h
deleted file mode 100755
index 03bd343..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-count-message.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Count_Message_01(void);
-static void uts_Email_Count_Message_02(void);
-static void uts_Email_Count_Message_03(void);
-static void uts_Email_Count_Message_04(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Count_Message_01, 1}, { uts_Email_Count_Message_02, 2}, { uts_Email_Count_Message_03, 3}, { uts_Email_Count_Message_04, 4}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-create-db-full.c b/TC/TC_email_service/TC_Message/uts-email-create-db-full.c
deleted file mode 100755
index 468d237..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-create-db-full.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-create-db-full.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Create_Db_Full_01
- TestObjective : To Create DB full
- APIs Tested : int email_create_db_full()
- */
-
-static void uts_Email_Create_Db_Full_01()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- err_code = email_create_db_full();
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email Create Db Full Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Create Db Full Failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-/*Testcase : uts_Email_Create_Db_Full_02
- TestObjective : email_create_db_full() have no parameter. return TET_PASS
- APIs Tested : int email_create_db_full()
- */
-
-static void uts_Email_Create_Db_Full_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_result(TET_PASS);
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-create-db-full.h b/TC/TC_email_service/TC_Message/uts-email-create-db-full.h
deleted file mode 100755
index e36ae57..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-create-db-full.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Create_Db_Full_01(void);
-static void uts_Email_Create_Db_Full_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Create_Db_Full_01, 1}, { uts_Email_Create_Db_Full_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.c b/TC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.c
deleted file mode 100755
index ca34dc3..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-delete-all-message-in-folder.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Delete_All_Message_In_Folder_01
- TestObjective : To delete all message in mailbox message
- APIs Tested : int email_delete_all_mails_in_mailbox(int input_mailbox_id, int input_from_server)
- */
-
-static void uts_Email_Delete_All_Message_In_Folder_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int count = 0;
- int i = 0;
- email_account_t *account = NULL ;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("utc_Email_Delete_All_Message_In_Folder_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- if (count > 0) {
- err_code = email_get_mailbox_by_mailbox_type(account[i].account_id , EMAIL_MAILBOX_TYPE_SENTBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- err_code = email_delete_all_mails_in_mailbox(mailbox->mailbox_id, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email delete all message in mailbox : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete all message in mailbox failed : error_code[%d]\n", err_code);
- tet_printf("account_id[%d], mailbox->mailbox_id[%d]\n", account[i].account_id, mailbox->mailbox_id);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_infoline("NO email account found : success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-
-}
-
-
-
-/*Testcase : uts_Email_Delete_All_Message_In_Folder_02
- TestObjective : To validate parameter for mailbox in delete all message in mailbox message
- APIs Tested : int email_delete_all_mails_in_mailbox(int input_mailbox_id, int input_from_server)
- */
-
-static void uts_Email_Delete_All_Message_In_Folder_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("utc_Email_delete_all_Message_in_folder Begin\n");
-
- err_code = email_delete_all_mails_in_mailbox(0, 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email delete all_message_in_folder : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email delete all_message in mailbox : failed \n");
- tet_result(TET_FAIL);
- }
-}
diff --git a/TC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.h b/TC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.h
deleted file mode 100755
index 3b56dfe..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-delete-all-message-in-folder.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Delete_All_Message_In_Folder_01(void);
-static void uts_Email_Delete_All_Message_In_Folder_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Delete_All_Message_In_Folder_01, 1}, { uts_Email_Delete_All_Message_In_Folder_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-delete-attachment.c b/TC/TC_email_service/TC_Message/uts-email-delete-attachment.c
deleted file mode 100755
index 303e3b0..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-delete-attachment.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-delete-attachment.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Delete_Attachment_01
- TestObjective : To delete a attachment from mail
- APIs Tested : int email_delete_attachment(int attachment_id)
- */
-
-static void uts_Email_Delete_Attachment_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int attachment_id = 0;
- int i = 0;
- email_attachment_data_t *mail_attach_info = NULL;
- email_mail_list_item_t *mail_list = NULL;
- int count = 0;
- email_account_t *account = NULL ;
-
- tet_infoline("uts_Email_Delete_Attachment_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- g_accountId = account[i].account_id;
-
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- for (i ; i < count ; i++) {
- if(mail_list[i].attachment_count) {
- err_code = email_get_attachment_data_list(mail_list[i].mail_id, &mail_attach_info, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- err_code = email_delete_attachment(mail_attach_info->attachment_id);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email delete attachment : success\n");
- tet_result(TET_PASS);
- return ;
- }
- else {
- tet_printf("Email delete attachment : Failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- return ;
- }
-
- }else {
- tet_printf("Email get attachment data list : Failed err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- }
- }
-}
-
-
-/*Testcase : uts_Email_Delete_Attachment_02
- TestObjective : To validate parmete for mailbox in delete a attachment from mail
- APIs Tested : int email_delete_attachment(int attachment_id)
- */
-
-static void uts_Email_Delete_Attachment_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Delete_Attachment_02 Begin\n");
-
- err_code = email_delete_attachment(0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email delete attachment : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete attachment : Failed \n");
- tet_result(TET_FAIL);
- }
-
-}
diff --git a/TC/TC_email_service/TC_Message/uts-email-delete-attachment.h b/TC/TC_email_service/TC_Message/uts-email-delete-attachment.h
deleted file mode 100755
index dec459f..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-delete-attachment.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Delete_Attachment_01(void);
-static void uts_Email_Delete_Attachment_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Delete_Attachment_01, 1}, { uts_Email_Delete_Attachment_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-delete-message.c b/TC/TC_email_service/TC_Message/uts-email-delete-message.c
deleted file mode 100755
index 2468330..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-delete-message.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-delete-message.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Delete_Message_01
- TestObjective : To update message
- APIs Tested : int email_delete_mail(int input_mailbox_id, int *input_mail_ids, int input_num, int input_from_server)
- */
-
-static void uts_Email_Delete_Message_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int count = 0;
- int i = 0;
- email_account_t *account = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_infoline("uts_Email_Delete_Message_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- if (count > 0) {
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(account[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail list : success\n");
- if (count > 0) {
- tet_printf("mail_list[i].mailbox_id[%d] mail_list[i].mail_id[%d]\n", mail_list[i].mailbox_id, mail_list[i].mail_id);
- err_code = email_delete_mail(mail_list[i].mailbox_id, &mail_list[i].mail_id , 1, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email delete message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete message failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- }
- else {
- tet_printf("Email get mail list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- /* email_free_mail_list(&mail_list, count) */
- free(mail_list);
- }
- else {
- tet_infoline("NO email account found : success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
-}
-
-
-
-/*Testcase : uts_Email_Delete_Message_02
- TestObjective : To validate parameter for mailbox in delete message
- APIs Tested : int email_delete_mail(int input_mailbox_id, int *input_mail_ids, int input_num, int input_from_server)
- */
-
-static void uts_Email_Delete_Message_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = 1;
-
- tet_infoline("uts_Email_delete_Message_02 Begin\n");
-
- err_code = email_delete_mail(0, &mail_id , 1, 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email delete message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email delete message : failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Delete_Message_03
- TestObjective : To validate parameter for mail_id in delete message
- APIs Tested : int email_delete_mail(int input_mailbox_id, int *input_mail_ids, int input_num, int input_from_server)
- */
-
-static void uts_Email_Delete_Message_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = 0;
- int count = 0;
- email_mailbox_t *mail_box = NULL;
- email_account_t *account = NULL;
-
- tet_infoline("uts_Email_delete_Message_03 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- if (count > 0) {
- count = 0;
- err_code = email_get_mailbox_by_mailbox_type(account[0].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mail_box);
-
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("email_get_mailbox_by_mailbox_type : failed\n");
- tet_result(TET_UNRESOLVED);
- }
-
- err_code = email_delete_mail(mail_box->mailbox_id, &mail_id , 1, 0);
-
- if (mail_box) {
- email_free_mailbox(&mail_box, 1);
- mail_box = NULL;
- }
-
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email delete message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email delete message : failed \n");
- tet_result(TET_FAIL);
- }
- }
- }else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-}
-
-
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-delete-message.h b/TC/TC_email_service/TC_Message/uts-email-delete-message.h
deleted file mode 100755
index c61f21c..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-delete-message.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Delete_Message_01(void);
-static void uts_Email_Delete_Message_02(void);
-static void uts_Email_Delete_Message_03(void);
-
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Delete_Message_01, 1}, { uts_Email_Delete_Message_02, 2}, { uts_Email_Delete_Message_03, 3}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-attachment-info.c b/TC/TC_email_service/TC_Message/uts-email-free-attachment-info.c
deleted file mode 100755
index e6005a5..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-attachment-info.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-free-attachment-info.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Free_Attachment_Info_01
- TestObjective : Free mail attachment
- APIs Tested : int email_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count)
- */
-
-static void uts_Email_Free_Attachment_Info_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int i = 0;
- char att_pos[10];
- email_attachment_data_t *mail_attach_info = NULL;
- email_mail_list_item_t *mail_list = NULL;
- int count = 0;
- email_account_t *account = NULL ;
- email_attachment_data_t *test_attachment_data_list = NULL;
- int test_attachment_data_count = 0;
-
-
- tet_infoline("uts_Email_Free_Attachment_Info_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- g_accountId = account[i].account_id;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- for (i = 0 ; i < count ; i++) {
- err_code = email_get_attachment_data_list(mail_list[i].mail_id, &test_attachment_data_list, &test_attachment_data_count);
- if (EMAIL_ERROR_NONE == err_code) {
- if (test_attachment_data_count > 0) {
-
- if(test_attachment_data_list)
- err_code = email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count);
-
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email free attachment info : success\n");
- tet_result(TET_PASS);
- return;
- }
- else {
- tet_printf("Email free attachment info : Failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- return;
- }
- }
- }
- }
-
- tet_printf("uts_Email_Free_Attachment_Info_01 End\n");
- tet_result(TET_UNRESOLVED);
-}
-
-
-/*Testcase : uts_Email_Free_Attachment_Info_02
- TestObjective : Validate Parameter for Free mail attachment
- APIs Tested : int email_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count)
- */
-
-static void uts_Email_Free_Attachment_Info_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int attachment_data_count = 0;
-
- tet_infoline("uts_Email_Free_Attachment_Info_02 Begin\n");
-
- err_code = email_free_attachment_data(NULL, attachment_data_count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email free attachment info : success\n");
- tet_result(TET_PASS);
- return;
- }
- else {
- tet_printf("Email free attachment info : Failed \n");
- tet_result(TET_FAIL);
- return;
- }
-
-}
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-attachment-info.h b/TC/TC_email_service/TC_Message/uts-email-free-attachment-info.h
deleted file mode 100755
index fe11d61..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-attachment-info.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Free_Attachment_Info_01(void);
-static void uts_Email_Free_Attachment_Info_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Free_Attachment_Info_01, 1}, { uts_Email_Free_Attachment_Info_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-mail-info.c b/TC/TC_email_service/TC_Message/uts-email-free-mail-info.c
deleted file mode 100755
index 8bb699e..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-mail-info.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-free-mail-info.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Free_Mail_Info_01
- TestObjective : To Free mail info
- APIs Tested : int email_free_mail_data(email_mail_data_t** mail_list, int count)
- */
-
-static void uts_Email_Free_Mail_Info_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_mail_data_t *mail_data = NULL;
- email_mail_list_item_t *mail_list = NULL;
- email_account_t *account = NULL ;
-
-
- tet_infoline("uts_Email_Free_Mail_Info_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- if (count > 0) {
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail list : success\n");
- if (count > 0) {
- err_code = email_get_mail_data(mail_list[0].mail_id, &mail_data);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail info : success\n");
- err_code = email_free_mail_data(&mail_data, 1);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email free mail info : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email free mail info : Failed err_code[%d] \n", err_code);
- tet_result(TET_FAIL);
- }
-
- }
- else {
- tet_printf("Email get mail data : Failed err_code[%d] \n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- }
- else {
- tet_infoline("No Mails in mailbox\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get mail list : Failed err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_infoline("NO email account found : success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
-}
-
-
-/*Testcase : uts_Email_Free_Mail_Info_02
- TestObjective : To validate parameter for free mail info
- APIs Tested : int email_free_mail_data(email_mail_data_t** mail_list, int count)
- */
-
-static void uts_Email_Free_Mail_Info_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_mail_data_t *mail_data = NULL;
-
- tet_infoline("uts_Email_Free_Mail_Info_02 Begin\n");
-
- err_code = email_free_mail_data(NULL, 1);
-
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email free mail info : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email free mail info : Failed \n");
- tet_result(TET_FAIL);
- }
-
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-mail-info.h b/TC/TC_email_service/TC_Message/uts-email-free-mail-info.h
deleted file mode 100755
index 730cd45..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-mail-info.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Free_Mail_Info_01(void);
-static void uts_Email_Free_Mail_Info_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Free_Mail_Info_01, 1}, { uts_Email_Free_Mail_Info_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-mail-list.c b/TC/TC_email_service/TC_Message/uts-email-free-mail-list.c
deleted file mode 100755
index 20f0ecf..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-mail-list.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-free-mail-list.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Free_Mail_List_01
- TestObjective : To Free the MailList Information
- APIs Tested : int email_free_mail_list(email_mail_list_item_t **mail_list, int count)
- */
-
-static void uts_Email_Free_Mail_List_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_infoline("uts_Email_Free_Mail_List_01\n");
-
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
-
-/* err_code = email_free_mail_list(&mail_list , count) */
- free(mail_list);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email free Mail list Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email free mail list failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_printf("Email get mail list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-}
-
-
-/*Testcase : uts_Email_Free_Mail_List_02
- TestObjective : To validate parameter for mail_list in Free the MailList Information
- APIs Tested : int email_free_mail_list(email_mail_list_item_t **mail_list, int count)
- */
-
-static void uts_Email_Free_Mail_List_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 1;
-
- tet_infoline("uts_Email_Free_Mail_List_02\n");
-
- err_code = email_free_mail_list(NULL, count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email free mail list Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email free Mail list failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-mail-list.h b/TC/TC_email_service/TC_Message/uts-email-free-mail-list.h
deleted file mode 100755
index ef2225f..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-mail-list.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Free_Mail_List_01(void);
-static void uts_Email_Free_Mail_List_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Free_Mail_List_01, 1}, { uts_Email_Free_Mail_List_02, 2}, {NULL, 0}
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-mailbox.c b/TC/TC_email_service/TC_Message/uts-email-free-mailbox.c
deleted file mode 100755
index 9a293ec..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-mailbox.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-free-mailbox.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Free_Mailbox_01
- TestObjective : Free allocated memory for mailbox information.
- APIs Tested : int email_free_mailbox(email_mailbox_t **mailbox_list, int count)
- */
-
-static void uts_Email_Free_Mailbox_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_mailbox_t *mbox;
- email_account_t *account = NULL ;
-
-
- tet_infoline("utc_Email_Free_Mailbox_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- err_code = email_get_mailbox_list(account[0].account_id, 1, &mbox, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Mailbox List Failed : err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- return;
-
- }
- err_code = email_free_mailbox(&mbox, count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email freeMailbox : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email freet Mailbox : Failed err_code[%d] \n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-
-/*Testcase : uts_Email_Free_Mailbox_02
- TestObjective : validate parameter Free allocated memory for mailbox information.
- APIs Tested : int email_free_mailbox(email_mailbox_t **mailbox_list, int count)
- */
-
-static void uts_Email_Free_Mailbox_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 1;
-
- tet_infoline("utc_Email_Free_Mailbox_02 Begin\n");
-
- err_code = email_free_mailbox(NULL, count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email Free Mailbox : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Free Mailbox : Failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-free-mailbox.h b/TC/TC_email_service/TC_Message/uts-email-free-mailbox.h
deleted file mode 100755
index 031aad0..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-free-mailbox.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Free_Mailbox_01(void);
-static void uts_Email_Free_Mailbox_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Free_Mailbox_01, 1}, { uts_Email_Free_Mailbox_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-attachment-info.c b/TC/TC_email_service/TC_Message/uts-email-get-attachment-info.c
deleted file mode 100755
index e779e4d..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-attachment-info.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-attachment-info.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Attachment_Info_01
- TestObjective : Get a mail attachment
- APIs Tested : int email_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
- */
-
-static void uts_Email_Get_Attachment_Info_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int i = 0;
- email_attachment_data_t *mail_attach_info = NULL;
- email_mail_list_item_t *mail_list = NULL;
- int count = 0;
- email_account_t *account = NULL ;
-
- tet_infoline("uts_Email_Get_Attachment_Info_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- g_accountId = account[i].account_id;
-
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- for (i ; i < count ; i++) {
- if(mail_list[i].attachment_count) {
- err_code = email_get_attachment_data_list(mail_list[i].mail_id, &mail_attach_info, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get attachment info : success\n");
- tet_result(TET_PASS);
- return;
- }else {
- tet_printf("Email get attachment info : Failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- return;
- }
- }
- }
-}
-
-
-/*Testcase : uts_Email_Get_Attachment_Info_02
- TestObjective : Validate Parameter for mailbox in Get a mail attachment
- APIs Tested : int email_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
- */
-
-static void uts_Email_Get_Attachment_Info_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = 1;
- email_attachment_data_t *mail_attach_info = NULL;
- int count = 0;
-
- tet_infoline("uts_Email_Get_Attachment_Info_02 Begin\n");
-
- err_code = email_get_attachment_data_list(0, &mail_attach_info, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get attachment info : success\n");
- tet_result(TET_PASS);
- return;
- }
- else {
- tet_printf("Email get attachment info : Failed \n");
- tet_result(TET_FAIL);
- return;
- }
-
-}
-
-/*Testcase : uts_Email_Get_Attachment_Info_03
- TestObjective : Validate Parameter for mailbox account_id in Get a mail attachment
- APIs Tested : int email_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
- */
-
-static void uts_Email_Get_Attachment_Info_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = 1;
- email_mailbox_t mbox;
- int count = 0;
-
- tet_infoline("uts_Email_Get_Attachment_Info_03 Begin\n");
-
- err_code = email_get_attachment_data_list(1, NULL, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get attachment info : success\n");
- tet_result(TET_PASS);
- return;
- }
- else {
- tet_printf("Email get attachment info : Failed \n");
- tet_result(TET_FAIL);
- return;
- }
-
-}
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-attachment-info.h b/TC/TC_email_service/TC_Message/uts-email-get-attachment-info.h
deleted file mode 100755
index fbc680f..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-attachment-info.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Attachment_Info_01(void);
-static void uts_Email_Get_Attachment_Info_02(void);
-static void uts_Email_Get_Attachment_Info_03(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Attachment_Info_01, 1}, { uts_Email_Get_Attachment_Info_02, 2}, { uts_Email_Get_Attachment_Info_03, 3}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.c b/TC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.c
deleted file mode 100755
index 0f61f18..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-disk-space-usage.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Disk_Space_Usage_01
- TestObjective : To get the total disk usage of emails
- APIs Tested : int email_get_disk_space_usage(unsigned long *total_size)
- */
-
-static void uts_Email_Get_Disk_Space_Usage_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- unsigned long total_size = 0;
-
- tet_infoline("uts_Email_Get_Disk_Space_Usage_01 Begin\n");
-
- err_code = email_get_disk_space_usage(&total_size);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email Get Disk Space Usage success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Disk Space Usage Failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-
-/*Testcase : uts_Email_Get_Disk Space_Usage_02
- TestObjective : To validate parameter for total_size in get disk space usage
- APIs Tested : int email_get_disk_space_usage(unsigned long *total_size)
- */
-
-static void uts_Email_Get_Disk_Space_Usage_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Get_Disk_Space_Usage_02 Begin\n");
-
- err_code = email_get_disk_space_usage(0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email Get Disk Space Usage Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Disk Space Usage failed\n");
- tet_result(TET_FAIL);
- }
-
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.h b/TC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.h
deleted file mode 100755
index 97911eb..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-disk-space-usage.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Disk_Space_Usage_01(void);
-static void uts_Email_Get_Disk_Space_Usage_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- {uts_Email_Get_Disk_Space_Usage_01, 1}, {uts_Email_Get_Disk_Space_Usage_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-info.c b/TC/TC_email_service/TC_Message/uts-email-get-info.c
deleted file mode 100755
index 91f4ca5..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-info.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-info.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Info_01
- TestObjective : To get mail info
- APIs Tested : int email_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data)
- */
-
-static void uts_Email_Get_Info_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_mail_data_t *mail_data = NULL;
- email_mail_list_item_t *mail_list = NULL;
- email_account_t *account = NULL ;
-
- tet_infoline("utc_Email_Get_Info_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- if (count > 0) {
- g_accountId = account[0].account_id;
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail list : success\n");
- if (count > 0) {
- err_code = email_get_mail_data(mail_list[0].mail_id , &mail_data);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail data : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mail data : Failed err_code[%d] \n", err_code);
- tet_result(TET_FAIL);
- }
-
- }
- else {
- tet_infoline("No Mails in mailbox\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get mail list : Failed err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_infoline("NO email account found : success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Info_02
- TestObjective : To validate parameter for mailbox in get mail info
- APIs Tested : int email_get_info(email_mailbox_t *mailbox, int mail_id, email_mail_info_t **info)
- */
-
-static void uts_Email_Get_Info_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = -1;
- email_mail_data_t *mail_data = NULL;
-
- tet_infoline("utc_Email_Get_Info_02 Begin\n");
-
- err_code = email_get_mail_data(mail_id , &mail_data);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get mail data : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mail data : Failed \n");
- tet_result(TET_FAIL);
- }
-
-}
-
-
-/*Testcase : uts_Email_Get_Info_03
- TestObjective : To validate parameter for mail_id in get mail info
- APIs Tested : int email_get_info(email_mailbox_t *mailbox, int mail_id, email_mail_info_t **info)
- */
-
-static void uts_Email_Get_Info_03()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("utc_Email_Get_Info_03 Begin\n");
-
- err_code = email_get_mail_data(1 , NULL);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get mail info : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mail info : Failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-info.h b/TC/TC_email_service/TC_Message/uts-email-get-info.h
deleted file mode 100755
index 6f7755e..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-info.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Info_01(void);
-static void uts_Email_Get_Info_02(void);
-static void uts_Email_Get_Info_03(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Info_01, 1}, { uts_Email_Get_Info_02, 2}, { uts_Email_Get_Info_03, 3}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.c b/TC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.c
deleted file mode 100755
index e238382..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-mail-list-ex.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Mail_List_Ex_01
- TestObjective : Get the Mail List information from DB based on the mailbox mailbox_name
- APIs Tested : int email_get_mail_list_ex(email_list_filter_t *input_filter_list, int input_filter_count, email_list_sorting_rule_t *input_sorting_rule_list,
- int input_sorting_rule_count, int input_start_index, int input_limit_count, email_mail_list_item_t** output_mail_list, int *output_result_count)
- */
-
-static void uts_Email_Get_Mail_List_Ex_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_mail_list_item_t *mail_list = NULL;
- int count = 0;
- int start_index = 0;
- int limit_count = 2;
- email_list_filter_t *filter_list = NULL;
-
- tet_infoline("uts_Email_Get_Mail_Ex_01\n");
-
- filter_list = malloc(sizeof(email_list_filter_t) * 1);
- memset(filter_list, 0 , sizeof(email_list_filter_t) * 1);
-
- filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
- filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE;
- filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
- filter_list[0].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_INBOX;
- filter_list[0].list_filter_item.rule.case_sensitivity = false;
-
- err_code = email_get_mail_list_ex(filter_list, 1, NULL, 0, start_index, limit_count, &mail_list , &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail list ex Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mail list ex failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_list_filter(&filter_list, 1);
-}
-
-
-/*Testcase : uts_Email_Get_Mail_List_Ex_02
- TestObjective : Validate parameter for mail_list in Get the Mail List information from DB based on the mailbox mailbox_name
- APIs Tested : email_get_mail_list_ex(int account_id , const char *mailbox_mailbox_name, int thread_id, int start_index, int limit_count, email_sort_type_t sorting,
- email_mail_list_item_t **mail_list, int *result_count)
- */
-static void uts_Email_Get_Mail_List_Ex_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_mail_list_item_t *mail_list = NULL;
- int count = 0;
- int start_index = 0;
- int limit_count = 2;
-
- tet_infoline("uts_Email_Get_Mail_Ex_02\n");
-
- count = 0;
- err_code = email_get_mail_list_ex(NULL, 1, NULL, 0, start_index, limit_count, &mail_list , &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get mail list ex Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mail list ex failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
-}
-
-/*Testcase : uts_Email_Get_Mail_List_Ex_03
- TestObjective : Validate parameter for result_count in Get the Mail List information from DB based on the mailbox mailbox_name
- APIs Tested : email_get_mail_list_ex(int account_id , const char *mailbox_mailbox_name, int thread_id, int start_index, int limit_count, email_sort_type_t sorting,
- email_mail_list_item_t **mail_list, int *result_count)
- */
-
-static void uts_Email_Get_Mail_List_Ex_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_mail_list_item_t *mail_list = NULL;
- int count = 0;
- int start_index = 0;
- int limit_count = 2 ;
- email_list_filter_t *filter_list = NULL;
-
- tet_infoline("uts_Email_Get_Mail_Ex_03\n");
-
-
- filter_list = malloc(sizeof(email_list_filter_t) * 1);
- memset(filter_list, 0 , sizeof(email_list_filter_t) * 1);
-
- filter_list[0].list_filter_item_type = EMAIL_LIST_FILTER_ITEM_RULE;
- filter_list[0].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE;
- filter_list[0].list_filter_item.rule.rule_type = EMAIL_LIST_FILTER_RULE_EQUAL;
- filter_list[0].list_filter_item.rule.key_value.integer_type_value = EMAIL_MAILBOX_TYPE_INBOX;
- filter_list[0].list_filter_item.rule.case_sensitivity = false;
- count = 0;
- err_code = email_get_mail_list_ex(filter_list, 1, NULL, 0, start_index, limit_count, &mail_list , 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get mail list ex Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get mail list ex failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
- email_free_list_filter(&filter_list, 1);
-
-}
-
-
-
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.h b/TC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.h
deleted file mode 100755
index b0169b7..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-mail-list-ex.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Mail_List_Ex_01(void);
-static void uts_Email_Get_Mail_List_Ex_02(void);
-static void uts_Email_Get_Mail_List_Ex_03(void);
-
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- {uts_Email_Get_Mail_List_Ex_01, 1}, {uts_Email_Get_Mail_List_Ex_02, 2}, {uts_Email_Get_Mail_List_Ex_03, 3}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-mail-list.h b/TC/TC_email_service/TC_Message/uts-email-get-mail-list.h
deleted file mode 100755
index 90c1ec4..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-mail-list.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Mail_List_01(void);
-static void uts_Email_Get_Mail_List_02(void);
-static void uts_Email_Get_Mail_List_03(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- {uts_Email_Get_Mail_List_01, 1}, {uts_Email_Get_Mail_List_02, 2}, {uts_Email_Get_Mail_List_03, 3}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-mailbox-list.c b/TC/TC_email_service/TC_Message/uts-email-get-mailbox-list.c
deleted file mode 100755
index 1dc4a19..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-mailbox-list.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-mailbox-list.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_01
- TestObjective : To Get all mailboxes from account.
- APIs Tested : int email_get_mailbox_list(int account_id, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_mailbox_t *mbox;
- int mailbox_sync_type = 1;
- email_account_t *account = NULL ;
-
-
- tet_infoline("utc_Email_Get_Mailbox_List_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- err_code = email_get_mailbox_list(account[0].account_id, mailbox_sync_type, &mbox, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email Get Mailbox List : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Mailbox List : Failed err_code[%d] \n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_02
- TestObjective : To validate parameter for account_id in Get all mailboxes from account.
- APIs Tested : int email_get_mailbox_list(int account_id, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_mailbox_t *mbox;
- int account_id = -1 ;
-
- tet_infoline("utc_Email_Get_Mailbox_List_02 Begin\n");
-
- err_code = email_get_mailbox_list(account_id, 1, &mbox, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email Get Mailbox List : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Mailbox List : Failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_03
- TestObjective : To validate parameter for mailbox_list in Get all mailboxes from account.
- APIs Tested : int email_get_mailbox_list(int account_id, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_account_t *account = NULL ;
-
-
- tet_infoline("utc_Email_Get_Mailbox_List_03 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- err_code = email_get_mailbox_list(account[0].account_id, 1, NULL, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email Get Mailbox List : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Mailbox List : Failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
-/*Testcase : uts_Email_Get_Mailbox_List_04
- TestObjective : To validate parameter for Get all mailboxes from account.
- APIs Tested : int email_get_mailbox_list(int account_id, email_mailbox_t **mailbox_list, int *count)
- */
-
-static void uts_Email_Get_Mailbox_List_04()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- email_mailbox_t *mbox;
- email_account_t *account = NULL ;
-
-
- tet_infoline("utc_Email_Get_Mailbox_List_04 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
- err_code = email_get_mailbox_list(account[0].account_id, 1, &mbox, 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email Get Mailbox List : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Mailbox List : Failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
-
-
-
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-mailbox-list.h b/TC/TC_email_service/TC_Message/uts-email-get-mailbox-list.h
deleted file mode 100755
index 686eb2e..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-mailbox-list.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Mailbox_List_01(void);
-static void uts_Email_Get_Mailbox_List_02(void);
-static void uts_Email_Get_Mailbox_List_03(void);
-static void uts_Email_Get_Mailbox_List_04(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Mailbox_List_01, 1}, { uts_Email_Get_Mailbox_List_02, 2}, { uts_Email_Get_Mailbox_List_03, 3}, { uts_Email_Get_Mailbox_List_04, 4}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-max-mail-count.c b/TC/TC_email_service/TC_Message/uts-email-get-max-mail-count.c
deleted file mode 100755
index 2cea12c..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-max-mail-count.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-max-mail-count.h"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Max_Mail_Count_01
- TestObjective : To get the maximum count of emails
- APIs Tested : int email_get_max_mail_count(int *Count)
- */
-
-static void uts_Email_Get_Max_Mail_Count_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
-
- tet_infoline("uts_Email_Get_Max_Mail_Count_01 Begin\n");
-
- err_code = email_get_max_mail_count(&count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email Get Max Mail Count success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Max Mail Count Failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Max_Mail_Count_02
- TestObjective : validate parameter
- APIs Tested : int email_get_max_mail_count(int *Count)
- */
-
-static void uts_Email_Get_Max_Mail_Count_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Get_Max_Mail_Count_01 Begin\n");
-
- err_code = email_get_max_mail_count(NULL);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email Get Max Mail Count success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Get Max Mail Count Failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-max-mail-count.h b/TC/TC_email_service/TC_Message/uts-email-get-max-mail-count.h
deleted file mode 100755
index eadcbf4..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-max-mail-count.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Max_Mail_Count_01(void);
-static void uts_Email_Get_Max_Mail_Count_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Max_Mail_Count_01, 1}, { uts_Email_Get_Max_Mail_Count_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-get-thread-information.h b/TC/TC_email_service/TC_Message/uts-email-get-thread-information.h
deleted file mode 100755
index 14fc932..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-get-thread-information.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Thread_Information_01(void);
-static void uts_Email_Get_Thread_Information_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Get_Thread_Information_01, 1}, { uts_Email_Get_Thread_Information_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.c b/TC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.c
deleted file mode 100755
index ac2ee5d..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-move-all-mails-to-folder.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
-
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Move_All_Mails_To_Folder_01
- TestObjective : To move all mails to a mailbox
- APIs Tested : int email_move_all_mails_to_mailbox(int input_source_mailbox_id, int input_target_mailbox_id)
-
- */
-
-static void uts_Email_Move_All_Mails_To_Folder_01()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- email_mailbox_t *src_mailbox = NULL;
- email_mailbox_t *new_mailbox = NULL;
- email_account_t *account = NULL;
- int count = 0;
-
- tet_infoline("uts_Email_Move_All_Mails_To_Folder_01 Begin\n");
- if (!email_get_account_list(&account, &count) || NULL == account || count <= 0) {
- tet_printf("Email Move All Mails To mailbox failed in account list fetch\n");
- tet_result(TET_UNRESOLVED);
- return;
- }
-
- err_code = email_get_mailbox_by_mailbox_type(account[0].account_id, EMAIL_MAILBOX_TYPE_INBOX, &src_mailbox);
- if(err_code != EMAIL_ERROR_NONE) {
- tet_printf("email_get_mailbox_by_mailbox_type failed in uts_Email_Move_All_Mails_To_Folder_01\n");
- tet_result(TET_UNRESOLVED);
- return;
- }
- err_code = email_get_mailbox_by_mailbox_type(account[0].account_id, EMAIL_MAILBOX_TYPE_TRASH, &new_mailbox);
- if(err_code != EMAIL_ERROR_NONE) {
- tet_printf("email_get_mailbox_by_mailbox_type failed in uts_Email_Move_All_Mails_To_Folder_01\n");
- tet_result(TET_UNRESOLVED);
- return;
- }
-
- err_code = email_move_all_mails_to_mailbox(src_mailbox->mailbox_id, new_mailbox->mailbox_id);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email Move All Mails To mailbox success\n");
- tet_result(TET_PASS);
- }
- else {
-
- tet_printf("Email Move All Mails To mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
- if (account && count > 0) {
- email_free_account(&account, count);
- }
-
- if (src_mailbox) {
- email_free_mailbox(&src_mailbox, 1);
- src_mailbox = NULL;
- }
- if (new_mailbox) {
- email_free_mailbox(&new_mailbox, 1);
- new_mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Move_All_Mails_To_Folder_02
- TestObjective : To validate parameter for all mail move to mailbox
- APIs Tested : int email_move_all_mails_to_mailbox(int input_source_mailbox_id, int input_target_mailbox_id)
-
- */
-static void uts_Email_Move_All_Mails_To_Folder_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- int src_mailbox_id = 0; /* src_mailbox is 0 */
- email_mailbox_t *new_mailbox = NULL;
- email_account_t *account = NULL;
- int count = 0;
-
- tet_infoline("uts_Email_Move_All_Mails_To_Folder_02 Begin\n");
- if (!email_get_account_list(&account, &count) || NULL == account || count <= 0) {
- tet_printf("Email Move All Mails To mailbox failed in account list fetch\n");
- tet_result(TET_UNRESOLVED);
- return;
- }
- email_get_mailbox_by_mailbox_type(account[0].account_id, EMAIL_MAILBOX_TYPE_TRASH, &new_mailbox);
-
- err_code = email_move_all_mails_to_mailbox(src_mailbox_id, new_mailbox->mailbox_id);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email Move All Mails To mailbox success\n");
- tet_result(TET_PASS);
- }
- else {
-
- tet_printf("Email Move All Mails To mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
- if (account && count > 0) {
- email_free_account(&account, count);
- }
- if (new_mailbox) {
- email_free_mailbox(&new_mailbox, 1);
- new_mailbox = NULL;
- }
-
-}
-
-/*Testcase : uts_Email_Move_All_Mails_To_Folder_03
- TestObjective : To validate parameter for all mail move to mailbox
- APIs Tested : int email_move_all_mails_to_mailbox(int input_source_mailbox_id, int input_target_mailbox_id)
-
- */
-static void uts_Email_Move_All_Mails_To_Folder_03()
-{
-
- int err_code = EMAIL_ERROR_NONE;
-
- email_mailbox_t *src_mailbox = NULL;
- int new_mailbox_id = 0; /* Destination mailbox is 0 */
- email_account_t *account = NULL;
- int count = 0;
-
- tet_infoline("uts_Email_Move_All_Mails_To_Folder_03 Begin\n");
- if (!email_get_account_list(&account, &count) || NULL == account || count <= 0) {
- tet_printf("Email Move All Mails To mailbox failed in account list fetch\n");
- tet_result(TET_UNRESOLVED);
- return;
- }
- email_get_mailbox_by_mailbox_type(account[0].account_id, EMAIL_MAILBOX_TYPE_INBOX, &src_mailbox);
-
- err_code = email_move_all_mails_to_mailbox(src_mailbox->mailbox_id, new_mailbox_id);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email Move All Mails To mailbox success\n");
- tet_result(TET_PASS);
- }
- else {
-
- tet_printf("Email Move All Mails To mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
- if (account && count > 0) {
- email_free_account(&account, count);
- }
- if (src_mailbox) {
- email_free_mailbox(&src_mailbox, 1);
- src_mailbox = NULL;
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.h b/TC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.h
deleted file mode 100755
index bbf0098..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-move-all-mails-to-folder.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-mail.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Move_All_Mails_To_Folder_01(void);
-static void uts_Email_Move_All_Mails_To_Folder_02(void);
-static void uts_Email_Move_All_Mails_To_Folder_03(void);
-
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Move_All_Mails_To_Folder_01, 1}, { uts_Email_Move_All_Mails_To_Folder_02, 2}, { uts_Email_Move_All_Mails_To_Folder_03, 3}, {NULL, 0}
-
-};
diff --git a/TC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.c b/TC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.c
deleted file mode 100755
index 23f26ae..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-move-mail-to-folder.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
-
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-/*Testcase : uts_Email_Move_Mail_To_Folder_01
- TestObjective : To move mails to a mailbox
- APIs Tested : int email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id)
- */
-
-static void uts_Email_Move_Mail_To_Folder_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_ids[] = {1, 2};
- int num = 0;
- int new_mailbox_id = 0;
- int count = 0;
- email_mailbox_t mbox;
- email_mail_list_item_t *mail_list = NULL;
- int mailbox_type = EMAIL_MAILBOX_TYPE_TRASH;
- email_mailbox_t *pMailbox = NULL;
-
- tet_infoline("uts_Email_Move_Mail_To_Folder_01 Begin\n");
-
- if (g_accountId <= 0) {
- tet_infoline("g_accountId is invalid\n");
- tet_result(TET_UNRESOLVED);
- }
-
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(g_accountId, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("uts_Email_Get_Mail_List_03 Failed : err_code[%d]", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId , mailbox_type, &pMailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- mail_ids[0] = mail_list[0].mail_id;
- num = 1;
- new_mailbox_id = pMailbox->mailbox_id;
-
- tet_printf("New mailbox : new_mailbox_id[%d]\n", new_mailbox_id);
-
- err_code = email_move_mail_to_mailbox(mail_ids, num, new_mailbox_id);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email Move Mail To mailbox success\n");
- tet_result(TET_PASS);
- }
- else {
-
- tet_printf("Email Move Mail To mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- if (pMailbox) {
- email_free_mailbox(&pMailbox, 1);
- pMailbox = NULL;
- }
-
-}
-
-
-/*Testcase : uts_Email_Move_Mail_To_Folder_02
- TestObjective : To validate parameter for mail move to mailbox
- APIs Tested : int email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id)
- */
-static void uts_Email_Move_Mail_To_Folder_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int *mail_ids = NULL; /* mail ids initialized to NULL*/
- int num = 2;
- email_mailbox_t *pMailbox = NULL;
- int count = 0;
-
- tet_infoline("uts_Email_Move_Mail_To_Folder_02 Begin\n");
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId , EMAIL_MAILBOX_TYPE_TRASH, &pMailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- err_code = email_move_mail_to_mailbox(mail_ids, num, pMailbox->mailbox_id);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email Move Mail To mailbox success\n");
- tet_result(TET_PASS);
- }
- else {
-
- tet_printf("Email Move Mail To mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- if (pMailbox) {
- email_free_mailbox(&pMailbox, 1);
- pMailbox = NULL;
- }
-}
-
-/*Testcase : uts_Email_Move_Mail_To_Folder_03
- TestObjective : To validate parameter for mail move to mailbox
- APIs Tested : int email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id)
- */
-static void uts_Email_Move_Mail_To_Folder_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_ids[] = {1, 2};
- int num = -1; /* Boundary condition test */
- email_mailbox_t *pMailbox = NULL;
- int count = 0;
-
- tet_infoline("uts_Email_Move_Mail_To_Folder_03 Begin\n");
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId , EMAIL_MAILBOX_TYPE_TRASH, &pMailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- err_code = email_move_mail_to_mailbox(mail_ids, num, pMailbox->mailbox_id);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email Move Mail To mailbox success\n");
- tet_result(TET_PASS);
- }
- else {
-
- tet_printf("Email Move Mail To mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- if (pMailbox) {
- email_free_mailbox(&pMailbox, 1);
- pMailbox = NULL;
- }
-}
-
-/*Testcase : uts_Email_Move_Mail_To_Folder_04
- TestObjective : To validate parameter for mail move to mailbox
- APIs Tested : int email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id)
- */
-static void uts_Email_Move_Mail_To_Folder_04()
-
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_ids[] = {1, 2};
- int num = 2;
- int input_target_mailbox_id = 0; /* input_target_mailbox_id as 0 */
-
- tet_infoline("uts_Email_Move_Mail_To_Folder_04 Begin\n");
-
- err_code = email_move_mail_to_mailbox(mail_ids, num, input_target_mailbox_id);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email Move Mail To mailbox success\n");
- tet_result(TET_PASS);
- }
- else {
-
- tet_printf("Email Move Mail To mailbox failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.h b/TC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.h
deleted file mode 100755
index 4ec3c9b..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-move-mail-to-folder.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-mail.h"
-
-
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Move_Mail_To_Folder_01(void);
-static void uts_Email_Move_Mail_To_Folder_02(void);
-static void uts_Email_Move_Mail_To_Folder_03(void);
-static void uts_Email_Move_Mail_To_Folder_04(void);
-
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Move_Mail_To_Folder_01, 1}, { uts_Email_Move_Mail_To_Folder_02, 2}, { uts_Email_Move_Mail_To_Folder_03, 3}, { uts_Email_Move_Mail_To_Folder_04, 4}, {NULL, 0}
-
-};
diff --git a/TC/TC_email_service/TC_Message/uts-email-send-retry.c b/TC/TC_email_service/TC_Message/uts-email-send-retry.c
deleted file mode 100755
index 791ae72..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-send-retry.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-send-retry.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Send_Retry_01
- TestObjective : To Retry mail send
- APIs Tested : int email_retry_sending_mail(int mail_id, int timeout_in_sec)
- */
-
-static void uts_Email_Send_Retry_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_infoline("uts_Email_Send_Retry_01\n");
-
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- if (count > 0) {
-
- err_code = email_retry_sending_mail(mail_list[i].mail_id , 3);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email Send Retry Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Send Retry failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_infoline("No mail found\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get mail list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-}
-
-
-/*Testcase : uts_Email_Send_Retry_02
- TestObjective : To validate parameter for mail_id in Retry mail send
- APIs Tested : int email_retry_sending_mail(int mail_id, int timeout_in_sec)
- */
-
-static void uts_Email_Send_Retry_02()
-{
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Send_Retry_02\n");
-
- err_code = email_retry_sending_mail(-1, 2);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email Send Retry Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email Send Retry failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-send-retry.h b/TC/TC_email_service/TC_Message/uts-email-send-retry.h
deleted file mode 100755
index 5f447ca..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-send-retry.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Send_Retry_01(void);
-static void uts_Email_Send_Retry_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Send_Retry_01, 1}, { uts_Email_Send_Retry_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-update-message.c b/TC/TC_email_service/TC_Message/uts-email-update-message.c
deleted file mode 100755
index 2fc65d9..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-update-message.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-update-message.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_printf("\n TC startup");
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
-
- g_accountId = 0;
- /* Check if there are any accounts and Get account id. If there is no account in the db, add new dummy account data to the d */
- err_code = email_get_account_list(&pAccount, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- /* get the account id from the d */
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else if (EMAIL_ERROR_ACCOUNT_NOT_FOUND == err_code) {
- /* Add new dummy account to the db if there is no account in the d */
- tet_printf("Add new account\n");
- g_accountId = uts_Email_Add_Dummy_Account_01();
- tet_printf("g_accountId[%d]\n", g_accountId);
- }
- else {
- tet_printf("email_get_account_list() failed : err_code[%d]\n", err_code);
- }
-
- /* Check if there are any mails and Get mail id of one of them. If there is no mail in the db, add new dummy mail data to the d */
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(ALL_ACCOUNT, 0, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("email_get_mail_list() success\n");
- }
- else if (EMAIL_ERROR_MAIL_NOT_FOUND == err_code) {
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Dummy_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Dummy_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Dummy_Message_02() failed : err_code[%d]\n", err_code);
- }
- }
- else {
- tet_printf("Email Get Mail List Failed : err_code[%d]", err_code);
- }
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else {
- tet_infoline("Email service not started\n");
- }
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Update_Message_01
- TestObjective : To update message
- APIs Tested : int email_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas);
- */
-
-static void uts_Email_Update_Message_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int count = 0;
- email_account_t *account = NULL ;
- email_mail_list_item_t *mail_list = NULL;
- email_mail_data_t *mail_data = NULL;
- email_attachment_data_t *test_attachment_data_list = NULL;
- email_meeting_request_t *meeting_req = NULL;
- int test_attachment_data_count = 0;
-
- tet_infoline("uts_Email_Update_Message_01 Begin\n");
-
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get account list success\n");
- if (count > 0) {
- count = 0;
- err_code = uts_Email_Get_Mail_List_03(account[0].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail list : success\n");
- if (count > 0) {
- err_code = email_get_mail_data(mail_list[0].mail_id , &mail_data);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail success\n");
-
- mail_data->full_address_cc = strdup("samsungtest09@gmail.com");
-
- err_code = email_update_mail(mail_data, NULL, 0, NULL, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("email_update_mail : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("email_update_mail failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_printf("Email get mail failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- }
- }
- else {
- tet_printf("Email get mail list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-// email_free_mail_list(&mail_list, count)
- free(mail_list);
- }
- else {
- tet_infoline("NO email account found : success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get account list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
-}
-
-
-/*Testcase : uts_Email_Update_Message_02
- TestObjective : To validate parameter for mail_id in update message
- APIs Tested : int email_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas);
- */
-
-static void uts_Email_Update_Message_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int mail_id = 0;
-
- tet_infoline("uts_Email_Update_Message_02 Begin\n");
-
- err_code = email_update_mail(NULL, NULL, 0, NULL, 0);
-
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email update message : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email update message : failed \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Message/uts-email-update-message.h b/TC/TC_email_service/TC_Message/uts-email-update-message.h
deleted file mode 100755
index 64fd8b8..0000000
--- a/TC/TC_email_service/TC_Message/uts-email-update-message.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Update_Message_01(void);
-static void uts_Email_Update_Message_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = {
- { uts_Email_Update_Message_01, 1}, { uts_Email_Update_Message_02, 2}, {NULL, 0}
-
-
-};
-
diff --git a/TC/TC_email_service/TC_Network/Makefile b/TC/TC_email_service/TC_Network/Makefile
deleted file mode 100755
index 2f3c575..0000000
--- a/TC/TC_email_service/TC_Network/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-###################################################
-# add your TestCase List Here
-#
-# e.g.,
-# TC1 = utc_frameworkName_apiName_func
-# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
-TARGETS = uts_email_send_mail \
- uts_email_send_saved \
- uts_email_sync_header \
- uts_email_sync_header_for_all_account \
- uts_email_download_body \
- uts_email_download_attachment \
- uts_email_get_imap_folder_list \
- uts_email_cancel_job \
- uts_email_get_network_status \
- uts_email_get_pending_job \
-
-###################################################
-# add your Package Config Info Here
-#
-# e.g.,
-# PKGS=calendar
-PKGS= email-service
-
-LIBS = `pkg-config --libs $(PKGS)`
-LIBS += `pkg-config --libs glib-2.0`
-LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
-LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
-
-INCS = -I. `pkg-config --cflags $(PKGS)`
-INCS += -I. `pkg-config --cflags glib-2.0`
-INCS += -I$(TET_ROOT)/inc/tet3
-INCS += -I$(TET_SUITE_ROOT)/TC_email_service/TC_Utility
-
-UTIL_SRC = $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-dummy-utility.c
-UTIL_SRC += $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-real-utility.c
-
-CFLAGS = $(INCS)
-CFLAGS += -D_TETWARE_MODE
-LDFLAGS = $(LIBS)
-
-###################################################
-# Modify here
-# depending on the Test Case you want to build
-#
-# e.g.,
-# TCLIST = $(TC1) $(TC2)
-all : $(TARGETS)
-
-$(TARGETS) : %: %.c
- $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
-
-clean :
- rm -rf $(TARGETS)
-
diff --git a/TC/TC_email_service/TC_Network/tslist b/TC/TC_email_service/TC_Network/tslist
deleted file mode 100755
index 072193d..0000000
--- a/TC/TC_email_service/TC_Network/tslist
+++ /dev/null
@@ -1,10 +0,0 @@
-uts_email_get_network_status
-uts_email_get_pending_job
-uts_email_send_mail
-uts_email_send_saved
-uts_email_sync_header
-uts_email_sync_header_for_all_account
-uts_email_download_body
-uts_email_download_attachment
-uts_email_get_imap_folder_list
-uts_email_cancel_job
diff --git a/TC/TC_email_service/TC_Network/uts_email_activate_pdp.c b/TC/TC_email_service/TC_Network/uts_email_activate_pdp.c
deleted file mode 100755
index fa3c016..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_activate_pdp.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_activate_pdp.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Activate_Pdp_01
- TestObjective : To activate pdp
- APIs Tested : int email_activate_pdp(int thread_type)
- */
-
-static void uts_Email_Activate_Pdp_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int thread_type = 1;
-
- tet_infoline("uts_Email_Activate_Pdp_01 Begin\n");
-
- err_code = email_activate_pdp(thread_type);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email activate pdp : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email activate pdp failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Activate_Pdp_02
- TestObjective : To validate parameter for activate pdp
- APIs Tested : int email_activate_pdp(int thread_type)
- */
-
-static void uts_Email_Activate_Pdp_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int thread_type = -1;
-
- tet_infoline("uts_Email_Activate_pdp_01 Begin\n");
-
- err_code = email_activate_pdp(thread_type);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email activate pdp : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email activate pdp failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_activate_pdp.h b/TC/TC_email_service/TC_Network/uts_email_activate_pdp.h
deleted file mode 100755
index 2fbb3ba..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_activate_pdp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Activate_Pdp_01(void);
-static void uts_Email_Activate_Pdp_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Activate_Pdp_01, 1}, {uts_Email_Activate_Pdp_02, 2}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_cancel_job.c b/TC/TC_email_service/TC_Network/uts_email_cancel_job.c
deleted file mode 100755
index e16c965..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_cancel_job.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_cancel_job.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_email_cancel_job_01
- TestObjective : To cancel the ongoing job
- APIs Tested : int email_cancel_job(int account_id, int handle)
- */
-
-static void uts_Email_Cancel_Job_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle = 0;
-
- tet_infoline("uts_Email_cancel_job_01 Begin\n");
-
- err_code = email_sync_header_for_all_account(&handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email sync mail header for all account : success\n");
- err_code = email_cancel_job(0, handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email cancel job : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email cancel job failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_printf("Email sync mail header for all account failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-}
-
-
-/*Testcase : uts_email_cancel_job_02
- TestObjective : To validate the parameter for account id in cancel the ongoing job
- APIs Tested : int email_cancel_job(int account_id, int handle)
- */
-static void uts_Email_Cancel_Job_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int account_id = -1;
- int handle;
-
- tet_infoline("uts_Email_cancel_job_10 Begin\n");
-
- err_code = email_sync_header_for_all_account(&handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email sync mail header for all account : success\n");
- err_code = email_cancel_job(account_id, handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email cancel job : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email cancel job failed : \n");
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_printf("Email sync mail header for all account failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_cancel_job.h b/TC/TC_email_service/TC_Network/uts_email_cancel_job.h
deleted file mode 100755
index 2165ee3..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_cancel_job.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Cancel_Job_01(void);
-static void uts_Email_Cancel_Job_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Cancel_Job_01, 1}, {uts_Email_Cancel_Job_02, 2}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_deactivate_pdp.c b/TC/TC_email_service/TC_Network/uts_email_deactivate_pdp.c
deleted file mode 100755
index 7e292ff..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_deactivate_pdp.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_deactivate_pdp.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Deactivate_Pdp_01
- TestObjective : To Deactivate pdp
- APIs Tested : int email_deactivate_pdp(int thread_type)
- */
-
-static void uts_Email_Deactivate_Pdp_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int thread_type = 1;
-
- tet_infoline("uts_Email_Deactivate_Pdp_01 Begin\n");
-
- err_code = email_deactivate_pdp(thread_type);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email deactivate pdp : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email deactivate pdp failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Deactivate_Pdp_02
- TestObjective : To validate parameter for deactivate pdp
- APIs Tested : int email_deactivate_pdp(int thread_type)
- */
-
-static void uts_Email_Deactivate_Pdp_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int thread_type = -1;
-
- tet_infoline("uts_Email_Deactivate_pdp_01 Begin\n");
-
- err_code = email_deactivate_pdp(thread_type);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email deactivate pdp : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email deactivate pdp failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_deactivate_pdp.h b/TC/TC_email_service/TC_Network/uts_email_deactivate_pdp.h
deleted file mode 100755
index 2afc147..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_deactivate_pdp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Deactivate_Pdp_01(void);
-static void uts_Email_Deactivate_Pdp_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Deactivate_Pdp_01, 1}, {uts_Email_Deactivate_Pdp_02, 2}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_download_attachment.c b/TC/TC_email_service/TC_Network/uts_email_download_attachment.c
deleted file mode 100755
index cba5f38..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_download_attachment.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_download_attachment.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-int mail_id ;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- mail_id = uts_Email_Add_Real_Message_02();
- }
- else {
- g_accountId = pAccount[i].account_id;
- mail_id = uts_Email_Add_Real_Message_02();
-
- }
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_email_download_attachment_01
- TestObjective : To download attachment part of email
- APIs Tested : int email_download_attachment(int mail_id, int nth, unsigned* handle)
- */
-static void uts_Email_Download_Attachment_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int i = 0;
- email_mail_list_item_t *mail_list = NULL;
- int count = 0;
-
- tet_infoline("uts_Email_Download_Attachment_01 Begin\n");
-
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE != err_code || count < 0) {
- tet_printf("Email Get Account List Failed : err_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return;
- }
-
- for (i ; i < count ; i++) {
- if(mail_list[i].attachment_count) {
- err_code = email_download_attachment(mail_list[i].mail_id, 1, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email download mail attachment success\n");
- tet_result(TET_PASS);
- return ;
- }
- else
- {
- tet_printf("Email download mail attachment failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- return;
- }
- }
- }
-}
-
-
-
-/*Testcase : uts_email_download_attachment_02
- TestObjective : To validate parameter account_id for email download attachment
- APIs Tested : int email_download_attachment(int mail_id, int nth, unsigned* handle)
- */
-static void uts_Email_Download_Attachment_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int mail_id = 0; /* validation fiel */
-
- tet_infoline("uts_Email_Download_Attachment_02 Begin\n");
-
- err_code = email_download_attachment(mail_id, 1, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email download mail attachment success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email download attachment failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-
-
-/*Testcase : uts_email_download_attachment_03
- TestObjective : To validate parameter mailbox for email download attachment
- APIs Tested : int email_download_attachment(int mail_id, int nth, unsigned* handle)
- */
-static void uts_Email_Download_Attachment_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
-
- tet_infoline("uts_Email_Download_Attachment_03 Begin\n");
-
-
- err_code = email_download_attachment(1, 0, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email download mail attachment success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email download attachment failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
diff --git a/TC/TC_email_service/TC_Network/uts_email_download_attachment.h b/TC/TC_email_service/TC_Network/uts_email_download_attachment.h
deleted file mode 100755
index dc42faf..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_download_attachment.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Download_Attachment_01(void);
-static void uts_Email_Download_Attachment_02(void);
-static void uts_Email_Download_Attachment_03(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Download_Attachment_01, 1}, {uts_Email_Download_Attachment_02, 2}, {uts_Email_Download_Attachment_03, 3}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_download_body.c b/TC/TC_email_service/TC_Network/uts_email_download_body.c
deleted file mode 100755
index 9b3b953..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_download_body.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_download_body.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- uts_Email_Add_Real_Message_02();
- }
- else {
- g_accountId = pAccount[i].account_id;
- uts_Email_Add_Real_Message_02();
- }
- email_free_account(&pAccount, count);
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Download_Body_01
- TestObjective : To download email body
- APIs Tested : int email_download_body(int mail_id, int with_attachment, unsigned* handle)
- */
-static void uts_Email_Download_Body_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int count = 0;
- int i = 0;
- email_account_t *account = NULL ;
- email_mail_list_item_t *mail_list = NULL;
-
- tet_infoline("uts_Email_Download_Body_01 Begin\n");
-
- err_code = uts_Email_Get_Mail_List_03(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mail_list, &count, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get mail list : success\n");
- for (i = 0 ;i<count ; i++) {
- /* if (mail_list[i].text_download_yn == 0 */ {
- tet_printf("mail_id[%d]\n", mail_list[i].mail_id);
- err_code = email_download_body( mail_list[i].mail_id, 0, &handle);
- i = count;
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email download mail body success\n");
- tet_result(TET_PASS);
- return;
- }
- else {
- tet_printf("Email download body failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- return;
- }
- }
- }
-
-/* email_free_mail_list(&mail_list, count) */
- free(mail_list);
- }
- else {
- tet_printf("Email get mail list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-}
-
-
-
-/*Testcase : uts_Email_Download_Body_02
- TestObjective : To validate parameter for mailbox in email download body
- APIs Tested : int email_download_body(int mail_id, int with_attachment, unsigned* handle)
- */
-static void uts_Email_Download_Body_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int mail_id = 1; /* Validation Fiel */
-
- tet_infoline("uts_Email_Download_Body_02 Begin\n");
-
- err_code = email_download_body(mail_id, 0, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email download mail body success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email download body failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Download_Body_03
- TestObjective : To validate parameter for account id in email download body
- APIs Tested : int email_download_body(int mail_id, int with_attachment, unsigned* handle)
- */
-static void uts_Email_Download_Body_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int mail_id = 1;
-
- tet_infoline("uts_Email_Download_Body_03 Begin\n");
-
- err_code = email_download_body(mail_id, 0, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email download mail body success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email download body failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-
-
-/*Testcase : uts_Email_Download_Body_04
- TestObjective : To validate parameter for mail_id in email download body
- APIs Tested : int email_download_body(int mail_id, int with_attachment, unsigned* handle)
- */
-static void uts_Email_Download_Body_04()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int mail_id = -1;
-
- tet_infoline("uts_Email_Download_Body_04 Begin\n");
-
- err_code = email_download_body(mail_id, 0, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email download mail body success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email download body failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_download_body.h b/TC/TC_email_service/TC_Network/uts_email_download_body.h
deleted file mode 100755
index fe21204..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_download_body.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Download_Body_01(void);
-static void uts_Email_Download_Body_04(void);
-static void uts_Email_Download_Body_03(void);
-static void uts_Email_Download_Body_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Download_Body_01, 1}, {uts_Email_Download_Body_02, 1}, {uts_Email_Download_Body_03, 1}, {uts_Email_Download_Body_04, 1}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.c b/TC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.c
deleted file mode 100755
index d2081ba..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_get_imap_folder_list.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Get_Imap_Folder_List_01
- TestObjective : To get imap mailbox list
- APIs Tested : int email_get_imap_mailbox_list(int account_id, unsigned *handle)
- */
-
-static void uts_Email_Get_Imap_Folder_List_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_account_t *account = NULL ;
- int count = 0;
-
- tet_infoline("uts_email_get_imap_folder_list_01 Begin\n");
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count <=0 ) {
- tet_printf("email_get_account_list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- err_code = email_sync_imap_mailbox_list(account[0].account_id, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get Imap mailbox list : success\n ");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get Imap mailbox list : failed err_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
-
-/*Testcase : uts_email_get_imap_folder_list_02
- TestObjective : To validate parametr for account_id in get imap mailbox list
- APIs Tested : int email_get_imap_mailbox_list(int account_id, unsigned *handle)
- */
-
-static void uts_Email_Get_Imap_Folder_List_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int account_id = -1;
-
-
- tet_infoline("uts_email_get_imap_folder_list_02 Begin\n");
-
-
- err_code = email_sync_imap_mailbox_list(account_id, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get Imap mailbox list : success\n ");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get Imap mailbox list : failed \n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.h b/TC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.h
deleted file mode 100755
index 9d11bfa..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_get_imap_folder_list.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Get_Imap_Folder_List_01(void);
-static void uts_Email_Get_Imap_Folder_List_02(void);
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Get_Imap_Folder_List_01, 1}, {uts_Email_Get_Imap_Folder_List_02, 2}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_get_network_status.c b/TC/TC_email_service/TC_Network/uts_email_get_network_status.c
deleted file mode 100755
index a183862..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_get_network_status.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_get_network_status.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Get_Network_Status_01
- TestObjective : To get network status
- APIs Tested : int email_get_network_status(int *on_sending, int *on_receiving)
- */
-
-static void uts_Email_Get_Network_Status_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int on_sending = 0;
- int on_receiving = 0;
-
- tet_infoline("uts_email_get_network_status_01 Begin\n");
-
- err_code = email_get_network_status(&on_sending, &on_receiving);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email get Network status : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get Network status failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_get_network_status.h b/TC/TC_email_service/TC_Network/uts_email_get_network_status.h
deleted file mode 100755
index a3e69fb..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_get_network_status.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Get_Network_Status_01(void);
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Get_Network_Status_01, 1}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_get_pending_job.c b/TC/TC_email_service/TC_Network/uts_email_get_pending_job.c
deleted file mode 100755
index cde82fe..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_get_pending_job.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_get_pending_job.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Get_Pending_job_01
- TestObjective : To get pending job list
- APIs Tested : int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t *status)
- */
-
-static void uts_Email_Get_Pending_Job_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle = 0;
-
- tet_infoline("uts_Email_Get_pending_Job_01 Begin\n");
-
- err_code = email_get_pending_job(EMAIL_ACTION_SEND_MAIL, g_accountId, 1, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_printf("Email get pending job : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get pending job failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Pending_Job_02
- TestObjective : To get pending job list
- APIs Tested : int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t *status)
- */
-
-static void uts_Email_Get_Pending_Job_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle = 0;
- int account_id = -1;
- int mail_id = 1;
-
- tet_infoline("uts_Email_Get_Pending_Job_02 Begin\n");
-
- err_code = email_get_pending_job(EMAIL_ACTION_SEND_MAIL, account_id, mail_id, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get pending job : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get pending job failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Pending_Job_03
- TestObjective : To get pending job list
- APIs Tested : int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t *status)
- */
-
-static void uts_Email_Get_Pending_Job_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle = 0;
- int account_id = -1 ;
- int mail_id = 0;
-
- tet_infoline("uts_Email_Network_11 Begin\n");
-
- err_code = email_get_pending_job(EMAIL_ACTION_SEND_MAIL, account_id , mail_id, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get pending job : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get pending job failed : \n");
- tet_result(TET_FAIL);
- }
-}
diff --git a/TC/TC_email_service/TC_Network/uts_email_get_pending_job.h b/TC/TC_email_service/TC_Network/uts_email_get_pending_job.h
deleted file mode 100755
index eebeb02..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_get_pending_job.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Get_Pending_Job_01(void);
-static void uts_Email_Get_Pending_Job_02(void);
-static void uts_Email_Get_Pending_Job_03(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Get_Pending_Job_01, 1}, {uts_Email_Get_Pending_Job_02, 2}, {uts_Email_Get_Pending_Job_03, 3}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_send_mail.c b/TC/TC_email_service/TC_Network/uts_email_send_mail.c
deleted file mode 100755
index 41cd96b..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_send_mail.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_send_mail.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- tet_printf("Add new email\n");
- err_code = uts_Email_Add_Real_Message_02();
- if (EMAIL_ERROR_NONE == err_code) { /* Make db contain at least one mai */
- tet_printf("uts_Email_Add_Real_Message_02() success.\n");
- }
- else {
- tet_printf("uts_Email_Add_Real_Message_02() failed : err_code[%d]\n", err_code);
- }
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-/*Testcase : uts_Email_Send_Mail_01
- TestObjective : To send a mail
- APIs Tested : int email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle)
- */
-
-static void uts_Email_Send_Mail_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_mail_data_t *test_mail_data = NULL;
- email_attachment_data_t *attachment_data = NULL;
- email_meeting_request_t *meeting_req = NULL;
-
- FILE *fp;
- email_option_t option;
- int count = 0;
- int i = 0;
- email_account_t *account = NULL ;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("uts_Email_Send_Mail_01 Begin\n");
-
- memset(&option, 0x00, sizeof(email_option_t));
- option.keep_local_copy = 1;
-
- test_mail_data = malloc(sizeof(email_mail_data_t));
- memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
-
- attachment_data = malloc(sizeof(email_attachment_data_t));
- memset(attachment_data, 0x00, sizeof(email_attachment_data_t));
-
- test_mail_data->account_id = g_accountId;
- test_mail_data->flags_draft_field = 1;
-
- test_mail_data->full_address_from = strdup("<samsungtest09@gmail.com>");
- test_mail_data->full_address_to = strdup("<samsungtest09@gmail.com>");
- test_mail_data->subject = strdup("Test");
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId , EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- return ;
- }
-
- test_mail_data->mailbox_id = mailbox->mailbox_id;
- test_mail_data->mailbox_type = mailbox->mailbox_type;
-
- fp = fopen("/tmp/mail.txt", "w");
- fprintf(fp, "xxxxxxxxx");
- fclose(fp);
-
- test_mail_data->file_path_plain = strdup("/tmp/mail.txt");
- test_mail_data->attachment_count = 1;
-
- fp = fopen("/tmp/attach.txt", "w");
- fprintf(fp, "Simple Attach");
- fclose(fp);
-
- attachment_data->attachment_name = strdup("Attach");
- attachment_data->attachment_path = strdup("/tmp/attach.txt");
-
- err_code = email_add_mail(test_mail_data, attachment_data, 1, NULL, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("email_add_mail Success\n");
- tet_printf("account_id[%d], test_mail_data->mail_id[%d]", g_accountId, test_mail_data->mail_id);
- err_code = email_send_mail(test_mail_data->mail_id, &option, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("email_send_mail : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("email_send_mail failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- }
- else {
- tet_printf("email_add_message failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-
-/*Testcase : uts_Email_Send_Mail_02
- TestObjective : To validate parameter for send a mail
- APIs Tested : int email_send_mail(int mail_id, email_option_t* sending_option, unsigned* handle)
- */
-
-static void uts_Email_Send_Mail_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_option_t option;
-
- tet_infoline("Email Email_send_mail_02 Begin\n");
-
- memset(&option, 0x00, sizeof(email_option_t));
- option.keep_local_copy = 1;
- err_code = email_send_mail(0, &option, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email send mail : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email send mail failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_send_mail.h b/TC/TC_email_service/TC_Network/uts_email_send_mail.h
deleted file mode 100755
index 4070318..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_send_mail.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Send_Mail_01(void);
-static void uts_Email_Send_Mail_02(void);
-
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Send_Mail_01, 1}, {uts_Email_Send_Mail_02, 2}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_send_saved.c b/TC/TC_email_service/TC_Network/uts_email_send_saved.c
deleted file mode 100755
index 2646985..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_send_saved.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_send_saved.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Send_Saved_01
- TestObjective : To send all saved mails
- APIs Tested : int email_send_saved(int account_id, email_option_t *sending_option, unsigned *handle)
- */
-
-static void uts_Email_Send_Saved_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_option_t option;
- email_account_t *account = NULL ;
- int count = 0;
-
- tet_infoline("uts_email_send_saved_01 Begin\n");
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count <=0 ) {
- tet_printf("email_get_account_list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- memset(&option , 0x00, sizeof(email_option_t));
- option.keep_local_copy = 1;
-
- err_code = email_send_saved(account[0].account_id, &option, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email send and saved : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email send and saved failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
-}
-
-/*Testcase : uts_Email_Send_Saved_02
- TestObjective : To validate parameter for account_id in send all saved mails
- APIs Tested : int email_send_saved(int account_id, email_option_t *sending_option, unsigned *handle)
- */
-
-static void uts_Email_Send_Saved_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int account_id = -1;
- email_option_t option;
-
- tet_infoline("uts_email_send_saved_02 Begin\n");
-
- memset(&option , 0x00, sizeof(email_option_t));
- option.keep_local_copy = 1;
-
- err_code = email_send_saved(account_id, &option, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email send and saved : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email send and saved failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_email_send_saved_03
- TestObjective : To validate parameter for sending_option in send all saved mails
- APIs Tested : int email_send_saved(int account_id, email_option_t *sending_option, unsigned *handle)
- */
-
-static void uts_Email_Send_Saved_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
-
- tet_infoline("uts_email_send_saved_03 Begin\n");
-
-
- err_code = email_send_saved(g_accountId, NULL, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email send and saved : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email send and saved failed : \n");
- tet_result(TET_FAIL);
- }
-}
diff --git a/TC/TC_email_service/TC_Network/uts_email_send_saved.h b/TC/TC_email_service/TC_Network/uts_email_send_saved.h
deleted file mode 100755
index b23a007..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_send_saved.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Send_Saved_01(void);
-static void uts_Email_Send_Saved_03(void);
-static void uts_Email_Send_Saved_02(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Send_Saved_01, 1}, {uts_Email_Send_Saved_02, 2}, {uts_Email_Send_Saved_03, 3}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_sync_header.c b/TC/TC_email_service/TC_Network/uts_email_sync_header.c
deleted file mode 100755
index efead29..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_sync_header.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_sync_header.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Real_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : uts_Email_Sync_Header_01
- TestObjective : To download email headers
- APIs Tested : int email_sync_header(int input_account_id, int input_maibox_id, unsigned* handle)
- */
-
-static void uts_Email_Sync_Header_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_mailbox_t *mailbox = NULL;
- email_account_t *account = NULL ;
- int count = 0;
-
- tet_infoline("uts_email_sync_header_01 Begin\n");
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE != err_code || count <=0 ) {
- tet_printf("email_get_account_list failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- err_code = email_get_mailbox_by_mailbox_type(account[0].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- err_code = email_sync_header(g_accountId, mailbox->mailbox_id , &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email sync mail header : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email sync mail header failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Sync_Header_02
- TestObjective : To validate parameter for mailbox account_id in download email headers
- APIs Tested : int email_sync_header(int input_account_id, int input_maibox_id, unsigned* handle)
- */
-
-static void uts_Email_Sync_Header_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_mailbox_t mbox;
- int handle;
-
- tet_infoline("uts_Email_Sync_Header_02 Begin\n");
-
- err_code = email_sync_header(-1, 0, &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email sync mail header : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email sync mail header failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-/*Testcase : uts_Email_Sync_Header_03
- TestObjective : To validate parameter for mailbox in download email headers
- APIs Tested : int email_sync_header(int input_account_id, int input_maibox_id, unsigned* handle)
- */
-
-static void uts_Email_Sync_Header_03()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
-
- tet_infoline("uts_Email_Sync_Header_03 Begin\n");
-
-
- err_code = email_sync_header(-1, -1 , &handle);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email sync mail header : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email sync mail header failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_sync_header.h b/TC/TC_email_service/TC_Network/uts_email_sync_header.h
deleted file mode 100755
index e1361dd..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_sync_header.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Sync_Header_01(void);
-static void uts_Email_Sync_Header_02(void);
-static void uts_Email_Sync_Header_03(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Sync_Header_01, 1}, {uts_Email_Sync_Header_02, 2}, {uts_Email_Sync_Header_03, 3}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.c b/TC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.c
deleted file mode 100755
index 626b73c..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-/***************************************
-* add your header file here
-* e.g.,
-* #include "uts_ApplicationLib_recurGetDayOfWeek_func.h"
-***************************************/
-#include "uts_email_sync_header_for_all_account.h"
-#include "../TC_Utility/uts-email-real-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-
-
-static void startup()
-{
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db())
- tet_infoline("Email open DB success\n");
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
-
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Close DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void uts_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void uts_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-/*Testcase : uts_Eemail_Sync_Header_For_All_Account_01
- TestObjective : To download email headers for all account
- APIs Tested : int email_sync_header_for_all_account(unsigned *handle)
- */
-
-static void uts_Email_Sync_Header_For_All_Account_01()
-{
- int err_code = EMAIL_ERROR_NONE;
- email_mailbox_t mbox;
- int handle;
-
- tet_infoline("uts_email_sync_header_for_all_account_01 Begin\n");
-
- err_code = email_sync_header_for_all_account(&handle);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email sync mail header for all account : success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email sync mail header for all account failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.h b/TC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.h
deleted file mode 100755
index d368267..0000000
--- a/TC/TC_email_service/TC_Network/uts_email_sync_header_for_all_account.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mailbox.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-
-static void uts_Email_Sync_Header_For_All_Account_01(void);
-
-
-
-
-
-struct tet_testlist tet_testlist[] = { {uts_Email_Sync_Header_For_All_Account_01, 1}, {NULL, 0}
-};
diff --git a/TC/TC_email_service/TC_Rule/Makefile b/TC/TC_email_service/TC_Rule/Makefile
deleted file mode 100755
index 4abc2fb..0000000
--- a/TC/TC_email_service/TC_Rule/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-###################################################
-# add your TestCase List Here
-#
-# e.g.,
-# TC1 = utc_frameworkName_apiName_func
-# TC2 = utc_ApplicationLib_recurGetDayOfWeek_func
-TARGETS = uts-email-add-rule \
- uts-email-delete-rule \
- uts-email-get-rule \
- uts-email-get-rule-list \
- uts-email-update-rule \
- uts-email-free-rule
-
-###################################################
-# add your Package Config Info Here
-#
-# e.g.,
-# PKGS=calendar
-PKGS= email-service
-
-LIBS = `pkg-config --libs $(PKGS)`
-LIBS += `pkg-config --libs glib-2.0`
-LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
-LIBS +=-L$(TET_ROOT)/lib/tet3 -lapi_s
-
-INCS = -I. `pkg-config --cflags $(PKGS)`
-INCS += -I. `pkg-config --cflags glib-2.0`
-INCS += -I$(TET_ROOT)/inc/tet3
-INCS += -I$(TET_SUITE_ROOT)/TC_email_service/TC_Utility
-
-UTIL_SRC = $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-dummy-utility.c
-UTIL_SRC += $(TET_SUITE_ROOT)/TC_email_service/TC_Utility/uts-email-real-utility.c
-
-CFLAGS = $(INCS)
-CFLAGS += -D_TETWARE_MODE
-LDFLAGS = $(LIBS)
-
-###################################################
-# Modify here
-# depending on the Test Case you want to build
-#
-# e.g.,
-# TCLIST = $(TC1) $(TC2)
-all : $(TARGETS)
-
-$(TARGETS) : %: %.c
- $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
-
-clean :
- rm -rf $(TARGETS)
-
diff --git a/TC/TC_email_service/TC_Rule/tslist b/TC/TC_email_service/TC_Rule/tslist
deleted file mode 100755
index dc0f06e..0000000
--- a/TC/TC_email_service/TC_Rule/tslist
+++ /dev/null
@@ -1,6 +0,0 @@
-uts-email-add-rule
-uts-email-get-rule
-uts-email-get-rule-list
-uts-email-update-rule
-uts-email-free-rule
-uts-email-delete-rule
diff --git a/TC/TC_email_service/TC_Rule/uts-email-add-rule.c b/TC/TC_email_service/TC_Rule/uts-email-add-rule.c
deleted file mode 100755
index fc6f4c0..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-add-rule.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-add-rule.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count)
- g_accountId = uts_Email_Add_Dummy_Account_01();
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Cloase DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Add_Rule_01
- TestObjective : To add a filter rule to an email account
- APIs Tested : int email_add_rule(email_rule_t *filtering_set)
- */
-
-static void uts_Email_Add_Rule_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
- email_mailbox_t *src_mailbox = NULL;
-
- tet_infoline("uts_Email_Add_Rule_01 Begin\n");
-
- pRule = (email_rule_t *)malloc(sizeof(email_rule_t));
- memset(pRule, 0x00, sizeof(email_rule_t));
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &src_mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- pRule->account_id = g_accountId;
- pRule->type = RULE_TYPE_INCLUDES;
- pRule->value = strdup("a");
- pRule->faction = EMAIL_FILTER_BLOCK;
- pRule->target_mailbox_id = src_mailbox->mailbox_id;
- pRule->flag1 = 1;
- pRule->flag2 = 0;
- err_code = email_add_rule(pRule);
- if (EMAIL_ERROR_NONE == err_code || EMAIL_ERROR_ALREADY_EXISTS == err_code) {
- tet_infoline("Email add rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_rule(&pRule, 1);
-
- if (src_mailbox) {
- email_free_mailbox(&src_mailbox, 1);
- src_mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Add_Rule_02
- TestObjective : To validate parameter for add a filter rule to an email account
- APIs Tested : int email_add_rule(email_rule_t *filtering_set)
- */
-
-static void uts_Email_Add_Rule_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Add_Rule_02 Begin\n");
-
- err_code = email_add_rule(pRule);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email add rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email add rule failed : \n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Rule/uts-email-add-rule.h b/TC/TC_email_service/TC_Rule/uts-email-add-rule.h
deleted file mode 100755
index 71830ee..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-add-rule.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
- #include <string.h>
- #include <stdlib.h>
- #include <sqlite3.h>
- #include "email-api-init.h"
- #include "email-api-account.h"
- #include "email-api-rule.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Add_Rule_01(void);
-static void uts_Email_Add_Rule_02(void);
-
-
-
- struct tet_testlist tet_testlist[] = { {uts_Email_Add_Rule_01, 1}, {uts_Email_Add_Rule_02, 2}, {NULL, 0}
- };
diff --git a/TC/TC_email_service/TC_Rule/uts-email-delete-rule.c b/TC/TC_email_service/TC_Rule/uts-email-delete-rule.c
deleted file mode 100755
index af9f9f3..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-delete-rule.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-delete-rule.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Cloase DB failed\n");
-}
-
-
-
-
-/***************************************
-* add your Test Cases
-* e.g.,
-* static void utc_ApplicationLib_recurGetDayOfWeek_01()
-* {
-* int ret;
-*
-* ret = target_api();
-* if (ret == 1)
-* tet_result(TET_PASS);
-* else
-* tet_result(TET_FAIL);
-* }
-*
-* static void utc_ApplicationLib_recurGetDayOfWeek_02()
-* {
-* code..
-* condition1i
-* tet_result(TET_PASS);
-* condition2
-* tet_result(TET_FAIL);
-* }
-*
-***************************************/
-
-
-/*Testcase : utc_Email_Delete_Rule_01
- TestObjective : To delete filter rule information
- APIs Tested : int email_delete_rule(int filter_id)
- */
-
-static void uts_Email_Delete_Rule_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int count = 0;
- int i = 0;
- email_rule_t *pRule_list = NULL;
- email_rule_t *pRule = NULL;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("uts_Email_Delete_Rule_01 Begin\n");
-
- tet_printf("Email Add rule\n");
- pRule = (email_rule_t *)malloc(sizeof(email_rule_t));
- memset(pRule, 0x00, sizeof(email_rule_t));
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- pRule->account_id = g_accountId;
- pRule->type = RULE_TYPE_INCLUDES;
- pRule->value = strdup("a");
- pRule->faction = EMAIL_FILTER_BLOCK;
- pRule->target_mailbox_id = mailbox->mailbox_id;
- pRule->flag1 = 1;
- pRule->flag2 = 0;
- err_code = email_add_rule(pRule);
- if (EMAIL_ERROR_NONE == err_code || EMAIL_ERROR_ALREADY_EXISTS == err_code) {
- tet_infoline("Email add rule Success\n");
- }
- else {
- tet_printf("Email add rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_rule(&pRule, 1);
-
- tet_printf("Email Get Rule List\n");
- err_code = email_get_rule_list(&pRule_list, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get all filter rule Success\n");
- if (count > 0) {
- tet_printf("Email Delete Rule : rule id [%d]\n", pRule_list[0].filter_id);
- err_code = email_delete_rule(pRule_list[0].filter_id);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email delete filter rule : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete filter rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
-
- }
- else {
- tet_infoline("NO filter rule found : Success\n");
- tet_result(TET_UNRESOLVED);
- }
- }
- else {
- tet_printf("Email get all filter rule failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Delete_Rule_02
- TestObjective : To validate parameter for delete filter rule information
- APIs Tested : int email_delete_rule(int filter_id)
- */
-
-static void uts_Email_Delete_Rule_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Delete_Rule_02 Begin\n");
-
- err_code = email_delete_rule(0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email delete filter rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email delete filter rule failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Rule/uts-email-delete-rule.h b/TC/TC_email_service/TC_Rule/uts-email-delete-rule.h
deleted file mode 100755
index 8e8b883..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-delete-rule.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
- #include <string.h>
- #include <stdlib.h>
- #include <sqlite3.h>
- #include "email-api-init.h"
- #include "email-api-account.h"
- #include "email-api-rule.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Delete_Rule_01(void);
-static void uts_Email_Delete_Rule_02(void);
-
-
-
- struct tet_testlist tet_testlist[] = { {uts_Email_Delete_Rule_01, 1}, {uts_Email_Delete_Rule_02, 2}, {NULL, 0}
- };
diff --git a/TC/TC_email_service/TC_Rule/uts-email-free-rule.c b/TC/TC_email_service/TC_Rule/uts-email-free-rule.c
deleted file mode 100755
index bdbf1a2..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-free-rule.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-free-rule.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Cloase DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Free_Rule_01
- TestObjective : To free allcated memory for a filter rule
- APIs Tested : int email_free_rule(email_rule_t *filtering_set, int count)
- */
-
-static void uts_Email_Free_Rule_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("uts_Email_Free_Rule_01 Begin\n");
-
- pRule = (email_rule_t *)malloc(sizeof(email_rule_t));
- memset(pRule, 0x00, sizeof(email_rule_t));
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- pRule->account_id = g_accountId;
- pRule->type = RULE_TYPE_INCLUDES;
- pRule->value = strdup("a");
- pRule->faction = EMAIL_FILTER_BLOCK;
- pRule->target_mailbox_id = mailbox->mailbox_id;
- pRule->flag1 = 1;
- pRule->flag2 = 0;
-
- err_code = email_free_rule(&pRule, 1);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email free rule success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_infoline("Email free rule failed\n");
- tet_result(TET_FAIL);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-
diff --git a/TC/TC_email_service/TC_Rule/uts-email-free-rule.h b/TC/TC_email_service/TC_Rule/uts-email-free-rule.h
deleted file mode 100755
index 744a546..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-free-rule.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
- #include <string.h>
- #include <stdlib.h>
- #include <sqlite3.h>
- #include "email-api-init.h"
- #include "email-api-account.h"
- #include "email-api-rule.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Free_Rule_01(void);
-
-
-
- struct tet_testlist tet_testlist[] = { {uts_Email_Free_Rule_01, 1}, {NULL, 0}
- };
diff --git a/TC/TC_email_service/TC_Rule/uts-email-get-rule-list.c b/TC/TC_email_service/TC_Rule/uts-email-get-rule-list.c
deleted file mode 100755
index 6651b83..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-get-rule-list.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-rule-list.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Cloase DB failed\n");
-}
-
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Rule_List_01
- TestObjective : To get all filter rule information
- APIs Tested : int email_get_rule_list(email_rule_t **filtering_set, int *count)
- */
-
-static void uts_Email_Get_Rule_List_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int count = 0;
- email_rule_t *pRule_list = NULL;
- email_rule_t *pRule = NULL;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("uts_Email_Get_Rule_List_01 Begin\n");
-
-
- tet_printf("Email Add rule\n");
- pRule = (email_rule_t *)malloc(sizeof(email_rule_t));
- memset(pRule, 0x00, sizeof(email_rule_t));
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- pRule->account_id = g_accountId;
- pRule->type = RULE_TYPE_INCLUDES;
- pRule->value = strdup("a");
- pRule->faction = EMAIL_FILTER_BLOCK;
- pRule->target_mailbox_id = mailbox->mailbox_id;
- pRule->flag1 = 1;
- pRule->flag2 = 0;
- err_code = email_add_rule(pRule);
- if (EMAIL_ERROR_NONE == err_code || EMAIL_ERROR_ALREADY_EXISTS == err_code) {
- tet_infoline("Email add rule Success\n");
- }
- else {
- tet_printf("Email add rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_rule(&pRule, 1);
-
- tet_printf("Email Get Rule List\n");
-
- err_code = email_get_rule_list(&pRule_list, &count);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get all filter rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all filter rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Get_Rule_List_02
- TestObjective : To validate parameter for filtering_set in get all filter rule information
- APIs Tested : int email_get_rule_list(email_rule_t **filtering_set, int *count)
- */
-
-static void uts_Email_Get_Rule_List_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int count = 0;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Get_Rule_List_02 Begin\n");
-
- err_code = email_get_rule_list(NULL, &count);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get all filter rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all filter rule failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Rule_List_03
- TestObjective : To validate parameter for count in get all filter rule information
- APIs Tested : int email_get_rule_list(email_rule_t **filtering_set, int *count)
- */
-
-static void uts_Email_Get_Rule_List_03()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int count = 0;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Get_Rule_List_03 Begin\n");
-
- err_code = email_get_rule_list(&pRule, 0);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get all filter rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get all filter rule failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Rule/uts-email-get-rule-list.h b/TC/TC_email_service/TC_Rule/uts-email-get-rule-list.h
deleted file mode 100755
index 92725c3..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-get-rule-list.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
- #include <string.h>
- #include <stdlib.h>
- #include <sqlite3.h>
- #include "email-api-init.h"
- #include "email-api-account.h"
- #include "email-api-rule.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Rule_List_01(void);
-static void uts_Email_Get_Rule_List_02(void);
-static void uts_Email_Get_Rule_List_03(void);
-
-
-
- struct tet_testlist tet_testlist[] = { {uts_Email_Get_Rule_List_01, 1}, {uts_Email_Get_Rule_List_02, 2}, {uts_Email_Get_Rule_List_03, 3}, {NULL, 0}
- };
diff --git a/TC/TC_email_service/TC_Rule/uts-email-get-rule.c b/TC/TC_email_service/TC_Rule/uts-email-get-rule.c
deleted file mode 100755
index 4924806..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-get-rule.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-get-rule.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Cloase DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Get_Rule_01
- TestObjective : To get filter information
- APIs Tested : int email_get_rule(int filter_id, email_rule_t **filter_info)
- */
-
-static void uts_Email_Get_Rule_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int filter_id = 1;
- email_rule_t *pRule = NULL;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("uts_Email_Get_Rule_01 Begin\n");
-
- tet_printf("Email Add rule\n");
- pRule = (email_rule_t *)malloc(sizeof(email_rule_t));
- memset(pRule, 0x00, sizeof(email_rule_t));
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- pRule->account_id = g_accountId;
- pRule->type = RULE_TYPE_INCLUDES;
- pRule->value = strdup("a");
- pRule->faction = EMAIL_FILTER_BLOCK;
- pRule->target_mailbox_id = mailbox->mailbox_id;
- pRule->flag1 = 1;
- pRule->flag2 = 0;
- err_code = email_add_rule(pRule);
- if (EMAIL_ERROR_NONE == err_code || EMAIL_ERROR_ALREADY_EXISTS == err_code) {
- tet_infoline("Email add rule Success\n");
- }
- else {
- tet_printf("Email add rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_rule(&pRule, 1);
-
- err_code = email_get_rule(filter_id, &pRule);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email get rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Get_Rule_02
- TestObjective : To validate parameter for filter_info in find filter rule to an email account
- APIs Tested : int email_get_rule(int filter_id, email_rule_t **filter_info)
- */
-
-static void uts_Email_Get_Rule_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Get_Rule_02 Begin\n");
-
- err_code = email_get_rule(1, NULL);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get rule failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Get_Rule_03
- TestObjective : To validate parameter for filter_id in find filter rule to an email account
- APIs Tested : int email_get_rule(int filter_id, email_rule_t **filter_info)
- */
-
-static void uts_Email_Get_Rule_03()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Get_Rule_03 Begin\n");
-
- err_code = email_get_rule(0, &pRule);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email get rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email get rule failed\n");
- tet_result(TET_FAIL);
- }
-}
diff --git a/TC/TC_email_service/TC_Rule/uts-email-get-rule.h b/TC/TC_email_service/TC_Rule/uts-email-get-rule.h
deleted file mode 100755
index b007f32..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-get-rule.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
- #include <string.h>
- #include <stdlib.h>
- #include <sqlite3.h>
- #include "email-api-init.h"
- #include "email-api-account.h"
- #include "email-api-rule.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Get_Rule_01(void);
-static void uts_Email_Get_Rule_02(void);
-static void uts_Email_Get_Rule_03(void);
-
-
-
- struct tet_testlist tet_testlist[] = { {uts_Email_Get_Rule_01, 1}, {uts_Email_Get_Rule_02, 2}, {uts_Email_Get_Rule_03, 3}, {NULL, 0}
- };
diff --git a/TC/TC_email_service/TC_Rule/uts-email-update-rule.c b/TC/TC_email_service/TC_Rule/uts-email-update-rule.c
deleted file mode 100755
index 5758faa..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-update-rule.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
-* Copyright (c) 2012 - 2013 Samsung Electronics, Inc.
-* All rights reserved.
-*
-* This software is a confidential and proprietary information of Samsung
-* Electronics, Inc. ("Confidential Information"). You shall not disclose such
-* Confidential Information and shall use it only in accordance with the terms
-* of the license agreement you entered into with Samsung Electronics.
-*/
-
-
-#include "uts-email-update-rule.h"
-#include "../TC_Utility/uts-email-dummy-utility.c"
-
-
-sqlite3 *sqlite_emmb;
-static int g_accountId;
-
-static void startup()
-{
- int err_code = EMAIL_ERROR_NONE;
- int count = 0;
- int i = 0;
- email_account_t *pAccount = NULL ;
-
- tet_printf("\n TC startup");
-
- if (EMAIL_ERROR_NONE == email_service_begin()) {
- tet_infoline("Email service Begin\n");
- if (EMAIL_ERROR_NONE == email_open_db()) {
- tet_infoline("Email open DB success\n");
- err_code = email_get_account_list(&pAccount, &count);
- if (!count) {
- g_accountId = uts_Email_Add_Dummy_Account_01();
- }
- else
- g_accountId = pAccount[i].account_id;
- email_free_account(&pAccount, count);
-
- }
- else
- tet_infoline("Email open DB failed\n");
- }
- else
- tet_infoline("Email service not started\n");
-}
-
-static void cleanup()
-{
- tet_printf("\n TC End");
- if (EMAIL_ERROR_NONE == email_close_db()) {
- tet_infoline("Email Close DB Success\n");
- if (EMAIL_ERROR_NONE == email_service_end())
- tet_infoline("Email service close Success\n");
- else
- tet_infoline("Email service end failed\n");
- }
- else
- tet_infoline("Email Cloase DB failed\n");
-}
-
-
-
-
-
-
-/*Testcase : uts_Email_Update_Rule_01
- TestObjective : To update filter rule information
- APIs Tested : int email_update_rule(int filter_id, email_rule_t *new_set)
- */
-
-static void uts_Email_Update_Rule_01()
-{
- int err_code = EMAIL_ERROR_NONE ;
- int count = 0;
- int i = 0;
- email_rule_t *pRule_list = NULL;
- email_rule_t *pNew_rule;
- email_rule_t *pRule = NULL;
- email_mailbox_t *mailbox = NULL;
-
- tet_infoline("uts_Email_Update_Rule_01 Begin\n");
-
- tet_printf("Email Add rule\n");
- pRule = (email_rule_t *)malloc(sizeof(email_rule_t));
- memset(pRule, 0x00, sizeof(email_rule_t));
-
- err_code = email_get_mailbox_by_mailbox_type(g_accountId, EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
-
- pRule->account_id = g_accountId;
- pRule->type = RULE_TYPE_INCLUDES;
- pRule->value = strdup("a");
- pRule->faction = EMAIL_FILTER_BLOCK;
- pRule->target_mailbox_id = mailbox->mailbox_id;
- pRule->flag1 = 1;
- pRule->flag2 = 0;
- err_code = email_add_rule(pRule);
- if (EMAIL_ERROR_NONE == err_code || EMAIL_ERROR_ALREADY_EXISTS == err_code) {
- tet_infoline("Email add rule Success\n");
- }
- else {
- tet_printf("Email add rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_rule(&pRule, 1);
-
- tet_printf("Email Get Rule List\n");
- err_code = email_get_rule_list(&pRule_list, &count);
- if (EMAIL_ERROR_NONE == err_code && count > 0) {
- tet_infoline("Email get all filter rule Success\n");
- pNew_rule = (email_rule_t *)malloc(sizeof(email_rule_t));
- memset(pNew_rule , 0x00, sizeof(email_rule_t));
-
- pNew_rule->account_id = pRule_list[i].account_id;
- pNew_rule->type = RULE_TYPE_EXACTLY;
- pNew_rule->value = strdup("ab");
- pNew_rule->target_mailbox_id = mailbox->mailbox_id;
- pNew_rule->faction = pRule_list[i].faction;
- pNew_rule->flag1 = pRule_list[i].flag1;
- pNew_rule->flag2 = pRule_list[i].flag2;
-
- tet_printf("Email Update Rule\n");
- err_code = email_update_rule(pRule_list[i].filter_id, pNew_rule);
- if (EMAIL_ERROR_NONE == err_code) {
- tet_infoline("Email update rule : Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email update filter rule failed : error_code[%d]\n", err_code);
- tet_result(TET_FAIL);
- }
- email_free_rule(&pNew_rule, 1);
- }
- else {
- tet_printf("Email get all filter rule failed : error_code[%d]\n", err_code);
- tet_result(TET_UNRESOLVED);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
-/*Testcase : uts_Email_Update_Rule_02
- TestObjective : To validate parameter for new_set in update filter rule information
- APIs Tested : int email_update_rule(int filter_id , email_rule_t *new_set)
- */
-
-static void uts_Email_Update_Rule_02()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Update_Rule_02 Begin\n");
-
- err_code = email_update_rule(1, NULL);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email update filter rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email update filter rule failed\n");
- tet_result(TET_FAIL);
- }
-}
-
-
-/*Testcase : uts_Email_Update_Rule_03
- TestObjective : To validate parameter for filter_id in update filter rule information
- APIs Tested : int email_update_rule(int filter_id , email_rule_t *new_set)
- */
-
-static void uts_Email_Update_Rule_03()
-{
- int err_code = EMAIL_ERROR_NONE ;
- email_rule_t *pRule = NULL;
-
- tet_infoline("uts_Email_Update_Rule_03 Begin\n");
-
- err_code = email_update_rule(0, pRule);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_infoline("Email update filter rule Success\n");
- tet_result(TET_PASS);
- }
- else {
- tet_printf("Email update filter rule failed\n");
- tet_result(TET_FAIL);
- }
-}
-
diff --git a/TC/TC_email_service/TC_Rule/uts-email-update-rule.h b/TC/TC_email_service/TC_Rule/uts-email-update-rule.h
deleted file mode 100755
index fe26b1a..0000000
--- a/TC/TC_email_service/TC_Rule/uts-email-update-rule.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-#include <tet_api.h>
-
- #include <string.h>
- #include <stdlib.h>
- #include <sqlite3.h>
- #include "email-api-init.h"
- #include "email-api-account.h"
- #include "email-api-rule.h"
-
-static void startup(), cleanup();
-void (*tet_startup) () = startup;
-void (*tet_cleanup) () = cleanup;
-
-static void uts_Email_Update_Rule_01(void);
-static void uts_Email_Update_Rule_02(void);
-static void uts_Email_Update_Rule_03(void);
-
-
-
- struct tet_testlist tet_testlist[] = { {uts_Email_Update_Rule_01, 1}, {uts_Email_Update_Rule_02, 2}, {uts_Email_Update_Rule_03, 3}, {NULL, 0}
- };
diff --git a/TC/TC_email_service/TC_Utility/uts-email-dummy-utility.c b/TC/TC_email_service/TC_Utility/uts-email-dummy-utility.c
deleted file mode 100755
index 2590c07..0000000
--- a/TC/TC_email_service/TC_Utility/uts-email-dummy-utility.c
+++ /dev/null
@@ -1,169 +0,0 @@
-#include "uts-email-dummy-utility.h"
-
-
-int uts_Email_Add_Dummy_Account_01()
-{
- email_account_t *account = NULL;
- int err_code = EMAIL_ERROR_NONE;
-
- tet_infoline("uts_Email_Add_Dummy_Account\n");
- account = (email_account_t *)malloc(sizeof(email_account_t));
- if (account) {
- memset(account , 0x00, sizeof(email_account_t));
-
- account->account_name = strdup("Gmail POP");
- account->user_display_name = strdup("samsungtest09");
- account->user_email_address = strdup("samsungtest09@gmail.com");
- account->reply_to_address = strdup("samsungtest09@gmail.com");
- account->return_address = strdup("samsungtest09@gmail.com");
- account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
- account->incoming_server_address = strdup("pop.gmail.com");
- account->incoming_server_port_number = 995;
- account->incoming_server_secure_connection = 1;
- account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_NEW;
- account->incoming_server_user_name = strdup("samsungtest09");
- account->incoming_server_password = strdup("samsung09");
- account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
- account->outgoing_server_address = strdup("smtp.gmail.com");
- account->outgoing_server_port_number = 465;
- account->outgoing_server_secure_connection = 1;
- account->outgoing_server_need_authentication = 1;
- account->outgoing_server_user_name = strdup("samsungtest09");
- account->outgoing_server_password = strdup("samsung09");
- account->pop_before_smtp = 0;
- account->incoming_server_requires_apop = 0;
- account->auto_download_size = 0; /* downloading option, 0 is subject only, 1 is text body, 2 is normal */
- account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3 */
- account->logo_icon_path = NULL;
- account->options.priority = 3;
- account->options.keep_local_copy = 0;
- account->options.req_delivery_receipt = 0;
- account->options.req_read_receipt = 0;
- account->options.download_limit = 0;
- account->options.block_address = 0;
- account->options.display_name_from = NULL;
- account->options.reply_with_body = 0;
- account->options.forward_with_files = 0;
- account->options.add_myname_card = 0;
- account->options.add_signature = 0;
- account->options.signature = strdup("Gmail POP3 Signature");
- account->check_interval = 0;
-
- err_code = email_add_account(account);
- if (EMAIL_ERROR_NONE == err_code) {
- printf("email add account : success\n");
- tet_printf("email add account : success\n");
- return account->account_id;
- }
- else {
- printf("email add account : failed err_code[%d]", err_code);
- tet_printf("email add account : failed err_code[%d]", err_code);
- }
- email_free_account(&account, 1);
- }
- return 0;
-}
-
-
-int uts_Email_Add_Dummy_Message_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
-
- email_mail_data_t *test_mail_data = NULL;
- email_attachment_data_t *attachment_data = NULL;
- email_meeting_request_t *meeting_req = NULL;
- email_mailbox_t *mailbox = NULL;
-
- FILE *fp;
- email_option_t option;
- int count = 0;
- int i = 0;
- email_account_t *account = NULL ;
-
- memset(&option, 0x00, sizeof(email_option_t));
- option.keep_local_copy = 1;
-
- test_mail_data = malloc(sizeof(email_mail_data_t));
- memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
-
- attachment_data = malloc(sizeof(email_attachment_data_t));
- memset(attachment_data, 0x00, sizeof(email_attachment_data_t));
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code && count > 0) {
-
- test_mail_data->account_id = account[i].account_id;
- test_mail_data->flags_draft_field = 1;
-
- test_mail_data->save_status = 1;
- test_mail_data->body_download_status = 1;
-
- test_mail_data->server_mail_id = strdup("TESTMAIL_1");
-
- test_mail_data->full_address_from = strdup("<samsungtest09@gmail.com>");
- test_mail_data->full_address_to = strdup("<samsungtest09@gmail.com>");
- test_mail_data->subject = strdup("Test");
-
- err_code = email_get_mailbox_by_mailbox_type(account[i].account_id , EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- return err_code;
- }
-
- test_mail_data->mailbox_id = mailbox->mailbox_id;
- test_mail_data->mailbox_type = mailbox->mailbox_type;
-
- fp = fopen("/tmp/mail.txt", "w");
- fprintf(fp, "xxxxxxxxx");
- fclose(fp);
- test_mail_data->file_path_plain = strdup("/tmp/mail.txt");
- test_mail_data->attachment_count = 1;
-
- fp = fopen("/tmp/attach.txt", "w");
- fprintf(fp, "Simple Attachment");
- fclose(fp);
-
- attachment_data->attachment_name = strdup("Attach");
- attachment_data->attachment_path = strdup("/tmp/attach.txt");
- attachment_data->save_status = 1;
-
- err_code = email_add_mail(test_mail_data, attachment_data, 1, NULL, 0);
- if (EMAIL_ERROR_NONE == err_code) {
- printf("email add mail : success\n");
- }
- else {
- printf("email add mail : failed err_code[%d]\n", err_code);
- }
- }
- else {
- printf("emaill get account list : failed err_code[%d]", err_code);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-
- return err_code;
-}
-
-int uts_Email_Get_Mail_List_03(int account_id, email_mailbox_type_e mailbox_type, email_mail_list_item_t** mail_list, int* result_count, email_sort_type_t sorting) {
-
- email_mailbox_t *mailbox = NULL;
- int err_code = EMAIL_ERROR_NONE;
-
- if(account_id != ALL_ACCOUNT && mailbox_type != 0)
- err_code = email_get_mailbox_by_mailbox_type(account_id , mailbox_type, &mailbox);
-
- if (EMAIL_ERROR_NONE == err_code) {
- err_code = email_get_mail_list(account_id , mailbox ? mailbox->mailbox_id : 0, 0, 0, EMAIL_GET_MAIL_LIST_MAX, sorting, mail_list, result_count);
- }
-
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-
- return err_code;
-
-}
diff --git a/TC/TC_email_service/TC_Utility/uts-email-dummy-utility.h b/TC/TC_email_service/TC_Utility/uts-email-dummy-utility.h
deleted file mode 100755
index 5e82eda..0000000
--- a/TC/TC_email_service/TC_Utility/uts-email-dummy-utility.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-/* #include <tet_api.h */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-//#define email_get_mail_list(account_id, mailbox_name, mail_list, count, sorting) email_get_mail_list_ex(account_id, mailbox_name, EMAIL_LIST_TYPE_NORMAL, -1, -1, sorting, mail_list, count)
-#define EMAIL_GET_MAIL_LIST_MAX 20
-
-int uts_Email_Add_Dummy_Account_01(void);
-int uts_Email_Add_Dummy_Message_02(void);
-int uts_Email_Get_Mail_List_03(int account_id, email_mailbox_type_e mailbox_type, email_mail_list_item_t** mail_list, int* result_count, email_sort_type_t sorting);
-
-/* struct tet_testlist tet_testlist[] = */
-/* */
-/* { uts_Email_Add_Dummy_Account_01, 1} */
-/* { uts_Email_Add_Dummy_Message_02, 2} */
-/* {NULL, 0 */
-/* } */
diff --git a/TC/TC_email_service/TC_Utility/uts-email-real-utility.c b/TC/TC_email_service/TC_Utility/uts-email-real-utility.c
deleted file mode 100755
index 462bcd1..0000000
--- a/TC/TC_email_service/TC_Utility/uts-email-real-utility.c
+++ /dev/null
@@ -1,221 +0,0 @@
-#include "uts-email-real-utility.h"
-
-
-int uts_Email_Add_Real_Account_01()
-{
- email_account_t *account = NULL;
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- int account_id = 0;
-
- tet_infoline("uts_Email_Add_Real_Account_01\n");
-
- /* POP */
- tet_infoline("Add POP3 account\n");
- printf("Add POP3 account\n");
- account = (email_account_t *)malloc(sizeof(email_account_t));
- if (account) {
- memset(account , 0x00, sizeof(email_account_t));
-
- account->account_name = strdup("Gmail POP");
- account->user_display_name = strdup("samsungtest09");
- account->user_email_address = strdup("samsungtest09@gmail.com");
- account->reply_to_address = strdup("samsungtest09@gmail.com");
- account->return_address = strdup("samsungtest09@gmail.com");
- account->incoming_server_type = EMAIL_SERVER_TYPE_POP3;
- account->incoming_server_address = strdup("pop.gmail.com");
- account->incoming_server_port_number = 995;
- account->incoming_server_secure_connection = 1;
- account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_NEW;
- account->incoming_server_user_name = strdup("samsungtest09");
- account->incoming_server_password = strdup("samsung09");
- account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
- account->outgoing_server_address = strdup("smtp.gmail.com");
- account->outgoing_server_port_number = 465;
- account->outgoing_server_secure_connection = 1;
- account->outgoing_server_need_authentication = 1;
- account->outgoing_server_user_name = strdup("samsungtest09");
- account->outgoing_server_password = strdup("samsung09");
- account->pop_before_smtp = 0;
- account->incoming_server_requires_apop = 0;
- account->auto_download_size = 0; /* downloading option, 0 is subject only, 1 is text body, 2 is normal */
- account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3 */
- account->logo_icon_path = NULL;
- account->options.priority = 3;
- account->options.keep_local_copy = 0;
- account->options.req_delivery_receipt = 0;
- account->options.req_read_receipt = 0;
- account->options.download_limit = 0;
- account->options.block_address = 0;
- account->options.display_name_from = NULL;
- account->options.reply_with_body = 0;
- account->options.forward_with_files = 0;
- account->options.add_myname_card = 0;
- account->options.add_signature = 0;
- account->options.signature = strdup("Gmail POP3 Signature");
- account->check_interval = 0;
-
- err_code = email_add_account(account);
- if (EMAIL_ERROR_NONE == err_code) {
- printf("email add account : success\n");
- tet_printf("email add account : success\n");
- /* return account->account_id */
- account_id = account->account_id;
- }
- else {
- printf("email add account : failed err_code[%d]", err_code);
- tet_printf("email add account : failed err_code[%d]", err_code);
- }
- email_free_account(&account, 1);
- }
-
- tet_infoline("Add IMAP4 account\n");
- printf("Add IMAP4 account\n");
- account = (email_account_t *)malloc(sizeof(email_account_t));
- if (account) {
- memset(account , 0x00, sizeof(email_account_t));
-
- account->account_name = strdup("Gmail IMAP");
- account->user_display_name = strdup("samsungtest09");
- account->user_email_address = strdup("samsungtest09@gmail.com");
- account->reply_to_address = strdup("samsungtest09@gmail.com");
- account->return_address = strdup("samsungtest09@gmail.com");
- account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4;
- account->incoming_server_address = strdup("imap.gmail.com");
- account->incoming_server_port_number = 993;
- account->incoming_server_secure_connection = 1;
- account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_NEW;
- account->incoming_server_user_name = strdup("samsungtest09");
- account->incoming_server_password = strdup("samsung09");
- account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP;
- account->outgoing_server_address = strdup("smtp.gmail.com");
- account->outgoing_server_port_number = 465;
- account->outgoing_server_secure_connection = 1;
- account->outgoing_server_need_authentication = 1;
- account->outgoing_server_user_name = strdup("samsungtest09");
- account->outgoing_server_password = strdup("samsung09");
- account->pop_before_smtp = 0;
- account->incoming_server_requires_apop = 0;
- account->auto_download_size = 0; /* downloading option, 0 is subject only, 1 is text body, 2 is normal */
- account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3 */
- account->logo_icon_path = NULL;
- account->options.priority = 3;
- account->options.keep_local_copy = 0;
- account->options.req_delivery_receipt = 0;
- account->options.req_read_receipt = 0;
- account->options.download_limit = 0;
- account->options.block_address = 0;
- account->options.display_name_from = NULL;
- account->options.reply_with_body = 0;
- account->options.forward_with_files = 0;
- account->options.add_myname_card = 0;
- account->options.add_signature = 0;
- account->options.signature = strdup("Gmail IMAP4 Signature");
- account->check_interval = 0;
-
- err_code = email_add_account_with_validation(account, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- /*
- err_code = email_validate_account(account->account_id, &handle);
- if (EMAIL_ERROR_NONE == err_code) {
- printf("email add account success\n");
- return account->account_id;
- }
- else {
-
- printf("email add ccount : Failed err_code[%d]", err_code);
- }
- */
- printf("email add account - in progress\n");
- }
- else {
- printf("email add ccount : Failed err_code[%d]", err_code);
- }
- email_free_account(&account, 1);
- }
-
- return account_id;
-}
-
-
-int uts_Email_Add_Real_Message_02()
-{
- int err_code = EMAIL_ERROR_NONE;
- int handle;
- email_mail_data_t *test_mail_data = NULL;
- email_attachment_data_t *attachment_data = NULL;
- email_meeting_request_t *meeting_req = NULL;
- email_mailbox_t *mailbox = NULL;
-
- FILE *fp;
- email_option_t option;
- int count = 0;
- int i = 0;
- email_account_t *account = NULL ;
-
- memset(&option, 0x00, sizeof(email_option_t));
- option.keep_local_copy = 1;
-
- test_mail_data = malloc(sizeof(email_mail_data_t));
- memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
-
- attachment_data = malloc(sizeof(email_attachment_data_t));
- memset(attachment_data, 0x00, sizeof(email_attachment_data_t));
-
- err_code = email_get_account_list(&account, &count);
- if (EMAIL_ERROR_NONE == err_code && count > 0) {
- test_mail_data->account_id = account[i].account_id;
- test_mail_data->flags_draft_field = 1;
-
- test_mail_data->body_download_status = 1;
-
- test_mail_data->server_mail_id = strdup("testmail_1");
-
- test_mail_data->full_address_from = strdup("<samsungtest09@gmail.com>");
- test_mail_data->full_address_to = strdup("<samsungtest09@gmail.com>");
- test_mail_data->subject = strdup("Test");
-
- err_code = email_get_mailbox_by_mailbox_type(account[i].account_id , EMAIL_MAILBOX_TYPE_INBOX, &mailbox);
- if (EMAIL_ERROR_NONE != err_code) {
- tet_printf("Email get mailbox by mailbox type failed : error_code[%d]\n", err_code);
- return err_code;
- }
-
- test_mail_data->mailbox_id = mailbox->mailbox_id;
- test_mail_data->mailbox_type = mailbox->mailbox_type;
-
- fp = fopen("/tmp/mail.txt", "w");
- fprintf(fp, "xxxxxxxxx");
- fclose(fp);
-
- test_mail_data->file_path_plain = strdup("/tmp/mail.txt");
- test_mail_data->attachment_count = 1;
-
- fp = fopen("/tmp/attach.txt", "w");
- fprintf(fp, "Simple Attachment");
- fclose(fp);
-
- attachment_data->attachment_name = strdup("Attach");
- attachment_data->attachment_path = strdup("/tmp/attach.txt");
- attachment_data->save_status = 1;
-
- err_code = email_add_mail(test_mail_data, attachment_data, 1, NULL, 0);
-
- if (EMAIL_ERROR_NONE == err_code) {
- printf("email add message success\n");
- return test_mail_data->mail_id;
- }
- else {
- printf("email add message : Failed err_code[%d]", err_code);
- }
- }
- else {
- printf("emailccount list : Failed err_code[%d]", err_code);
- }
- if (mailbox) {
- email_free_mailbox(&mailbox, 1);
- mailbox = NULL;
- }
-}
-
-
diff --git a/TC/TC_email_service/TC_Utility/uts-email-real-utility.h b/TC/TC_email_service/TC_Utility/uts-email-real-utility.h
deleted file mode 100755
index 37776c2..0000000
--- a/TC/TC_email_service/TC_Utility/uts-email-real-utility.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2012 - 2013 Samsung Electronics, Co., Ltd.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Co., Ltd. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- */
-
-/* #include <tet_api.h */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include "email-api-init.h"
-#include "email-api-account.h"
-#include "email-api-mail.h"
-
-//#define email_get_mail_list(account_id, mailbox_name, mail_list, count, sorting) email_get_mail_list_ex(account_id, mailbox_name, EMAIL_LIST_TYPE_NORMAL, -1, -1, sorting, mail_list, count)
-
-int uts_Email_Add_Real_Account_01(void);
-int uts_Email_Add_Real_Message_02(void);
-
-/* struct tet_testlist tet_testlist[] = */
-/* */
-/* { uts_Email_Add_Real_Account_01, 1} */
-/* { uts_Email_Add_Real_Message_02, 2} */
-/* {NULL, 0 */
-/* } */
-
-
diff --git a/TC/TC_email_service/_export_env.sh b/TC/TC_email_service/_export_env.sh
deleted file mode 100755
index 119d077..0000000
--- a/TC/TC_email_service/_export_env.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-export ARCH=target
-
-export TET_INSTALL_PATH=/myfiles/download/DTS/TETware # tetware root path
-echo $TET_INSTALL_PATH
-export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target.3.8 # tetware target path
-export PATH=$TET_TARGET_PATH/bin:$PATH
-export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
-
-export TET_ROOT=$TET_TARGET_PATH
-
-set $(pwd)
-export TET_SUITE_ROOT=$1
-echo $TET_SUITE_ROOT
-
-set $(date +%s)
-FILE_NAME_EXTENSION=$1
-echo $TET_SUITE_ROOT
-
-make
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
deleted file mode 100755
index 7a39b14..0000000
--- a/TC/_export_target_env.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-
-export ARCH=target
-
-#export TET_INSTALL_PATH=/opt/slp/TETware # path to mount
-export TET_INSTALL_PATH=/mnt/nfs/tet # path to mount
-export TET_TARGET_PATH=$TET_INSTALL_PATH/tet3.8
-export PATH=$TET_TARGET_PATH/bin:$PATH
-export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
-
-export TET_ROOT=$TET_TARGET_PATH
-
-set $(pwd)
-export TET_SUITE_ROOT=$1
-
-set $(date +%s)
-FILE_NAME_EXTENSION=$1
-
diff --git a/TC/build.sh b/TC/build.sh
deleted file mode 100755
index 439bfde..0000000
--- a/TC/build.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-. ./TC_email_service/_export_env.sh # setting environment variables
-
-echo PATH=$PATH
-echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-echo TET_ROOT=$TET_ROOT
-echo TET_SUITE_ROOT=$TET_SUITE_ROOT
-echo ARCH=$ARCH
-
-export TET_INSTALL_PATH=/git/tet/tet3.8
-
-RESULT_DIR=results-$ARCH
-HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
-JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
-
-mkdir $RESULT_DIR
-
-tcc -c -p ./ # executing tcc, with clean option (-c)
-tcc -b -j $JOURNAL_RESULT -p ./ # executing tcc to build test cases (-b)
-grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result
-
diff --git a/TC/execute.sh b/TC/execute.sh
deleted file mode 100755
index e1ed207..0000000
--- a/TC/execute.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-. ./_export_target_env.sh # setting environment variables
-
-echo PATH=$PATH
-echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-echo TET_ROOT=$TET_ROOT
-echo TET_SUITE_ROOT=$TET_SUITE_ROOT
-echo ARCH=$ARCH
-
-RESULT_DIR=results-$ARCH
-HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
-JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
-
-mkdir $RESULT_DIR
-
-tcc -e -j $JOURNAL_RESULT -p ./ # executing tcc, with –e option
-grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT # reporting the result
-
diff --git a/TC/making_new_tet_scen.py b/TC/making_new_tet_scen.py
deleted file mode 100755
index 8cde490..0000000
--- a/TC/making_new_tet_scen.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/python
-
-#############################################
-# tet_scen auto generator
-#
-# ** argv[1] = TC root
-#############################################
-
-import sys,string,os
-
-
-write_file = open("tet_scen", 'w')
-
-#
-# making new tet_scen
-#
-def making_tet_scen (filename):
- #tmp_list = filename.strip().split('/')
- n_filename = filename.replace(' ', '\\ ')
- #print n_filename
- #new_path = "/"+ sys.argv[1] +"/"+n_filename[2:-6]
- new_path = "/"+n_filename[:-6]
- #print new_path
- file = open(filename, 'r')
- lines = file.readlines()
- for line in lines:
- if len(line.strip()) > 1:
- list = line.strip().split('/')
- #print new_path + list[0]
- #print new_path + list[-1]
- write_file.write("\t"+new_path + list[0]+"\n")
-
-#
-# usage()
-#
-def usage():
- print(" ")
- print("./making_new_tet_scen.py tc_root")
- print("Put the Test Case's root directory.")
- print("Do not include '/' at the end")
- print(" ")
-
-#
-# main()
-#
-def main():
- if len(sys.argv) < 2:
- usage()
- sys.exit(0)
-
- os.system('find '+ sys.argv[1] +' -name "tslist" > tslist.txt')
-
- #write_file = open("tetscen", w)
- write_file.write("# auto generated tet_scen\n")
- write_file.write("all\n")
- write_file.write("\t\"Starting Full Test Suite\"\n")
-
- for file in open("tslist.txt", 'r'):
- #print file.strip()
- making_tet_scen(file.strip())
-
- write_file.write("\t\"Completed Full Test Suite\"\n")
- write_file.write("# EOF\n")
- write_file.close()
- print(" ")
- print("==============================")
- print("New tet_scen file is made~~~~")
- print("==============================")
- print(" ")
-main()
diff --git a/TC/tet_scen b/TC/tet_scen
deleted file mode 100644
index ed179f3..0000000
--- a/TC/tet_scen
+++ /dev/null
@@ -1,61 +0,0 @@
-# auto generated tet_scen
-all
- "Starting Full Test Suite"
- /./TC_email_service/TC_Folder/uts-email-add-mailbox
- /./TC_email_service/TC_Folder/uts-email-get-mailbox-list
- /./TC_email_service/TC_Folder/uts-email-get-mailbox-by-mailboxtype
- /./TC_email_service/TC_Folder/uts-email-delete-mailbox
- /./TC_email_service/TC_Message/uts-email-add-message
- /./TC_email_service/TC_Message/uts-email-add-attachment
- /./TC_email_service/TC_Message/uts-email-get-info
- /./TC_email_service/TC_Message/uts-email-get-attachment-info
- /./TC_email_service/TC_Message/uts-email-get-mail-list-ex
- /./TC_email_service/TC_Message/uts-email-get-disk-space-usage
- /./TC_email_service/TC_Message/uts-email-get-max-mail-count
- /./TC_email_service/TC_Message/uts-email-get-mailbox-list
- /./TC_email_service/TC_Message/uts-email-update-message
- /./TC_email_service/TC_Message/uts-email-count-message
- /./TC_email_service/TC_Message/uts-email-cancel-send-mail
- /./TC_email_service/TC_Message/uts-email-send-retry
- /./TC_email_service/TC_Message/uts-email-move-mail-to-folder
- /./TC_email_service/TC_Message/uts-email-move-all-mails-to-folder
- /./TC_email_service/TC_Message/uts-email-free-mail-info
- /./TC_email_service/TC_Message/uts-email-free-attachment-info
- /./TC_email_service/TC_Message/uts-email-free-mailbox
- /./TC_email_service/TC_Message/uts-email-delete-attachment
- /./TC_email_service/TC_Message/uts-email-delete-message
- /./TC_email_service/TC_Message/uts-email-delete-all-message-in-folder
- /./TC_email_service/TC_Message/uts-email-create-db-full
- /./TC_email_service/TC_Message/uts-email-clear-mail-data
- /./TC_email_service/TC_Account/uts-email-add-account
- /./TC_email_service/TC_Account/uts-email-validate-account
- /./TC_email_service/TC_Account/uts-email-update-account
- /./TC_email_service/TC_Account/uts-email-add-account-with-validation
- /./TC_email_service/TC_Account/uts-email-get-account
- /./TC_email_service/TC_Account/uts-email-get-account-list
- /./TC_email_service/TC_Account/uts-email-free-account
- /./TC_email_service/TC_Account/uts-email-delete-account
- /./TC_email_service/TC_Rule/uts-email-add-rule
- /./TC_email_service/TC_Rule/uts-email-get-rule
- /./TC_email_service/TC_Rule/uts-email-get-rule-list
- /./TC_email_service/TC_Rule/uts-email-update-rule
- /./TC_email_service/TC_Rule/uts-email-free-rule
- /./TC_email_service/TC_Rule/uts-email-delete-rule
- /./TC_email_service/TC_Network/uts_email_get_network_status
- /./TC_email_service/TC_Network/uts_email_get_pending_job
- /./TC_email_service/TC_Network/uts_email_send_mail
- /./TC_email_service/TC_Network/uts_email_send_saved
- /./TC_email_service/TC_Network/uts_email_sync_header
- /./TC_email_service/TC_Network/uts_email_sync_header_for_all_account
- /./TC_email_service/TC_Network/uts_email_download_body
- /./TC_email_service/TC_Network/uts_email_download_attachment
- /./TC_email_service/TC_Network/uts_email_get_imap_folder_list
- /./TC_email_service/TC_Network/uts_email_cancel_job
- /./TC_email_service/TC_Init/uts-email-service-begin
- /./TC_email_service/TC_Init/uts-email-open-db
- /./TC_email_service/TC_Init/uts-email-init-storage
- /./TC_email_service/TC_Init/uts-email-ping-service
- /./TC_email_service/TC_Init/uts-email-close-db
- /./TC_email_service/TC_Init/uts-email-service-end
- "Completed Full Test Suite"
-# EOF
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
deleted file mode 100755
index 225bf4d..0000000
--- a/TC/tetbuild.cfg
+++ /dev/null
@@ -1,25 +0,0 @@
-# TETware Training Course
-# Build mode configuration file for Exercise 1
-
-# An example build mode configuration
-# that uses make as the build tool
-# and -f makefile as the arguments to
-# the build tool.
-
-TET_BUILD_TOOL=make
-TET_BUILD_FILE=-f Makefile
-
-# Clearly, make doesn't use the TETware API when printing messages -
-# it just writes messages on stdout or stderr.
-# So we must tell tcc to execute make with output capture mode enabled.
-# When make is executed, stdout and stderr is captured and written to
-# the journal.
-
-TET_OUTPUT_CAPTURE=True
-
-# we just want make -f makefile executed;
-# if the following was set to true , then
-# it would be make -f makefile tc1 etc...
-
-TET_PASS_TC_NAME=True
-
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
deleted file mode 100755
index 9038770..0000000
--- a/TC/tetclean.cfg
+++ /dev/null
@@ -1,12 +0,0 @@
-# TETware Training Course
-# Clean mode configuration file for Exercise 1
-
-# Use "make clean" to clean up each test case.
-TET_CLEAN_TOOL=make clean
-TET_CLEAN_FILE=Makefile
-# Tell tcc to execute make with output capture mode enabled
-TET_OUTPUT_CAPTURE=True
-# don't want to pass the test case name to the clean tool
-TET_PASS_TC_NAME=True
-TET_API_COMPLAINT=True
-
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
deleted file mode 100755
index 673f800..0000000
--- a/TC/tetexec.cfg
+++ /dev/null
@@ -1,16 +0,0 @@
-# TETware Training Course
-# Execute mode configuration file for Exercise 1
-
-# TET_OUTPUT_CAPTURE specifies whether or not tcc should capture standard
-# output and standard error output from test cases
-# and record it in the journal.
-# Test cases in this test suite are API-conforming test cases, so they
-# will use API functions to write to the journal.
-
-# Setting TET_OUTPUT_CAPTURE to False provides a default value
-# of True for TET_API_COMPLIANT
-
-TET_OUTPUT_CAPTURE=False
-TET_API_COMPLAINT=True
-TET_PASS_TC_NAME=True
-
diff --git a/TC/tslist.txt b/TC/tslist.txt
deleted file mode 100755
index 8826d6f..0000000
--- a/TC/tslist.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-./TC_email_service/TC_Folder/tslist
-./TC_email_service/TC_Message/tslist
-./TC_email_service/TC_Account/tslist
-./TC_email_service/TC_Rule/tslist
-./TC_email_service/TC_Network/tslist
-./TC_email_service/TC_Init/tslist
diff --git a/email-api/doc/email-service_doc.h b/email-api/doc/email-service_doc.h
index 0625199..6c31c9e 100755
--- a/email-api/doc/email-service_doc.h
+++ b/email-api/doc/email-service_doc.h
@@ -19,11 +19,9 @@
#define __TIZEN_EMAIL_SERVICE_DOC_H__
/**
- * @internal
* @ingroup CAPI_MESSAGING_FRAMEWORK
* @defgroup EMAIL_SERVICE_FRAMEWORK email-service
* @brief The Platform API for email functionalities.
- * @internal
*
* @addtogroup EMAIL_SERVICE_FRAMEWORK
*
diff --git a/email-api/email-api-account.c b/email-api/email-api-account.c
index 08702c3..648e17f 100755
--- a/email-api/email-api-account.c
+++ b/email-api/email-api-account.c
@@ -29,7 +29,6 @@
* email-service .
*/
-#include "email-api.h"
#include "string.h"
#include "email-convert.h"
#include "email-api-account.h"
@@ -45,10 +44,11 @@
EXPORT_API int email_add_account(email_account_t* account)
{
EM_DEBUG_API_BEGIN ("account[%p]", account);
- char* local_account_stream = NULL;
int size = 0;
int err = EMAIL_ERROR_NONE;
int ret_from_ipc = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
+ char* local_account_stream = NULL;
HIPC_API hAPI = NULL;
if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
@@ -57,38 +57,53 @@ EXPORT_API int email_add_account(email_account_t* account)
return EMAIL_ERROR_INVALID_PARAM;
}
- if(emstorage_check_duplicated_account(account, true, &err) == false) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (!emstorage_check_duplicated_account(multi_user_name, account, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_check_duplicated_account failed (%d) ", err);
- return err;
+ goto FINISH_OFF;
}
/* composing account information to be added */
hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT);
- EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+ if (hAPI == NULL) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
local_account_stream = em_convert_account_to_byte_stream(account, &size);
- EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
+ if (local_account_stream == NULL) {
+ EM_DEBUG_EXCEPTION("em_convert_account_to_byte_stream failed");
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
- if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
+ if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
}
EM_DEBUG_LOG("APPID[%d], APIID [%d]", emipc_get_app_id(hAPI), emipc_get_api_id(hAPI));
/* passing account information to service */
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
}
/* get result from service */
- if( (ret_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err)) != EMAIL_ERROR_NONE) {
+ if ((ret_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_get_parameter failed [%d]", ret_from_ipc);
err = ret_from_ipc;
goto FINISH_OFF;
}
- if(err == EMAIL_ERROR_NONE) {
+ if (err == EMAIL_ERROR_NONE) {
emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &account->account_id);
}
else { /* get error code */
@@ -97,9 +112,11 @@ EXPORT_API int email_add_account(email_account_t* account)
FINISH_OFF:
- if(hAPI)
+ if (hAPI)
emipc_destroy_email_api(hAPI);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -182,6 +199,7 @@ EXPORT_API int email_delete_account(int account_id)
if(ret != EMAIL_ERROR_NONE) { /* get error code */
emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
}
+
emipc_destroy_email_api(hAPI);
hAPI = NULL;
@@ -305,16 +323,21 @@ EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t
{
EM_DEBUG_FUNC_BEGIN ("account_id[%d] pulloption[%d]", account_id, pulloption);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_account_tbl_t *account_tbl = NULL;
EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(account, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
if (pulloption == GET_FULL_DATA)
pulloption = EMAIL_ACC_GET_OPT_FULL_DATA;
- if (!emstorage_get_account_by_id(account_id, pulloption, &account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, pulloption, &account_tbl, true, &err)) {
if (err != EMAIL_ERROR_SECURED_STORAGE_FAILURE) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err);
goto FINISH_OFF;
@@ -325,7 +348,7 @@ EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t
EM_DEBUG_LOG("change pulloption : disable password");
}
- if (!emstorage_get_account_by_id(account_id, pulloption, &account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, pulloption, &account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err);
goto FINISH_OFF;
}
@@ -340,9 +363,12 @@ EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t
em_convert_account_tbl_to_account(account_tbl, *account);
FINISH_OFF:
+
if (account_tbl)
emstorage_free_account(&account_tbl, 1, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END ("err[%d]", err);
return err;
}
@@ -352,15 +378,20 @@ EXPORT_API int email_get_account_list(email_account_t** account_list, int* count
EM_DEBUG_FUNC_BEGIN ();
int err = EMAIL_ERROR_NONE, i = 0;
- emstorage_account_tbl_t *temp_account_tbl = NULL;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(account_list, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
+ emstorage_account_tbl_t *temp_account_tbl = NULL;
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_account_list(count, &temp_account_tbl , true, false, &err)) {
+ if (!emstorage_get_account_list(multi_user_name, count, &temp_account_tbl , true, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -371,6 +402,7 @@ EXPORT_API int email_get_account_list(email_account_t** account_list, int* count
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
+
memset((void*)*account_list, 0, sizeof(email_account_t) * (*count));
for(i = 0; i < (*count); i++)
em_convert_account_tbl_to_account(temp_account_tbl + i, (*account_list) + i);
@@ -378,9 +410,11 @@ EXPORT_API int email_get_account_list(email_account_t** account_list, int* count
FINISH_OFF:
-
if(temp_account_tbl)
emstorage_free_account(&temp_account_tbl, (*count), NULL);
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END ("err[%d]", err);
return err;
@@ -435,7 +469,8 @@ EXPORT_API int email_validate_account_ex(email_account_t* account, int *handle)
int size = 0;
int err = EMAIL_ERROR_NONE;
- if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
+ if (account == NULL || account->user_email_address == NULL ||
+ account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
@@ -480,6 +515,8 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int *
int ret = -1;
int size = 0;
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
+ HIPC_API hAPI = NULL;
if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL) {
@@ -487,25 +524,41 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int *
return EMAIL_ERROR_INVALID_PARAM;
}
- if(emstorage_check_duplicated_account(account, true, &err) == false) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ return err;
+ }
+
+ if(emstorage_check_duplicated_account(multi_user_name, account, true, &err) == false) {
EM_DEBUG_EXCEPTION("emstorage_check_duplicated_account failed (%d) ", err);
- return err;
+ goto FINISH_OFF;
}
/* create account information */
- HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION);
- EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+ hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION);
+ if (hAPI == NULL) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
local_account_stream = em_convert_account_to_byte_stream(account, &size);
- EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
+ if (local_account_stream == NULL) {
+ EM_DEBUG_EXCEPTION("em_convert_account_to_byte_stream failed");
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter failed ");
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
}
if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
}
emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
@@ -517,8 +570,14 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int *
emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
}
- emipc_destroy_email_api(hAPI);
- hAPI = NULL;
+FINISH_OFF:
+
+ if (hAPI) {
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ }
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -539,29 +598,46 @@ EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name)
}
HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_BACKUP_ACCOUNTS);
-
EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+ /* Checked the existed account */
+ int account_count = 0;
+
+ if (!emstorage_get_account_count(NULL, &account_count, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_count failed - %d", err);
+ goto FINISH_OFF;
+ }
+
+ if (account_count == 0) {
+ EM_DEBUG_LOG("Account is empty");
+ err = EMAIL_ERROR_ACCOUNT_NOT_FOUND;
+ goto FINISH_OFF;
+ }
+
/* file_name */
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, EM_SAFE_STRLEN(file_name)+1)) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, EM_SAFE_STRLEN(file_name)+1)) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
+ err = EMAIL_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
- EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
}
emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
- if(0 == ret) { /* get error code */
+ if (ret == false) { /* get error code */
emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
}
- emipc_destroy_email_api(hAPI);
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
hAPI = NULL;
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -770,9 +846,25 @@ EXPORT_API int email_save_default_account_id(int input_account_id)
EM_DEBUG_EXCEPTION ("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID);
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ /* Input account ID */
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char *)&input_account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter input_account_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
+ }
+
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ }
- err = emcore_save_default_account_id(input_account_id);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
EM_DEBUG_API_END ("ret[%d]", err);
return err;
}
@@ -780,9 +872,30 @@ EXPORT_API int email_save_default_account_id(int input_account_id)
EXPORT_API int email_load_default_account_id(int *output_account_id)
{
EM_DEBUG_FUNC_BEGIN ("output_account_id[%p]", output_account_id);
+
int err = EMAIL_ERROR_NONE;
+ int account_id = 0;
+
+ EM_IF_NULL_RETURN_VALUE(output_account_id, EMAIL_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_LOAD_DEFAULT_ACCOUNT_ID);
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if (err == EMAIL_ERROR_NONE) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &account_id);
+ }
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
- err = emcore_load_default_account_id(output_account_id);
+ *output_account_id = account_id;
EM_DEBUG_FUNC_END ("ret[%d]", err);
return err;
diff --git a/email-api/email-api-etc.c b/email-api/email-api-etc.c
index 8f8e112..8b046c2 100755
--- a/email-api/email-api-etc.c
+++ b/email-api/email-api-etc.c
@@ -28,7 +28,6 @@
* @brief This file contains the data structures and interfaces of functionalities provided by email-service .
*/
-#include "email-api.h"
#include "email-types.h"
#include "email-ipc.h"
#include "email-debug-log.h"
@@ -44,7 +43,7 @@ EXPORT_API int email_show_user_message(int id, email_action_t action, int error_
EM_DEBUG_API_BEGIN ("id[%d] action[%d] error_code[%d]", id, action, error_code);
int err = EMAIL_ERROR_NONE;
- if(id < 0 || action < 0) {
+ if (id < 0 || action < 0) {
EM_DEBUG_LOG("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
@@ -52,24 +51,24 @@ EXPORT_API int email_show_user_message(int id, email_action_t action, int error_
HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SHOW_USER_MESSAGE);
/* id */
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&id, sizeof(int))) {
EM_DEBUG_LOG("emipc_add_parameter failed ");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
/* action */
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&action, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&action, sizeof(int))) {
EM_DEBUG_LOG("emipc_add_parameter failed ");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
/* error_code */
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&error_code, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&error_code, sizeof(int))) {
EM_DEBUG_LOG("emipc_add_parameter failed ");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_execute_proxy_api(hAPI)) {
+ if (!emipc_execute_proxy_api(hAPI)) {
EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -83,26 +82,32 @@ EXPORT_API int email_show_user_message(int id, email_action_t action, int error_
return err;
}
-EXPORT_API int email_parse_mime_file(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
+EXPORT_API int email_parse_mime_file(char *eml_file_path, email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data, int *output_attachment_count)
{
- EM_DEBUG_API_BEGIN ("eml_file_path[%p] output_mail_data[%p] output_attachment_data[%p]", eml_file_path, output_mail_data, output_attachment_data);
+ EM_DEBUG_API_BEGIN ("eml_file_path[%p] output_mail_data[%p] output_attachment_data[%p]",
+ eml_file_path, output_mail_data, output_attachment_data);
int err = EMAIL_ERROR_NONE;
EM_IF_NULL_RETURN_VALUE(eml_file_path, EMAIL_ERROR_INVALID_PARAM);
- if (!emcore_parse_mime_file_to_mail(eml_file_path, output_mail_data, output_attachment_data, output_attachment_count, &err) || !*output_mail_data)
+ if (!emcore_parse_mime_file_to_mail(eml_file_path, output_mail_data, output_attachment_data,
+ output_attachment_count, &err) || !*output_mail_data)
EM_DEBUG_EXCEPTION("emcore_parse_mime_file_to_mail failed [%d]", err);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
-EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data, int input_attachment_count, char **output_file_path)
+EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data,
+ int input_attachment_count, char **output_file_path)
{
- EM_DEBUG_API_BEGIN ("input_mail_data[%p] input_attachment_data[%p] input_attachment_count[%d]", input_mail_data, input_attachment_data, input_attachment_count);
+ EM_DEBUG_API_BEGIN ("input_mail_data[%p] input_attachment_data[%p] input_attachment_count[%d]",
+ input_mail_data, input_attachment_data, input_attachment_count);
int err = EMAIL_ERROR_NONE;
- int *ret_nth_value = NULL;
+ int ret_from_ipc = EMAIL_ERROR_NONE;
HIPC_API hAPI = NULL;
EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM);
@@ -115,19 +120,21 @@ EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data, email_a
goto FINISH_OFF;
}
- if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (!emipc_execute_proxy_api(hAPI)) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
goto FINISH_OFF;
}
- if (*(ret_nth_value = (int*)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 0)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("email_write_mime_file failed:[%d]", *ret_nth_value);
- err = *ret_nth_value;
+
+ if ((ret_from_ipc = emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_parameter failed:[%d]", ret_from_ipc);
+ err = ret_from_ipc;
goto FINISH_OFF;
}
- if (!emcore_make_rfc822_file(input_mail_data, input_attachment_data, input_attachment_count, false, output_file_path, &err)) {
+ if (!emcore_make_rfc822_file(NULL, input_mail_data, input_attachment_data, input_attachment_count, false,
+ output_file_path, &err)) {
EM_DEBUG_EXCEPTION("emcore_make_rfc822_file failed : [%d]", err);
}
@@ -144,12 +151,20 @@ EXPORT_API int email_delete_parsed_data(email_mail_data_t *input_mail_data)
{
EM_DEBUG_API_BEGIN ("mail_data[%p]", input_mail_data);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM);
- if (!emcore_delete_parsed_data(input_mail_data, &err))
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ return err;
+ }
+
+ if (!emcore_delete_parsed_data(multi_user_name, input_mail_data, &err))
EM_DEBUG_EXCEPTION("emcore_delete_parsed_data failed [%d]", err);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
diff --git a/email-api/email-api-init.c b/email-api/email-api-init.c
index 8068824..2adb5fb 100755
--- a/email-api/email-api-init.c
+++ b/email-api/email-api-init.c
@@ -30,7 +30,6 @@
* email-service .
*/
-#include "email-api.h"
#include "string.h"
#include "email-convert.h"
#include "email-storage.h"
@@ -39,6 +38,7 @@
#include "email-core-account.h"
#include "email-utilities.h"
#include "email-dbus-activation.h"
+#include "email-core-container.h"
#include <sqlite3.h>
#include <gio/gio.h>
@@ -46,12 +46,19 @@ EXPORT_API int email_open_db(void)
{
EM_DEBUG_API_BEGIN ();
int error = EMAIL_ERROR_NONE;
-
- if (emstorage_db_open(&error) == NULL)
+ char *multi_user_name = NULL;
+
+ if ((error = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", error);
+ return error;
+ }
+
+ if (emstorage_db_open(multi_user_name, &error) == NULL)
EM_DEBUG_EXCEPTION("emstorage_db_open failed [%d]", error);
-
- EM_DEBUG_API_END ("err[%d]", error);
+ EM_SAFE_FREE(multi_user_name);
+
+ EM_DEBUG_API_END ("error[%d]", error);
return error;
}
@@ -59,11 +66,19 @@ EXPORT_API int email_close_db(void)
{
EM_DEBUG_API_BEGIN ();
int error = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
- if ( !emstorage_db_close(&error))
+ if ((error = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", error);
+ return error;
+ }
+
+ if (!emstorage_db_close(multi_user_name, &error))
EM_DEBUG_EXCEPTION("emstorage_db_close failed [%d]", error);
- EM_DEBUG_API_END ("err[%d]", error);
+ EM_SAFE_FREE(multi_user_name);
+
+ EM_DEBUG_API_END ("error[%d]", error);
return error;
}
@@ -109,12 +124,20 @@ EXPORT_API int email_init_storage(void)
{
EM_DEBUG_API_BEGIN ();
int error = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
- if (!emstorage_create_table(EMAIL_CREATE_DB_NORMAL, &error)) {
+ if ((error = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", error);
+ return error;
+ }
+
+ if (!emstorage_create_table(multi_user_name, EMAIL_CREATE_DB_NORMAL, &error)) {
EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error);
}
- EM_DEBUG_API_END ("err[%d]", error);
+ EM_SAFE_FREE(multi_user_name);
+
+ EM_DEBUG_API_END ("error[%d]", error);
return error;
}
diff --git a/email-api/email-api-mail.c b/email-api/email-api-mail.c
index 46477c0..524da69 100755
--- a/email-api/email-api-mail.c
+++ b/email-api/email-api-mail.c
@@ -33,8 +33,9 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
-#include "email-api.h"
#include "email-ipc.h"
+#include "email-api-init.h"
+#include "email-api-mailbox.h"
#include "email-convert.h"
#include "email-core-tasks.h"
#include "email-core-utils.h"
@@ -70,19 +71,25 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
int *ret_nth_value = NULL;
int size = 0;
char *rfc822_file = NULL;
+ char *multi_user_name = NULL;
char *mail_data_stream = NULL;
char *attachment_data_list_stream = NULL;
char *meeting_request_stream = NULL;
HIPC_API hAPI = NULL;
-
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
if(input_from_eas == 0) { /* native emails */
if ((input_mail_data->smime_type != EMAIL_SMIME_NONE) && (input_mail_data->mailbox_type != EMAIL_MAILBOX_TYPE_DRAFT)) {
- if (!emcore_make_rfc822_file(input_mail_data, input_attachment_data_list, input_attachment_count, true, &rfc822_file, &err)) {
+ if (!emcore_make_rfc822_file(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, true, &rfc822_file, &err)) {
EM_DEBUG_EXCEPTION("emcore_make_rfc822_file failed [%d]", err);
goto FINISH_OFF;
}
- input_mail_data->file_path_mime_entity = emcore_set_mime_entity(rfc822_file);
+ input_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(emcore_set_mime_entity(rfc822_file));
emstorage_delete_file(rfc822_file, NULL);
EM_SAFE_FREE(rfc822_file);
@@ -165,7 +172,7 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
goto FINISH_OFF;
}
} else { /* take care of mails from eas */
- err = emcore_add_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas, false);
+ err = emcore_add_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas, false);
if(err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
goto FINISH_OFF;
@@ -173,9 +180,11 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
}
FINISH_OFF:
+
if(hAPI)
emipc_destroy_email_api(hAPI);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -223,7 +232,7 @@ EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receip
#define TMP_BODY_PATH "/tmp/UTF-8"
-int email_create_db_full()
+EXPORT_API int email_create_db_full()
{
int mailbox_index, mail_index, mailbox_count, mail_slot_size;
int account_id = 0;
@@ -238,7 +247,7 @@ int email_create_db_full()
return err;
}
- if ((err = emcore_load_default_account_id(&account_id)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_load_default_account_id(NULL, &account_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_load_default_account_id failed : [%d]", err);
goto FINISH_OFF;
}
@@ -273,7 +282,8 @@ int email_create_db_full()
sprintf(mail_table_data.subject, "Subject #%d",mail_index);
mail_table_data.mailbox_id = mailbox_list[mailbox_index].mailbox_id;
mail_table_data.mailbox_type = mailbox_list[mailbox_index].mailbox_type;
- if( !emstorage_add_mail(&mail_table_data, 1, true, &err)) {
+
+ if( !emstorage_add_mail(NULL, &mail_table_data, 1, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]",err);
goto FINISH_OFF;
@@ -390,7 +400,7 @@ EXPORT_API int email_update_mail(email_mail_data_t *input_mail_data, email_attac
}
}
else {
- if( (err = emcore_update_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
+ if( (err = emcore_update_mail(NULL, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -477,6 +487,7 @@ EXPORT_API int email_count_mail(email_list_filter_t *input_filter_list, int inpu
int total_count = 0;
int unread = 0;
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
char *conditional_clause_string = NULL;
EM_IF_NULL_RETURN_VALUE(input_filter_list, EMAIL_ERROR_INVALID_PARAM);
@@ -484,13 +495,17 @@ EXPORT_API int email_count_mail(email_list_filter_t *input_filter_list, int inpu
EM_IF_NULL_RETURN_VALUE(output_total_mail_count, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(output_unseen_mail_count, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if( (err = emstorage_write_conditional_clause_for_getting_mail_list(input_filter_list, input_filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, input_filter_list, input_filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
- if ((err = emstorage_query_mail_count(conditional_clause_string, true, &total_count, &unread)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_query_mail_count(multi_user_name, conditional_clause_string, true, &total_count, &unread)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_count failed [%d]", err);
goto FINISH_OFF;
}
@@ -499,6 +514,8 @@ EXPORT_API int email_count_mail(email_list_filter_t *input_filter_list, int inpu
*output_unseen_mail_count = unread;
FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
EM_SAFE_FREE (conditional_clause_string); /* detected by valgrind */
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -743,15 +760,19 @@ EXPORT_API int email_query_mails(char *conditional_clause_string, email_mail_dat
EM_DEBUG_API_BEGIN ("conditional_clause_string[%s] mail_list[%p] result_count[%p]", conditional_clause_string, mail_list, result_count);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_mail_tbl_t *result_mail_tbl = NULL;
EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed :[%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_query_mail_tbl(conditional_clause_string, true, &result_mail_tbl, result_count, &err)) {
+ if (!emstorage_query_mail_tbl(multi_user_name, conditional_clause_string, true, &result_mail_tbl, result_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_list failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -761,9 +782,12 @@ EXPORT_API int email_query_mails(char *conditional_clause_string, email_mail_dat
}
FINISH_OFF:
+
if(result_mail_tbl && !emstorage_free_mail(&result_mail_tbl, *result_count, NULL))
EM_DEBUG_EXCEPTION("emstorage_free_mail failed");
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -773,17 +797,24 @@ EXPORT_API int email_query_mail_list(char *input_conditional_clause_string, emai
EM_DEBUG_API_BEGIN ("input_conditional_clause_string[%s] output_mail_list[%p] output_result_count[%p]", input_conditional_clause_string, output_mail_list, output_result_count);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(input_conditional_clause_string, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(output_result_count, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed :[%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_query_mail_list(input_conditional_clause_string, true, output_mail_list, output_result_count, &err)) {
+ if (!emstorage_query_mail_list(multi_user_name, input_conditional_clause_string, true, output_mail_list, output_result_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_list failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err [%d]", err);
return err;
}
@@ -864,12 +895,19 @@ FINISH_OFF:
EXPORT_API int email_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
{
EM_DEBUG_API_BEGIN ("input_mail_id[%d] output_attachment_data[%p] output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count);
- int err = EMAIL_ERROR_NONE;
+ int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ return err;
+ }
- if((err = emcore_get_attachment_data_list(input_mail_id, output_attachment_data, output_attachment_count)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_get_attachment_data_list(multi_user_name, input_mail_id, output_attachment_data, output_attachment_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -891,27 +929,34 @@ EXPORT_API int email_get_mail_list_ex(email_list_filter_t *input_filter_list, in
EM_DEBUG_FUNC_BEGIN ("input_filter_list[%p] input_filter_count[%d] input_sorting_rule_list[%p] input_sorting_rule_count[%d] input_start_index[%d] input_limit_count[%d] output_mail_list[%p] output_result_count[%p]", input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, output_mail_list, output_result_count);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
char *conditional_clause_string = NULL;
EM_IF_NULL_RETURN_VALUE(output_mail_list, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(output_result_count, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if( (err = emstorage_write_conditional_clause_for_getting_mail_list(input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG_DEV ("conditional_clause_string[%s].", conditional_clause_string);
- if(!emstorage_query_mail_list(conditional_clause_string, true, output_mail_list, output_result_count, &err)) {
+ if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, output_mail_list, output_result_count, &err)) {
if (err != EMAIL_ERROR_MAIL_NOT_FOUND) /* there is no mail and it is definitely common */
EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
+
EM_SAFE_FREE(conditional_clause_string);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END ("err[%d]", err);
return err;
@@ -935,6 +980,7 @@ EXPORT_API int email_get_mails(int account_id , int mailbox_id, int thread_id, i
EM_DEBUG_API_BEGIN ("account_id[%d] mailbox_id[%d] thread_id[%d]", account_id, mailbox_id, thread_id);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_mail_tbl_t *mail_tbl_list = NULL;
EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM);
@@ -944,10 +990,13 @@ EXPORT_API int email_get_mails(int account_id , int mailbox_id, int thread_id, i
goto FINISH_OFF;
}
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_mails(account_id, mailbox_id, NULL, thread_id, start_index, limit_count, sorting, true, &mail_tbl_list, result_count, &err)) {
+ if (!emstorage_get_mails(multi_user_name, account_id, mailbox_id, NULL, thread_id, start_index, limit_count, sorting, true, &mail_tbl_list, result_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mails failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -957,9 +1006,12 @@ EXPORT_API int email_get_mails(int account_id , int mailbox_id, int thread_id, i
}
FINISH_OFF:
+
if(mail_tbl_list && !emstorage_free_mail(&mail_tbl_list, *result_count, NULL))
EM_DEBUG_EXCEPTION("emstorage_free_mail failed");
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -969,6 +1021,7 @@ EXPORT_API int email_get_mail_list(int account_id , int mailbox_id, int thread_i
EM_DEBUG_API_BEGIN ("account_id[%d] mailbox_id[%d] thread_id[%d]", account_id, mailbox_id, thread_id);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM);
@@ -977,14 +1030,20 @@ EXPORT_API int email_get_mail_list(int account_id , int mailbox_id, int thread_i
return EMAIL_ERROR_INVALID_PARAM;
}
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_mail_list(account_id, mailbox_id, NULL, thread_id, start_index, limit_count, 0, NULL, sorting, true, mail_list, result_count, &err)) {
+ if (!emstorage_get_mail_list(multi_user_name, account_id, mailbox_id, NULL, thread_id, start_index, limit_count, 0, NULL, sorting, true, mail_list, result_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
-
goto FINISH_OFF;
}
FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -994,7 +1053,7 @@ EXPORT_API int email_get_mail_by_address(int account_id , int mailbox_id, email_
{
EM_DEBUG_API_BEGIN ("account_id[%d] mailbox_id[%d]", account_id, mailbox_id);
int err = EMAIL_ERROR_NONE;
-
+ char *multi_user_name = NULL;
email_mail_list_item_t* mail_list_item = NULL;
EM_IF_NULL_RETURN_VALUE(mail_list, EMAIL_ERROR_INVALID_PARAM);
@@ -1006,16 +1065,22 @@ EXPORT_API int email_get_mail_by_address(int account_id , int mailbox_id, email_
return err;
}
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_mail_list(account_id, mailbox_id, addr_list, EMAIL_LIST_TYPE_NORMAL, start_index, limit_count, search_type, search_value, sorting, true, &mail_list_item, result_count, &err)) {
+ if (!emstorage_get_mail_list(multi_user_name, account_id, mailbox_id, addr_list, EMAIL_LIST_TYPE_NORMAL, start_index, limit_count, search_type, search_value, sorting, true, &mail_list_item, result_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
-
goto FINISH_OFF;
}
*mail_list = mail_list_item;
FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -1024,12 +1089,17 @@ EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, email_ma
{
EM_DEBUG_API_BEGIN ("thread_id[%d]", thread_id);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_mail_tbl_t *mail_table_data = NULL;
EM_IF_NULL_RETURN_VALUE(thread_info, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) {
+ if (!emstorage_get_thread_information(multi_user_name, thread_id, &mail_table_data , true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_thread_information failed [%d]", err);
goto FINISH_OFF;
}
@@ -1044,6 +1114,8 @@ FINISH_OFF:
if(mail_table_data && !emstorage_free_mail(&mail_table_data, 1, NULL))
EM_DEBUG_EXCEPTION("emstorage_free_mail failed");
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -1052,13 +1124,18 @@ EXPORT_API int email_get_thread_information_ex(int thread_id, email_mail_list_it
{
EM_DEBUG_API_BEGIN ("thread_id[%d]", thread_id);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_mail_tbl_t *mail_table_data = NULL;
email_mail_list_item_t *temp_thread_info = NULL;
EM_IF_NULL_RETURN_VALUE(thread_info, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) {
+ if (!emstorage_get_thread_information(multi_user_name, thread_id, &mail_table_data , true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_thread_information -- failed [%d]", err);
goto FINISH_OFF;
}
@@ -1100,6 +1177,8 @@ FINISH_OFF:
if(mail_table_data)
emstorage_free_mail(&mail_table_data, 1, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -1108,10 +1187,18 @@ EXPORT_API int email_get_mail_data(int input_mail_id, email_mail_data_t **output
{
EM_DEBUG_API_BEGIN ("input_mail_id[%d]", input_mail_id);
int err = EMAIL_ERROR_NONE;
-
- if ( ((err = emcore_get_mail_data(input_mail_id, output_mail_data)) != EMAIL_ERROR_NONE) || !output_mail_data)
+ char *multi_user_name = NULL;
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ return err;
+ }
+
+ if ( ((err = emcore_get_mail_data(multi_user_name, input_mail_id, output_mail_data)) != EMAIL_ERROR_NONE) || !output_mail_data)
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
-
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -1382,12 +1469,17 @@ EXPORT_API int email_cancel_sending_mail(int mail_id)
int err = EMAIL_ERROR_NONE;
int account_id = 0;
+ char *multi_user_name = NULL;
email_mail_data_t* mail_data = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_container_name error : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (((err = emcore_get_mail_data(mail_id, &mail_data)) != EMAIL_ERROR_NONE) || mail_data == NULL) {
+ if (((err = emcore_get_mail_data(multi_user_name, mail_id, &mail_data)) != EMAIL_ERROR_NONE) || mail_data == NULL) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
goto FINISH_OFF;
}
@@ -1395,7 +1487,7 @@ EXPORT_API int email_cancel_sending_mail(int mail_id)
account_id = mail_data->account_id;
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(account_id, &account_server_type, false, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -1412,9 +1504,10 @@ EXPORT_API int email_cancel_sending_mail(int mail_id)
}
/* noti to active sync */
- as_noti_data.cancel_sending_mail.handle = as_handle;
- as_noti_data.cancel_sending_mail.mail_id = mail_id;
- as_noti_data.cancel_sending_mail.account_id = account_id;
+ as_noti_data.cancel_sending_mail.handle = as_handle;
+ as_noti_data.cancel_sending_mail.mail_id = mail_id;
+ as_noti_data.cancel_sending_mail.account_id = account_id;
+ as_noti_data.cancel_sending_mail.multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_SENDING_MAIL, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -1463,6 +1556,8 @@ FINISH_OFF:
if(mail_data)
emcore_free_mail_data_list(&mail_data, 1);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -1557,6 +1652,7 @@ EXPORT_API int email_get_address_info_list(int mail_id, email_address_info_list_
EM_DEBUG_FUNC_BEGIN ("mail_id[%d] address_info_list[%p]", mail_id, address_info_list);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_address_info_list_t *temp_address_info_list = NULL;
@@ -1566,22 +1662,28 @@ EXPORT_API int email_get_address_info_list(int mail_id, email_address_info_list_
err = EMAIL_ERROR_INVALID_PARAM ;
return err;
}
-
- if ( !emcore_get_mail_address_info_list(mail_id, &temp_address_info_list, &err) ) {
- EM_DEBUG_EXCEPTION("emcore_get_mail_address_info_list failed [%d]", err);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ if (!emcore_get_mail_address_info_list(multi_user_name, mail_id, &temp_address_info_list, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_mail_address_info_list failed [%d]", err);
goto FINISH_OFF;
}
- if ( address_info_list ) {
+ if (address_info_list) {
*address_info_list = temp_address_info_list;
temp_address_info_list = NULL;
}
FINISH_OFF:
- if ( temp_address_info_list )
+
+ if (temp_address_info_list)
emstorage_free_address_info_list(&temp_address_info_list);
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END ("err[%d]", err);
return err;
}
@@ -1603,14 +1705,22 @@ EXPORT_API int email_query_meeting_request(char *input_conditional_clause_string
{
EM_DEBUG_API_BEGIN ("input_conditional_clause_string[%s] output_meeting_req[%p] output_count[%p]", input_conditional_clause_string, output_meeting_req, output_count);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(input_conditional_clause_string, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(output_count, EMAIL_ERROR_INVALID_PARAM);
- if ((err = emstorage_query_meeting_request(input_conditional_clause_string, output_meeting_req, output_count, true)) != EMAIL_ERROR_NONE) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ return err;
+ }
+
+ if ((err = emstorage_query_meeting_request(multi_user_name, input_conditional_clause_string, output_meeting_req, output_count, true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_meeting_request failed [%d]", err);
}
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -1620,27 +1730,33 @@ EXPORT_API int email_get_meeting_request(int mail_id, email_meeting_request_t **
EM_DEBUG_API_BEGIN ("mail_id[%d] meeting_req[%p]", mail_id, meeting_req);
int err = EMAIL_ERROR_NONE;
-
+ char *multi_user_name = NULL;
email_meeting_request_t *temp_meeting_req = NULL;
EM_IF_NULL_RETURN_VALUE(meeting_req, EMAIL_ERROR_INVALID_PARAM);
- if( mail_id <= 0 ) {
+ if (mail_id <= 0) {
EM_DEBUG_EXCEPTION(" Invalid Mail Id Param ");
err = EMAIL_ERROR_INVALID_PARAM ;
return err;
}
-
- if ( !emstorage_get_meeting_request(mail_id, &temp_meeting_req, 1, &err) ) {
- EM_DEBUG_EXCEPTION("emstorage_get_meeting_request failed[%d]", err);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ return err;
+ }
+ if (!emstorage_get_meeting_request(multi_user_name, mail_id, &temp_meeting_req, 1, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_meeting_request failed[%d]", err);
goto FINISH_OFF;
}
- if ( meeting_req )
+ if (meeting_req)
*meeting_req = temp_meeting_req;
FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -1760,6 +1876,7 @@ EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag)
emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
FINISH_OFF:
+
if(hAPI)
emipc_destroy_email_api(hAPI);
@@ -1828,10 +1945,16 @@ EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int inp
EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
int err = EMAIL_ERROR_NONE;
int return_value = 0;
+ char *multi_user_name = NULL;
HIPC_API hAPI = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl_data = NULL;
- if( (err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl_data)) != EMAIL_ERROR_NONE) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if( (err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed[%d]", err);
goto FINISH_OFF;
}
@@ -1841,7 +1964,7 @@ EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int inp
memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
- if ( em_get_account_server_type_by_account_id(mailbox_tbl_data->account_id, &account_server_type, true, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, mailbox_tbl_data->account_id, &account_server_type, true, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
@@ -1855,10 +1978,11 @@ EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int inp
}
/* noti to active sync */
- as_noti_data.expunge_mails_deleted_flagged.handle = as_handle;
- as_noti_data.expunge_mails_deleted_flagged.account_id = mailbox_tbl_data->account_id;
- as_noti_data.expunge_mails_deleted_flagged.mailbox_id = input_mailbox_id;
- as_noti_data.expunge_mails_deleted_flagged.on_server = input_on_server;
+ as_noti_data.expunge_mails_deleted_flagged.handle = as_handle;
+ as_noti_data.expunge_mails_deleted_flagged.account_id = mailbox_tbl_data->account_id;
+ as_noti_data.expunge_mails_deleted_flagged.mailbox_id = input_mailbox_id;
+ as_noti_data.expunge_mails_deleted_flagged.on_server = input_on_server;
+ as_noti_data.expunge_mails_deleted_flagged.multi_user_name = multi_user_name;
return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED, &as_noti_data);
@@ -1917,6 +2041,7 @@ FINISH_OFF:
emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL);
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
diff --git a/email-api/email-api-mailbox.c b/email-api/email-api-mailbox.c
index 97be170..e9c8681 100755
--- a/email-api/email-api-mailbox.c
+++ b/email-api/email-api-mailbox.c
@@ -30,11 +30,11 @@
* email-service .
*/
-#include "email-api.h"
#include "string.h"
#include "email-convert.h"
#include "email-storage.h"
#include "email-core-utils.h"
+#include "email-core-gmime.h"
#include "email-core-signal.h"
#include "email-utilities.h"
#include "email-ipc.h"
@@ -48,16 +48,22 @@ EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, in
int size = 0;
int err = EMAIL_ERROR_NONE;
char* local_mailbox_stream = NULL;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
ASNotiData as_noti_data;
- memset(&as_noti_data, 0x00, sizeof(ASNotiData));
-
EM_IF_NULL_RETURN_VALUE(new_mailbox, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(new_mailbox->account_id, &account_server_type, false, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, new_mailbox->account_id, &account_server_type, false, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -73,20 +79,21 @@ EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, in
}
/* noti to active sync */
- as_noti_data.add_mailbox.handle = as_handle;
- as_noti_data.add_mailbox.account_id = new_mailbox->account_id;
- as_noti_data.add_mailbox.mailbox_alias = new_mailbox->alias;
- as_noti_data.add_mailbox.mailbox_path = new_mailbox->mailbox_name;
- as_noti_data.add_mailbox.eas_data = new_mailbox->eas_data;
+ as_noti_data.add_mailbox.handle = as_handle;
+ as_noti_data.add_mailbox.account_id = new_mailbox->account_id;
+ as_noti_data.add_mailbox.mailbox_alias = new_mailbox->alias;
+ as_noti_data.add_mailbox.mailbox_path = new_mailbox->mailbox_name;
+ as_noti_data.add_mailbox.eas_data = new_mailbox->eas_data;
as_noti_data.add_mailbox.eas_data_length = new_mailbox->eas_data_length;
+ as_noti_data.add_mailbox.multi_user_name = multi_user_name;
- if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_ADD_MAILBOX, &as_noti_data) == false) {
+ if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_ADD_MAILBOX, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if(handle)
+ if (handle)
*handle = as_handle;
}
else {
@@ -98,25 +105,25 @@ EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, in
EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_SAFE_FREE(local_mailbox_stream);
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
- if(handle) {
+ if (handle) {
emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
EM_DEBUG_LOG(" >>>>> Handle [%d]", *handle);
}
@@ -130,6 +137,7 @@ EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, in
FINISH_OFF:
EM_SAFE_FREE(local_mailbox_stream);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -140,6 +148,7 @@ EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_na
EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_mailbox_name[%p] input_mailbox_alias[%p] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_on_server, output_handle);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
ASNotiData as_noti_data;
@@ -149,43 +158,49 @@ EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_na
EM_IF_NULL_RETURN_VALUE(input_mailbox_name, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(input_mailbox_alias, EMAIL_ERROR_INVALID_PARAM);
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(mailbox_tbl->account_id, &account_server_type, false, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, mailbox_tbl->account_id, &account_server_type, false, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
int as_handle;
- if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
/* noti to active sync */
- as_noti_data.rename_mailbox.handle = as_handle;
- as_noti_data.rename_mailbox.account_id = mailbox_tbl->account_id;
- as_noti_data.rename_mailbox.mailbox_id = input_mailbox_id;
- as_noti_data.rename_mailbox.mailbox_name = input_mailbox_name;
- as_noti_data.rename_mailbox.mailbox_alias = input_mailbox_alias;
+ as_noti_data.rename_mailbox.handle = as_handle;
+ as_noti_data.rename_mailbox.account_id = mailbox_tbl->account_id;
+ as_noti_data.rename_mailbox.mailbox_id = input_mailbox_id;
+ as_noti_data.rename_mailbox.mailbox_name = input_mailbox_name;
+ as_noti_data.rename_mailbox.mailbox_alias = input_mailbox_alias;
as_noti_data.rename_mailbox.eas_data = NULL;
as_noti_data.rename_mailbox.eas_data_length = 0;
+ as_noti_data.rename_mailbox.multi_user_name = multi_user_name;
- if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_RENAME_MAILBOX, &as_noti_data) == false) {
+ if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_RENAME_MAILBOX, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if(output_handle)
+ if (output_handle)
*output_handle = as_handle;
}
else {
@@ -227,6 +242,7 @@ FINISH_OFF:
if (mailbox_tbl)
emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -236,6 +252,7 @@ EXPORT_API int email_rename_mailbox_ex(int input_mailbox_id, char *input_mailbox
EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_mailbox_name[%p] input_mailbox_alias[%p] input_eas_data[%p] input_eas_data_length[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_eas_data, input_eas_data_length, input_on_server, output_handle);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
ASNotiData as_noti_data;
@@ -245,22 +262,27 @@ EXPORT_API int email_rename_mailbox_ex(int input_mailbox_id, char *input_mailbox
EM_IF_NULL_RETURN_VALUE(input_mailbox_name, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(input_mailbox_alias, EMAIL_ERROR_INVALID_PARAM);
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(mailbox_tbl->account_id, &account_server_type, false, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, mailbox_tbl->account_id, &account_server_type, false, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
int as_handle;
- if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -274,45 +296,46 @@ EXPORT_API int email_rename_mailbox_ex(int input_mailbox_id, char *input_mailbox
as_noti_data.rename_mailbox.mailbox_alias = input_mailbox_alias;
as_noti_data.rename_mailbox.eas_data = input_eas_data;
as_noti_data.rename_mailbox.eas_data_length = input_eas_data_length;
+ as_noti_data.rename_mailbox.multi_user_name = multi_user_name;
- if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_RENAME_MAILBOX, &as_noti_data) == false) {
+ if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_RENAME_MAILBOX, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if(output_handle)
+ if (output_handle)
*output_handle = as_handle;
}
else {
hAPI = emipc_create_email_api(_EMAIL_API_RENAME_MAILBOX_EX);
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_id failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, EM_SAFE_STRLEN(input_mailbox_name)+1 )) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, EM_SAFE_STRLEN(input_mailbox_name)+1 )) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_path failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_alias, EM_SAFE_STRLEN(input_mailbox_alias)+1 )) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_alias, EM_SAFE_STRLEN(input_mailbox_alias)+1 )) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_alias failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_eas_data, input_eas_data_length )) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_eas_data, input_eas_data_length )) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_eas_data failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -328,6 +351,7 @@ FINISH_OFF:
if (mailbox_tbl)
emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -340,6 +364,7 @@ EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, i
EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
HIPC_API hAPI = NULL;
@@ -347,39 +372,45 @@ EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, i
EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
- if ( (err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed[%d]", err);
goto FINISH_OFF;
}
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(mailbox_tbl->account_id, &account_server_type, false, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, mailbox_tbl->account_id, &account_server_type, false, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
int as_handle;
- if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
/* noti to active sync */
- as_noti_data.delete_mailbox.handle = as_handle;
- as_noti_data.delete_mailbox.account_id = mailbox_tbl->account_id;
- as_noti_data.delete_mailbox.mailbox_id = input_mailbox_id;
+ as_noti_data.delete_mailbox.handle = as_handle;
+ as_noti_data.delete_mailbox.account_id = mailbox_tbl->account_id;
+ as_noti_data.delete_mailbox.mailbox_id = input_mailbox_id;
+ as_noti_data.delete_mailbox.multi_user_name = multi_user_name;
- if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DELETE_MAILBOX, &as_noti_data) == false) {
+ if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DELETE_MAILBOX, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if(output_handle)
+ if (output_handle)
*output_handle = as_handle;
}
else {
@@ -387,17 +418,17 @@ EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, i
EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -405,7 +436,7 @@ EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, i
emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
EM_DEBUG_LOG("error VALUE [%d]", err);
- if(input_on_server) {
+ if (input_on_server) {
emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle);
EM_DEBUG_LOG("output_handle [%d]", output_handle);
}
@@ -418,35 +449,52 @@ FINISH_OFF:
emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
-EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, int input_on_server, int *output_handle)
+EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array,
+ int input_mailbox_id_count, int input_on_server,
+ int *output_handle)
{
- EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id_array[%p] input_mailbox_id_count[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id_array, input_mailbox_id_array, input_mailbox_id_count, input_on_server, output_handle);
+ EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id_array[%p] "
+ "input_mailbox_id_count[%d] input_on_server[%d] "
+ "output_handle[%p]", input_mailbox_id_array, input_mailbox_id_array,
+ input_mailbox_id_count, input_on_server, output_handle);
+
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX task_parameter;
- if(input_account_id == 0 || input_mailbox_id_count <= 0 || input_mailbox_id_array == NULL) {
+ if (input_account_id == 0 || input_mailbox_id_count <= 0 || input_mailbox_id_array == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(input_account_id, &account_server_type, false, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name,
+ input_account_id,
+ &account_server_type,
+ false,
+ &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server) {
int as_handle;
ASNotiData as_noti_data;
- if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -458,14 +506,15 @@ EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_
as_noti_data.delete_mailbox_ex.mailbox_id_array = input_mailbox_id_array;
as_noti_data.delete_mailbox_ex.mailbox_id_count = input_mailbox_id_count;
as_noti_data.delete_mailbox_ex.on_server = input_on_server;
+ as_noti_data.delete_mailbox_ex.multi_user_name = EM_SAFE_STRDUP(multi_user_name);
- if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DELETE_MAILBOX_EX, &as_noti_data) == false) {
+ if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DELETE_MAILBOX_EX, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if(output_handle)
+ if (output_handle)
*output_handle = as_handle;
}
else {
@@ -474,7 +523,8 @@ EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_
task_parameter.mailbox_id_count = input_mailbox_id_count;
task_parameter.on_server = input_on_server;
- if((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, &task_parameter)) != EMAIL_ERROR_NONE) {
+ if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX,
+ &task_parameter)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
goto FINISH_OFF;
}
@@ -482,6 +532,8 @@ EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_
FINISH_OFF:
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -497,17 +549,17 @@ EXPORT_API int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e
EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_type, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_type, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -532,17 +584,17 @@ EXPORT_API int email_set_local_mailbox(int input_mailbox_id, int input_is_local_
EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_is_local_mailbox, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_is_local_mailbox, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -562,16 +614,20 @@ EXPORT_API int email_get_sync_mailbox_list(int account_id, email_mailbox_t** mai
int mailbox_count = 0;
int err = EMAIL_ERROR_NONE ;
int i = 0;
+ char *multi_user_name = NULL;
emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
- if (!emstorage_get_mailbox_list(account_id, 0, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
-
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ if (!emstorage_get_mailbox_list(multi_user_name, account_id, 0, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
goto FINISH_OFF;
} else
err = EMAIL_ERROR_NONE;
@@ -589,9 +645,12 @@ EXPORT_API int email_get_sync_mailbox_list(int account_id, email_mailbox_t** mai
*count = mailbox_count;
- FINISH_OFF:
+FINISH_OFF:
+
if (mailbox_tbl_list != NULL)
emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -605,15 +664,19 @@ EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, ema
emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
int err =EMAIL_ERROR_NONE;
int i;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_mailbox_list(account_id, mailbox_sync_type, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
+ if (!emstorage_get_mailbox_list(multi_user_name, account_id, mailbox_sync_type, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
-
goto FINISH_OFF;
} else
err = EMAIL_ERROR_NONE;
@@ -633,15 +696,16 @@ EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, ema
*count = mailbox_count;
FINISH_OFF:
+
if (mailbox_tbl_list != NULL)
emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err [%d]", err);
return err;
}
-
-
EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, email_mailbox_t** mailbox_list, int* count)
{
EM_DEBUG_FUNC_BEGIN ();
@@ -650,19 +714,27 @@ EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type,
emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
int err =EMAIL_ERROR_NONE;
int i;
-
+ char *multi_user_name = NULL;
+
EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_mailbox_list_ex(account_id, mailbox_sync_type, with_count, &mailbox_count, &mailbox_tbl_list, true, &err)) {
+ emcore_gmime_init();
+ if (!emstorage_get_mailbox_list_ex(multi_user_name, account_id, mailbox_sync_type, with_count, &mailbox_count, &mailbox_tbl_list, true, &err)) {
+ emcore_gmime_shutdown();
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_list_ex failed [%d]", err);
-
goto FINISH_OFF;
} else
err = EMAIL_ERROR_NONE;
-
+
+ emcore_gmime_shutdown();
+
if (mailbox_count > 0) {
if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) {
EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
@@ -670,7 +742,7 @@ EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type,
goto FINISH_OFF;
}
- for (i = 0; i < mailbox_count; i++)
+ for (i = 0; i < mailbox_count; i++)
em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
}
else
@@ -680,9 +752,12 @@ EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type,
*count = mailbox_count;
FINISH_OFF:
+
if (mailbox_tbl_list != NULL)
emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END ("err[%d]", err);
return err;
}
@@ -695,12 +770,17 @@ EXPORT_API int email_get_mailbox_list_by_keyword(int account_id, char *keyword,
emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
int err = EMAIL_ERROR_NONE;
int i = 0;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_mailbox_by_keyword(account_id, keyword, &mailbox_tbl_list, &mailbox_count, true, &err)) {
+ if (!emstorage_get_mailbox_by_keyword(multi_user_name, account_id, keyword, &mailbox_tbl_list, &mailbox_count, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_keyword failed [%d]", err);
goto FINISH_OFF;
}
@@ -725,6 +805,8 @@ FINISH_OFF:
if (mailbox_tbl_list != NULL)
emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -734,19 +816,25 @@ EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_t
EM_DEBUG_FUNC_BEGIN ();
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_mailbox_t* curr_mailbox = NULL;
emstorage_mailbox_tbl_t* local_mailbox = NULL;
EM_IF_NULL_RETURN_VALUE(mailbox, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM) ;
- if(mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_USER_DEFINED)
- return EMAIL_ERROR_INVALID_PARAM;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ if (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_USER_DEFINED) {
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, mailbox_type, &local_mailbox, true, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, mailbox_type, &local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
-
goto FINISH_OFF;
} else {
err = EMAIL_ERROR_NONE;
@@ -762,10 +850,14 @@ EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_t
}
*mailbox = curr_mailbox;
+
FINISH_OFF:
- if(local_mailbox)
+ if (local_mailbox)
emstorage_free_mailbox(&local_mailbox, 1, NULL);
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END ("err[%d]", err);
return err;
}
@@ -775,29 +867,41 @@ EXPORT_API int email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailb
EM_DEBUG_API_BEGIN ();
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_mailbox_t* curr_mailbox = NULL;
emstorage_mailbox_tbl_t* local_mailbox = NULL;
EM_IF_NULL_RETURN_VALUE(output_mailbox, EMAIL_ERROR_INVALID_PARAM);
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &local_mailbox)) != EMAIL_ERROR_NONE) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &local_mailbox)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
- return err;
+ goto FINISH_OFF;
} else {
curr_mailbox = em_malloc(sizeof(email_mailbox_t));
if (curr_mailbox == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
- return err;
+ goto FINISH_OFF;
}
memset(curr_mailbox, 0x00, sizeof(email_mailbox_t));
+
em_convert_mailbox_tbl_to_mailbox(local_mailbox, curr_mailbox);
}
*output_mailbox = curr_mailbox;
- emstorage_free_mailbox(&local_mailbox, 1, &err);
+FINISH_OFF:
+
+ if (local_mailbox)
+ emstorage_free_mailbox(&local_mailbox, 1, &err);
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -809,32 +913,31 @@ EXPORT_API int email_set_mail_slot_size(int account_id, int mailbox_id, int new_
int err = EMAIL_ERROR_NONE;
- if(new_slot_size < 0) {
+ if (new_slot_size < 0) {
EM_DEBUG_EXCEPTION("new_slot_size should be greater than 0 or should be equal to 0");
return EMAIL_ERROR_INVALID_PARAM;
}
HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAIL_SLOT_SIZE);
-
EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
if (hAPI) {
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter for account_id failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &mailbox_id, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &mailbox_id, sizeof(int))) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter for account_id failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &new_slot_size, sizeof(int))) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &new_slot_size, sizeof(int))) {
EM_DEBUG_EXCEPTION(" emipc_add_parameter for new_slot_size failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -862,7 +965,25 @@ EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id)
EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
- err = emstorage_stamp_last_sync_time_of_mailbox(input_mailbox_id, 1);
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_STAMP_SYNC_TIME_OF_MAILBOX);
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ if (hAPI) {
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter for account_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
+ }
+
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ EM_DEBUG_LOG("email_stamp_sync_time_of_mailbox error VALUE [%d]", err);
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ }
EM_DEBUG_API_END ("err[%d]", err);
return err;
diff --git a/email-api/email-api-network.c b/email-api/email-api-network.c
index a02556c..08ef234 100755
--- a/email-api/email-api-network.c
+++ b/email-api/email-api-network.c
@@ -30,7 +30,6 @@
* email-service .
*/
-#include "email-api.h"
#include "string.h"
#include "email-convert.h"
#include "email-api-mailbox.h"
@@ -46,18 +45,24 @@ EXPORT_API int email_send_mail(int mail_id, int *handle)
EM_DEBUG_API_BEGIN ("mail_id[%d] handle[%p]", mail_id, handle);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_mail_tbl_t* mail_table_data = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
ASNotiData as_noti_data;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
if(mail_id <= 0) {
EM_DEBUG_EXCEPTION("mail_id is not valid");
- err= EMAIL_ERROR_INVALID_PARAM;
+ err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- if(!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err) || !mail_table_data) {
+ if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
goto FINISH_OFF;
}
@@ -73,7 +78,7 @@ EXPORT_API int email_send_mail(int mail_id, int *handle)
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(mail_table_data->account_id, &account_server_type, false, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -88,9 +93,10 @@ EXPORT_API int email_send_mail(int mail_id, int *handle)
}
/* noti to active sync */
- as_noti_data.send_mail.handle = as_handle;
- as_noti_data.send_mail.account_id = mail_table_data->account_id;
- as_noti_data.send_mail.mail_id = mail_id;
+ as_noti_data.send_mail.handle = as_handle;
+ as_noti_data.send_mail.account_id = mail_table_data->account_id;
+ as_noti_data.send_mail.mail_id = mail_id;
+ as_noti_data.send_mail.multi_user_name = multi_user_name;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -136,6 +142,8 @@ FINISH_OFF:
emstorage_free_mail(&mail_table_data, 1, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -145,18 +153,24 @@ EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int
EM_DEBUG_API_BEGIN ("input_mail_id[%d] output_handle[%p]", input_mail_id, output_handle);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_mail_tbl_t* mail_table_data = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL task_parameter;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
if(input_mail_id <= 0) {
EM_DEBUG_EXCEPTION("mail_id is not valid");
err= EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- if(!emstorage_get_mail_by_id(input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
+ if(!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
goto FINISH_OFF;
}
@@ -170,7 +184,7 @@ EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int
EM_DEBUG_LOG("mail_table_data->account_id[%d], mail_table_data->mailbox_id[%d]", mail_table_data->account_id, mail_table_data->mailbox_id);
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(mail_table_data->account_id, &account_server_type, false, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -189,9 +203,10 @@ EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int
}
/* noti to active sync */
- as_noti_data.send_mail_with_downloading_attachment_of_original_mail.handle = as_handle;
- as_noti_data.send_mail_with_downloading_attachment_of_original_mail.mail_id = input_mail_id;
- as_noti_data.send_mail_with_downloading_attachment_of_original_mail.account_id = mail_table_data->account_id;
+ as_noti_data.send_mail_with_downloading_attachment_of_original_mail.handle = as_handle;
+ as_noti_data.send_mail_with_downloading_attachment_of_original_mail.mail_id = input_mail_id;
+ as_noti_data.send_mail_with_downloading_attachment_of_original_mail.account_id = mail_table_data->account_id;
+ as_noti_data.send_mail_with_downloading_attachment_of_original_mail.multi_user_name = multi_user_name;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL_WITH_DOWNLOADING_OF_ORIGINAL_MAIL, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -217,6 +232,8 @@ FINISH_OFF:
emstorage_free_mail(&mail_table_data, 1, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -226,24 +243,30 @@ EXPORT_API int email_schedule_sending_mail(int input_mail_id, time_t input_sched
EM_DEBUG_API_BEGIN ("mail_id[%d] input_time[%d]", input_mail_id, input_scheduled_time);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
emstorage_mail_tbl_t* mail_table_data = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL task_parameter;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
if(input_mail_id <= 0) {
EM_DEBUG_EXCEPTION("mail_id is not valid");
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- if(!emstorage_get_mail_by_id(input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
+ if(!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
goto FINISH_OFF;
}
/* check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(mail_table_data->account_id, &account_server_type, false, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -262,10 +285,11 @@ EXPORT_API int email_schedule_sending_mail(int input_mail_id, time_t input_sched
}
/* noti to active sync */
- as_noti_data.schedule_sending_mail.handle = as_handle;
- as_noti_data.schedule_sending_mail.account_id = mail_table_data->account_id;
- as_noti_data.schedule_sending_mail.mail_id = input_mail_id;
- as_noti_data.schedule_sending_mail.scheduled_time = input_scheduled_time;
+ as_noti_data.schedule_sending_mail.handle = as_handle;
+ as_noti_data.schedule_sending_mail.account_id = mail_table_data->account_id;
+ as_noti_data.schedule_sending_mail.mail_id = input_mail_id;
+ as_noti_data.schedule_sending_mail.scheduled_time = input_scheduled_time;
+ as_noti_data.schedule_sending_mail.multi_user_name = multi_user_name;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SCHEDULE_SENDING_MAIL, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -289,6 +313,8 @@ FINISH_OFF:
emstorage_free_mail(&mail_table_data, 1, NULL);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -334,6 +360,7 @@ EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int
{
EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id[%d] handle[%p]", input_account_id, input_mailbox_id, handle);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
/* int total_count = 0; */
EM_IF_ACCOUNT_ID_NULL(input_account_id, EMAIL_ERROR_INVALID_PARAM);
@@ -343,8 +370,13 @@ EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int
ASNotiData as_noti_data;
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
/* 2010/02/12 ch715.lee : check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(input_account_id, &account_server_type, true, &err) == false ) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
@@ -357,18 +389,19 @@ EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int
}
/* noti to active sync */
- as_noti_data.sync_header.handle = as_handle;
- as_noti_data.sync_header.account_id = input_account_id;
+ as_noti_data.sync_header.handle = as_handle;
+ as_noti_data.sync_header.account_id = input_account_id;
/* In case that Mailbox is NULL, SYNC ALL MAILBOX */
- as_noti_data.sync_header.mailbox_id = input_mailbox_id;
+ as_noti_data.sync_header.mailbox_id = input_mailbox_id;
+ as_noti_data.sync_header.multi_user_name = multi_user_name;
- if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
+ if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
}
- if(handle)
+ if (handle)
*handle = as_handle;
}
@@ -406,9 +439,12 @@ EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int
}
FINISH_OFF:
+
emipc_destroy_email_api(hAPI);
hAPI = NULL;
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -417,7 +453,7 @@ FINISH_OFF:
EXPORT_API int email_sync_header_for_all_account(int *handle)
{
EM_DEBUG_API_BEGIN ("handle[%p]", handle);
- char* mailbox_stream = NULL;
+ char *multi_user_name = NULL;
int err = EMAIL_ERROR_NONE;
HIPC_API hAPI = NULL;
int return_handle;
@@ -428,6 +464,11 @@ EXPORT_API int email_sync_header_for_all_account(int *handle)
int input_account_id = ALL_ACCOUNT;
int input_mailbox_id = 0; /* all case */
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
@@ -448,7 +489,7 @@ EXPORT_API int email_sync_header_for_all_account(int *handle)
if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
- EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(multi_user_name);
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -457,14 +498,13 @@ EXPORT_API int email_sync_header_for_all_account(int *handle)
if (err != EMAIL_ERROR_NONE)
goto FINISH_OFF;
- emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &return_handle);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &return_handle);
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
/* Get all accounts for sending notification to active sync engine. */
- if (!emstorage_get_account_list(&account_count, &account_tbl_array , true, false, &as_err)) {
+ if (!emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_array , true, false, &as_err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [ %d ] ", as_err);
-
goto FINISH_OFF;
}
@@ -480,10 +520,11 @@ EXPORT_API int email_sync_header_for_all_account(int *handle)
*/
/* noti to active sync */
- as_noti_data.sync_header.handle = return_handle;
- as_noti_data.sync_header.account_id = account_tbl_array[i].account_id;
+ as_noti_data.sync_header.handle = return_handle;
+ as_noti_data.sync_header.account_id = account_tbl_array[i].account_id;
/* In case that Mailbox is NULL, SYNC ALL MAILBOX */
- as_noti_data.sync_header.mailbox_id = 0;
+ as_noti_data.sync_header.mailbox_id = 0;
+ as_noti_data.sync_header.multi_user_name = multi_user_name;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -503,7 +544,8 @@ FINISH_OFF:
if ( account_tbl_array )
emstorage_free_account(&account_tbl_array, account_count, NULL);
-
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -517,6 +559,13 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
ASNotiData as_noti_data;
+ char *multi_user_name = NULL;
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
if(mail_id <= 0) {
@@ -525,7 +574,7 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
goto FINISH_OFF;
}
- if(!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err) || !mail_table_data ) {
+ if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data ) {
EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
goto FINISH_OFF;
}
@@ -538,7 +587,7 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
account_id = mail_table_data->account_id;
/* 2010/02/12 ch715.lee : check account bind type and branch off */
- if ( em_get_account_server_type_by_account_id(account_id, &account_server_type, true, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
@@ -551,10 +600,11 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
}
/* noti to active sync */
- as_noti_data.download_body.handle = as_handle;
- as_noti_data.download_body.account_id = account_id;
- as_noti_data.download_body.mail_id = mail_id;
+ as_noti_data.download_body.handle = as_handle;
+ as_noti_data.download_body.account_id = account_id;
+ as_noti_data.download_body.mail_id = mail_id;
as_noti_data.download_body.with_attachment = with_attachment;
+ as_noti_data.download_body.multi_user_name = multi_user_name;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -595,11 +645,9 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
if (err != EMAIL_ERROR_NONE)
goto FINISH_OFF;
- if(handle)
- {
+ if(handle) {
emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
EM_DEBUG_LOG("RETURN VALUE : %d handle %d", err, *handle);
-
}
}
@@ -611,6 +659,8 @@ FINISH_OFF:
emstorage_free_mail(&mail_table_data, 1, &err);
}
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -622,13 +672,19 @@ FINISH_OFF:
EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
{
EM_DEBUG_API_BEGIN ("mail_id[%d] nth[%d] handle[%p]", mail_id, nth, handle);
- char* mailbox_stream = NULL;
int err = EMAIL_ERROR_NONE;
emstorage_mail_tbl_t* mail_table_data = NULL;
int account_id = 0;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
ASNotiData as_noti_data;
+ char *multi_user_name = NULL;
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
if(mail_id <= 0) {
@@ -637,7 +693,7 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
goto FINISH_OFF;
}
- if(!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err) || !mail_table_data ) {
+ if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data ) {
EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
goto FINISH_OFF;
}
@@ -648,8 +704,8 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
}
account_id = mail_table_data->account_id;
-
- if ( em_get_account_server_type_by_account_id(account_id, &account_server_type, true, &err) == false ) {
+
+ if ( em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
@@ -662,10 +718,12 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
}
/* noti to active sync */
- as_noti_data.download_attachment.handle = as_handle;
- as_noti_data.download_attachment.account_id = account_id;
- as_noti_data.download_attachment.mail_id = mail_id;
+ as_noti_data.download_attachment.handle = as_handle;
+ as_noti_data.download_attachment.account_id = account_id;
+ as_noti_data.download_attachment.mail_id = mail_id;
as_noti_data.download_attachment.attachment_order = nth;
+ as_noti_data.download_attachment.multi_user_name = multi_user_name;
+
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
@@ -700,7 +758,6 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
/* Execute API */
if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
- EM_SAFE_FREE(mailbox_stream);
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
}
@@ -721,6 +778,8 @@ FINISH_OFF:
emstorage_free_mail(&mail_table_data, 1, &err);
}
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
@@ -736,30 +795,36 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
ASNotiData as_noti_data;
emstorage_account_tbl_t *account_list = NULL;
int i, account_count = 0;
+ char *multi_user_name = NULL;
if(input_account_id < 0)
return EMAIL_ERROR_INVALID_PARAM;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
if ( input_account_id == ALL_ACCOUNT ) {
/* this means that job is executed with all account */
/* Get all accounts for sending notification to active sync engine. */
- if (!emstorage_get_account_list(&account_count, &account_list , true, false, &err)) {
+ if (!emstorage_get_account_list(multi_user_name, &account_count, &account_list , true, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
for(i = 0; i < account_count; i++) {
- if ( em_get_account_server_type_by_account_id(account_list[i].account_id, &account_server_type, true, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, account_list[i].account_id, &account_server_type, true, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
- as_noti_data.cancel_job.account_id = account_list[i].account_id;
- as_noti_data.cancel_job.handle = input_handle;
- as_noti_data.cancel_job.cancel_type = input_cancel_type;
-
+ as_noti_data.cancel_job.account_id = account_list[i].account_id;
+ as_noti_data.cancel_job.handle = input_handle;
+ as_noti_data.cancel_job.cancel_type = input_cancel_type;
+ as_noti_data.cancel_job.multi_user_name = multi_user_name;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -802,15 +867,16 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
hAPI = NULL;
}
else {
- if ( em_get_account_server_type_by_account_id(input_account_id, &account_server_type, true, &err) == false ) {
+ if ( em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
- as_noti_data.cancel_job.account_id = input_account_id;
- as_noti_data.cancel_job.handle = input_handle;
+ as_noti_data.cancel_job.account_id = input_account_id;
+ as_noti_data.cancel_job.handle = input_handle;
+ as_noti_data.cancel_job.multi_user_name = multi_user_name;
if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
@@ -848,7 +914,8 @@ FINISH_OFF:
hAPI = NULL;
if (account_list)
emstorage_free_account(&account_list, account_count, NULL);
-
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -891,7 +958,7 @@ EXPORT_API int email_get_task_information(email_task_information_t **output_task
goto FINISH_OFF;
}
- if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
err = EMAIL_ERROR_IPC_CRASH;
goto FINISH_OFF;
@@ -967,10 +1034,222 @@ EXPORT_API int email_sync_imap_mailbox_list(int account_id, int *handle)
return err;
}
+EXPORT_API int email_search_mail_on_server(int input_account_id,
+ int input_mailbox_id,
+ email_search_filter_t *input_search_filter_list,
+ int input_search_filter_count,
+ int *output_handle)
+{
+ EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id[%d] input_search_filter_list[%p] "
+ "input_search_filter_count[%d] output_handle[%p]",
+ input_account_id, input_mailbox_id, input_search_filter_list,
+ input_search_filter_count, output_handle);
+
+ int err = EMAIL_ERROR_NONE;
+ int return_value = 0;
+ int stream_size_for_search_filter_list = 0;
+ char *stream_for_search_filter_list = NULL;
+ char *multi_user_name = NULL;
+ HIPC_API hAPI = NULL;
+ email_account_server_t account_server_type = EMAIL_SERVER_TYPE_NONE;
+ ASNotiData as_noti_data;
+
+ EM_IF_NULL_RETURN_VALUE(input_account_id, EMAIL_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_search_filter_list, EMAIL_ERROR_INVALID_PARAM);
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
+
+ if (em_get_account_server_type_by_account_id(multi_user_name,
+ input_account_id,
+ &account_server_type,
+ true,
+ &err) == false) {
+ EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
+ int as_handle = 0;
+
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
+ EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
+ goto FINISH_OFF;
+ }
+
+ /* noti to active sync */
+ as_noti_data.search_mail_on_server.handle = as_handle;
+ as_noti_data.search_mail_on_server.account_id = input_account_id;
+ as_noti_data.search_mail_on_server.mailbox_id = input_mailbox_id;
+ as_noti_data.search_mail_on_server.search_filter_list = input_search_filter_list;
+ as_noti_data.search_mail_on_server.search_filter_count = input_search_filter_count;
+ as_noti_data.search_mail_on_server.multi_user_name = multi_user_name;
+
+ return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER, &as_noti_data);
+
+ if (return_value == false) {
+ EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
+ err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if (output_handle)
+ *output_handle = as_handle;
+ }
+ else
+ {
+ hAPI = emipc_create_email_api(_EMAIL_API_SEARCH_MAIL_ON_SERVER);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_mailbox_id, sizeof(int))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ stream_for_search_filter_list = em_convert_search_filter_to_byte_stream(input_search_filter_list,
+ input_search_filter_count,
+ &stream_size_for_search_filter_list);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(stream_for_search_filter_list, hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN,
+ stream_for_search_filter_list,
+ stream_size_for_search_filter_list)) { /*prevent 18950*/
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("_EMAIL_API_SEARCH_MAIL_ON_SERVER failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if(output_handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle);
+ }
+
+FINISH_OFF:
+ if(hAPI) {
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ }
+
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_API_END ("err[%d]", err);
+ return err;
+}
+
+EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id)
+{
+ EM_DEBUG_API_BEGIN ("input_account_id[%d]", input_account_id);
+
+ int err = EMAIL_ERROR_NONE;
+ int return_value = 0;
+ HIPC_API hAPI = NULL;
+ char *multi_user_name = NULL;
+ email_account_server_t account_server_type = EMAIL_SERVER_TYPE_NONE;
+ ASNotiData as_noti_data;
+
+ EM_IF_NULL_RETURN_VALUE(input_account_id, EMAIL_ERROR_INVALID_PARAM);
+
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
+
+ if (em_get_account_server_type_by_account_id(multi_user_name,
+ input_account_id,
+ &account_server_type,
+ true,
+ &err) == false) {
+ EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
+ int as_handle = 0;
+
+ if (em_get_handle_for_activesync(&as_handle, &err) == false) {
+ EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
+ goto FINISH_OFF;
+ }
+
+ /* noti to active sync */
+ as_noti_data.clear_result_of_search_mail_on_server.handle = as_handle;
+ as_noti_data.clear_result_of_search_mail_on_server.account_id = input_account_id;
+ as_noti_data.clear_result_of_search_mail_on_server.multi_user_name = multi_user_name;
+
+ return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER,
+ &as_noti_data);
+ if (return_value == false) {
+ EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
+ err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+ }
+ else {
+ hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("_EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+
+FINISH_OFF:
+ if (hAPI) {
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ }
+
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_API_END ("err[%d]", err);
+ return err;
+}
+
EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
{
EM_DEBUG_API_BEGIN ("account_id[%d] handle[%p]", account_id, handle);
int err = EMAIL_ERROR_NONE;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
HIPC_API hAPI = NULL;
@@ -980,7 +1259,12 @@ EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
goto FINISH_OFF;
}
- if (em_get_account_server_type_by_account_id(account_id, &account_server_type, false, &err) == false ) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false ) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
@@ -1015,6 +1299,7 @@ FINISH_OFF:
emipc_destroy_email_api(hAPI);
hAPI = (HIPC_API)NULL;
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
diff --git a/email-api/email-api-rule.c b/email-api/email-api-rule.c
index 3290150..4bd92c0 100755
--- a/email-api/email-api-rule.c
+++ b/email-api/email-api-rule.c
@@ -30,7 +30,6 @@
* email-service .
*/
-#include "email-api.h"
#include "string.h"
#include "email-convert.h"
#include "email-storage.h"
@@ -43,19 +42,26 @@ EXPORT_API int email_get_rule(int filter_id, email_rule_t** filtering_set)
EM_DEBUG_API_BEGIN ("filter_id[%d] filtering_set[%p]", filter_id, filtering_set);
int err = 0;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(filter_id, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
- if (!emstorage_get_rule_by_id(filter_id, (emstorage_rule_tbl_t**)filtering_set, true, &err)) {
+ if (!emstorage_get_rule_by_id(multi_user_name, filter_id, (emstorage_rule_tbl_t**)filtering_set, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_rule_by_id failed [%d]", err);
-
goto FINISH_OFF;
} else
err = EMAIL_ERROR_NONE;
FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -67,22 +73,28 @@ EXPORT_API int email_get_rule_list(email_rule_t** filtering_set, int* count)
int err = EMAIL_ERROR_NONE;
int is_completed = 0;
+ char *multi_user_name = NULL;
EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
*count = 1000;
-
- if (!emstorage_get_rule(0, 0, 0, count, &is_completed, (emstorage_rule_tbl_t**)filtering_set, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_rule failed [%d]", err);
-
+ if (!emstorage_get_rule(multi_user_name, 0, 0, 0, count, &is_completed, (emstorage_rule_tbl_t**)filtering_set, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_rule failed [%d]", err);
goto FINISH_OFF;
} else
err = EMAIL_ERROR_NONE;
FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
diff --git a/email-api/email-api-smime.c b/email-api/email-api-smime.c
index c84890b..293f08e 100755
--- a/email-api/email-api-smime.c
+++ b/email-api/email-api-smime.c
@@ -30,8 +30,8 @@
* Email Engine .
*/
-#include "email-api.h"
#include "string.h"
+#include "email-api-mail.h"
#include "email-convert.h"
#include "email-api-account.h"
#include "email-storage.h"
@@ -150,36 +150,48 @@ EXPORT_API int email_get_certificate(char *email_address, email_certificate_t **
EM_DEBUG_API_BEGIN ();
int err = EMAIL_ERROR_NONE;
char temp_email_address[130] = {0, };
+ char *multi_user_name = NULL;
emstorage_certificate_tbl_t *cert = NULL;
EM_IF_NULL_RETURN_VALUE(email_address, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(certificate, EMAIL_ERROR_INVALID_PARAM);
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
SNPRINTF(temp_email_address, sizeof(temp_email_address), "<%s>", email_address);
-
- if (!emstorage_get_certificate_by_email_address(temp_email_address, &cert, false, 0, &err)) {
+
+ if (!emstorage_get_certificate_by_email_address(multi_user_name, temp_email_address, &cert, false, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_certificate_by_index failed - %d", err);
- return err;
+ goto FINISH_OFF;
}
if (!em_convert_certificate_tbl_to_certificate(cert, certificate, &err)) {
EM_DEBUG_EXCEPTION("em_convert_certificate_tbl_to_certificate failed");
- return err;
+ goto FINISH_OFF;
}
-
+
+FINISH_OFF:
+
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
-EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
+EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data,
+ int *output_attachment_count, int *verify)
{
EM_DEBUG_API_BEGIN ("mail_id[%d]", mail_id);
int err = EMAIL_ERROR_NONE;
int p_output_attachment_count = 0;
- int i = 0;
- int verify = 0;
+ int i = 0;
char *decrypt_filepath = NULL;
- char *search = NULL;
+ char *search = NULL;
+ char *multi_user_name = NULL;
email_mail_data_t *p_output_mail_data = NULL;
email_attachment_data_t *p_output_attachment_data = NULL;
emstorage_account_tbl_t *p_account_tbl = NULL;
@@ -192,17 +204,22 @@ EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output
goto FINISH_OFF;
}
- if ((err = emcore_get_mail_data(mail_id, &p_output_mail_data)) != EMAIL_ERROR_NONE) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]");
+ goto FINISH_OFF;
+ }
+
+ if ((err = emcore_get_mail_data(multi_user_name, mail_id, &p_output_mail_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed");
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(p_output_mail_data->account_id, EMAIL_ACC_GET_OPT_OPTIONS, &p_account_tbl, false, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, p_output_mail_data->account_id, EMAIL_ACC_GET_OPT_OPTIONS, &p_account_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed : [%d]", err);
goto FINISH_OFF;
}
- if ((err = emcore_get_attachment_data_list(mail_id, &p_output_attachment_data, &p_output_attachment_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_get_attachment_data_list(multi_user_name, mail_id, &p_output_attachment_data, &p_output_attachment_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed");
goto FINISH_OFF;
}
@@ -233,12 +250,12 @@ EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output
}
emcore_clean_openssl_library();
} else if (p_output_mail_data->smime_type == EMAIL_PGP_ENCRYPTED) {
- if ((err = emcore_pgp_get_decrypted_message(p_output_attachment_data[i].attachment_path, p_output_mail_data->pgp_password, false, &decrypt_filepath, &verify)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_pgp_get_decrypted_message(p_output_attachment_data[i].attachment_path, p_output_mail_data->pgp_password, false, &decrypt_filepath, verify)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_pgp_get_decrypted_message failed : [%d]", err);
goto FINISH_OFF;
}
} else if (p_output_mail_data->smime_type == EMAIL_PGP_SIGNED_AND_ENCRYPTED) {
- if ((err = emcore_pgp_get_decrypted_message(p_output_attachment_data[i].attachment_path, p_output_mail_data->pgp_password, true, &decrypt_filepath, &verify)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_pgp_get_decrypted_message(p_output_attachment_data[i].attachment_path, p_output_mail_data->pgp_password, true, &decrypt_filepath, verify)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_pgp_get_decrypted_message failed : [%d]", err);
goto FINISH_OFF;
}
@@ -279,19 +296,26 @@ FINISH_OFF:
if (p_output_attachment_data)
email_free_attachment_data(&p_output_attachment_data, p_output_attachment_count);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
-EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data, int input_attachment_count,
- email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
+EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data,
+ int input_attachment_count,
+ email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data,
+ int *output_attachment_count,
+ int *verify)
{
EM_DEBUG_API_BEGIN ();
int err = EMAIL_ERROR_NONE;
- int i = 0;
- int verify = 0;
+ int i = 0;
char *decrypt_filepath = NULL;
- char *search = NULL;
+ char *search = NULL;
+ char *multi_user_name = NULL;
emstorage_account_tbl_t *p_account_tbl = NULL;
EM_IF_NULL_RETURN_VALUE(input_mail_data, EMAIL_ERROR_INVALID_PARAM);
@@ -302,7 +326,12 @@ EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data,
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(input_mail_data->account_id, EMAIL_ACC_GET_OPT_OPTIONS, &p_account_tbl, false, &err)) {
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (!emstorage_get_account_by_id(multi_user_name, input_mail_data->account_id, EMAIL_ACC_GET_OPT_OPTIONS, &p_account_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed : [%d]", err);
goto FINISH_OFF;
}
@@ -325,20 +354,20 @@ EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data,
}
if (input_mail_data->smime_type == EMAIL_SMIME_ENCRYPTED || input_mail_data->smime_type == EMAIL_SMIME_SIGNED_AND_ENCRYPTED) {
- emcore_init_openssl_library();
+ emcore_init_openssl_library();
if (!emcore_smime_get_decrypt_message(input_attachment_data[i].attachment_path, p_account_tbl->certificate_path, &decrypt_filepath, &err)) {
EM_DEBUG_EXCEPTION("emcore_smime_get_decrypt_message failed");
- emcore_clean_openssl_library();
+ emcore_clean_openssl_library();
goto FINISH_OFF;
}
- emcore_clean_openssl_library();
+ emcore_clean_openssl_library();
} else if (input_mail_data->smime_type == EMAIL_PGP_ENCRYPTED) {
- if ((err = emcore_pgp_get_decrypted_message(input_attachment_data[i].attachment_path, input_mail_data->pgp_password, false, &decrypt_filepath, &verify)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_pgp_get_decrypted_message(input_attachment_data[i].attachment_path, input_mail_data->pgp_password, false, &decrypt_filepath, verify)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_pgp_get_decrypted_message failed : [%d]", err);
goto FINISH_OFF;
}
} else if (input_mail_data->smime_type == EMAIL_PGP_SIGNED_AND_ENCRYPTED) {
- if ((err = emcore_pgp_get_decrypted_message(input_attachment_data[i].attachment_path, input_mail_data->pgp_password, true, &decrypt_filepath, &verify)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_pgp_get_decrypted_message(input_attachment_data[i].attachment_path, input_mail_data->pgp_password, true, &decrypt_filepath, verify)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_pgp_get_decrypted_message failed : [%d]", err);
goto FINISH_OFF;
}
@@ -369,6 +398,7 @@ EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data,
FINISH_OFF:
EM_SAFE_FREE(decrypt_filepath);
+ EM_SAFE_FREE(multi_user_name);
if (p_account_tbl)
emstorage_free_account(&p_account_tbl, 1, NULL);
@@ -380,11 +410,15 @@ FINISH_OFF:
EXPORT_API int email_verify_signature(int mail_id, int *verify)
{
EM_DEBUG_API_BEGIN ("mail_id[%d]", mail_id);
+
+ if (mail_id <= 0) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return EMAIL_ERROR_INVALID_PARAM;
+ }
+
int result_from_ipc = 0;
- int err = EMAIL_ERROR_NONE;
int p_verify = 0;
-
- EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM);
+ int err = EMAIL_ERROR_NONE;
HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VERIFY_SIGNATURE);
if (hAPI == NULL) {
@@ -441,12 +475,18 @@ EXPORT_API int email_verify_signature_ex(email_mail_data_t *input_mail_data, ema
break;
}
+ if (count == input_attachment_count) {
+ EM_DEBUG_LOG("No have the signed attachment");
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return EMAIL_ERROR_INVALID_PARAM;
+ }
+
if (input_mail_data->smime_type == EMAIL_SMIME_SIGNED) {
- emcore_init_openssl_library();
+ emcore_init_openssl_library();
if (!emcore_verify_signature(input_attachment_data[count].attachment_path, input_mail_data->file_path_mime_entity, verify, &err))
EM_DEBUG_EXCEPTION("emcore_verify_signature failed : [%d]", err);
- emcore_clean_openssl_library();
+ emcore_clean_openssl_library();
} else if(input_mail_data->smime_type == EMAIL_PGP_SIGNED) {
if ((err = emcore_pgp_get_verify_signature(input_attachment_data[count].attachment_path, input_mail_data->file_path_mime_entity, input_mail_data->digest_type, verify)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_pgp_get_verify_siganture failed : [%d]", err);
@@ -540,10 +580,10 @@ EXPORT_API int email_check_ocsp_status(char *email_address, char *response_url,
EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
}
- emipc_get_paramter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
if (err == EMAIL_ERROR_NONE) {
if (handle)
- emipc_get_paramter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
}
}
*/
@@ -557,12 +597,18 @@ EXPORT_API int email_validate_certificate(int account_id, char *email_address, u
int err = EMAIL_ERROR_NONE;
int as_handle = 0;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
ASNotiData as_noti_data;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
- if (em_get_account_server_type_by_account_id(account_id, &account_server_type, false, &err) == false) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -582,7 +628,8 @@ EXPORT_API int email_validate_certificate(int account_id, char *email_address, u
as_noti_data.validate_certificate.handle = as_handle;
as_noti_data.validate_certificate.account_id = account_id;
- as_noti_data.validate_certificate.email_address = strdup(email_address);
+ as_noti_data.validate_certificate.email_address = email_address;
+ as_noti_data.validate_certificate.multi_user_name = multi_user_name;
if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_VALIDATE_CERTIFICATE, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed");
@@ -595,6 +642,7 @@ EXPORT_API int email_validate_certificate(int account_id, char *email_address, u
FINISH_OFF:
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
@@ -609,12 +657,18 @@ EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address,
int err = EMAIL_ERROR_NONE;
int as_handle = 0;
+ char *multi_user_name = NULL;
email_account_server_t account_server_type;
ASNotiData as_noti_data;
+ if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_get_user_name failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
memset(&as_noti_data, 0x00, sizeof(ASNotiData));
- if (em_get_account_server_type_by_account_id(account_id, &account_server_type, false, &err) == false) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
goto FINISH_OFF;
@@ -632,9 +686,10 @@ EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address,
goto FINISH_OFF;
}
- as_noti_data.get_resolve_recipients.handle = as_handle;
- as_noti_data.get_resolve_recipients.account_id = account_id;
- as_noti_data.get_resolve_recipients.email_address = strdup(email_address);
+ as_noti_data.get_resolve_recipients.handle = as_handle;
+ as_noti_data.get_resolve_recipients.account_id = account_id;
+ as_noti_data.get_resolve_recipients.email_address = email_address;
+ as_noti_data.get_resolve_recipients.multi_user_name = multi_user_name;
if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_RESOLVE_RECIPIENT, &as_noti_data) == false) {
EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed");
@@ -647,6 +702,7 @@ EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address,
FINISH_OFF:
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_API_END ("err[%d]", err);
return err;
}
diff --git a/email-api/include/email-api-account.h b/email-api/include/email-api-account.h
index 6da101a..f9c7ced 100755
--- a/email-api/include/email-api-account.h
+++ b/email-api/include/email-api-account.h
@@ -26,7 +26,6 @@
#include "email-types.h"
/**
- * @internal
* @ingroup EMAIL_SERVICE_FRAMEWORK
* @defgroup EMAIL_SERVICE_ACCOUNT_MODULE Account API
* @brief Account API is a set of operations to manage email accounts like add, update, delete or get account related details.
@@ -145,7 +144,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_ACCOUNT_MODULE
* @{
*/
diff --git a/email-api/include/email-api-etc.h b/email-api/include/email-api-etc.h
index f97a49c..f6d3821 100755
--- a/email-api/include/email-api-etc.h
+++ b/email-api/include/email-api-etc.h
@@ -25,7 +25,6 @@
*/
/**
- * @internal
* @ingroup EMAIL_SERVICE_FRAMEWORK
* @defgroup EMAIL_SERVICE_ETC_MODULE Other API
* @brief Various API set for initializing and MIME operations and verifying email address.
@@ -38,7 +37,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_FRAMEWORK
* @{
*/
diff --git a/email-api/include/email-api-init.h b/email-api/include/email-api-init.h
index 6e15f3f..22f4e93 100755
--- a/email-api/include/email-api-init.h
+++ b/email-api/include/email-api-init.h
@@ -26,7 +26,6 @@
#include "email-types.h"
/**
- * @internal
* @file email-api-init.h
* @brief This file contains the data structures and interfaces of Email FW Initialization provided by email-service.
*
@@ -74,7 +73,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_ETC_MODULE
* @{
*/
diff --git a/email-api/include/email-api-mail.h b/email-api/include/email-api-mail.h
index b2cdf1a..9ff8c12 100755
--- a/email-api/include/email-api-mail.h
+++ b/email-api/include/email-api-mail.h
@@ -34,7 +34,6 @@
*/
/**
- * @internal
* @ingroup EMAIL_SERVICE_FRAMEWORK
* @defgroup EMAIL_SERVICE_MAIL_MODULE Mail API
* @brief Mail API is a set of operations to manage mail like add, update, delete or get mail related details.
@@ -47,7 +46,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_MAIL_MODULE
* @{
*/
diff --git a/email-api/include/email-api-mailbox.h b/email-api/include/email-api-mailbox.h
index 60ceeea..52e98a8 100755
--- a/email-api/include/email-api-mailbox.h
+++ b/email-api/include/email-api-mailbox.h
@@ -105,7 +105,6 @@
*/
/**
- * @internal
* @ingroup EMAIL_SERVICE_FRAMEWORK
* @defgroup EMAIL_SERVICE_MAILBOX_MODULE Mailbox API
* @brief Mailbox API is a set of operations to manage email mailboxes like add, update, delete or get mailbox related details.
@@ -118,7 +117,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_MAILBOX_MODULE
* @{
*/
diff --git a/email-api/include/email-api-network.h b/email-api/include/email-api-network.h
index cbce793..f439578 100755
--- a/email-api/include/email-api-network.h
+++ b/email-api/include/email-api-network.h
@@ -26,7 +26,6 @@
#include "email-types.h"
/**
- * @internal
* @file email-api-network.h
* @brief This file contains the data structures and interfaces of Network related Functionality provided by
* email-service.
@@ -141,7 +140,6 @@
*/
/**
- * @internal
* @ingroup EMAIL_SERVICE_FRAMEWORK
* @defgroup EMAIL_SERVICE_NETWORK_MODULE Network API
* @brief Network API is a set of operations to manage email send, receive and cancel related details.
@@ -154,7 +152,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_NETWORK_MODULE
* @{
*/
@@ -367,6 +364,48 @@ EXPORT_API int email_send_saved(int account_id, int *handle);
EXPORT_API int email_sync_imap_mailbox_list(int account_id, int *handle);
/**
+ * @brief Searches the mails on the server.
+ *
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/email
+ *
+ * @param[in] account_id The Account ID
+ * @param[in] mailbox_id The Mailbox ID
+ * @param[in] input_search_filter_list The searching type \n
+ * #EMAIL_SEARCH_FILTER_SUBJECT, #EMAIL_SEARCH_FILTER_SENDER, \n
+ * #EMAIL_SEARCH_FILTER_RECIPIENT, #EMAIL_SEARCH_FILTER_ALL, etc \n
+ * and The value to use for searching \n
+ * Example: Subject, email address, display name
+ * @param[in] input_search_filter_count Count of input_search_filter_list
+ * @param[out] output_handle The handle for search on server
+ *
+ * @return #EMAIL_ERROR_NONE on success,
+ * otherwise an error code (see #EMAIL_ERROR_XXX) on failure
+ *
+ * @see #email_search_filter_t
+ */
+EXPORT_API int email_search_mail_on_server(int input_account_id, int input_mailbox_id,
+ email_search_filter_t *input_search_filter_list,
+ int input_search_filter_count, int *output_handle);
+
+/**
+ * @brief Deletes temporarily downloaded mails from the local storage.
+ *
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/email
+ *
+ * @param[in] input_account_id The Account ID
+ *
+ * @return #EMAIL_ERROR_NONE on success,
+ * otherwise an error code (see #EMAIL_ERROR_XXX) on failure
+ *
+ * @see #email_search_filter_t
+ */
+EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id);
+
+/**
* @brief Queries the maximum mail size limit from the SMTP server.
*
* @since_tizen 2.3
diff --git a/email-api/include/email-api-rule.h b/email-api/include/email-api-rule.h
index 68b5644..e9b6e90 100755
--- a/email-api/include/email-api-rule.h
+++ b/email-api/include/email-api-rule.h
@@ -92,7 +92,6 @@
*/
/**
- * @internal
* @ingroup EMAIL_SERVICE_FRAMEWORK
* @defgroup EMAIL_SERVICE_RULE_MOUDLE Rule API
* @brief Rule API is a set of operations to manage email rules like add, get, delete or update rule related details.
@@ -105,7 +104,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_RULE_MOUDLE
* @{
*/
diff --git a/email-api/include/email-api-smime.h b/email-api/include/email-api-smime.h
index a9d27d8..4019d90 100755
--- a/email-api/include/email-api-smime.h
+++ b/email-api/include/email-api-smime.h
@@ -33,7 +33,6 @@ extern "C" {
*/
/**
- * @internal
* @ingroup EMAIL_SERVICE_FRAMEWORK
* @defgroup EMAIL_SERVICE_SMIME_MODULE SMIME API
* @brief SMIME API is a set of operations to handle SMIME data for secured email.
@@ -46,7 +45,6 @@ extern "C" {
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_SMIME_MODULE
* @{
*/
@@ -103,11 +101,15 @@ EXPORT_API int email_get_certificate(char *email_address, email_certificate_t **
* @param[out] output_mail_data The mail data
* @param[out] output_attachment_data The mail attachment data
* @param[out] output_attachment_count The count of attachment
+ * @param[out] verify The verification state \n
+ * [false : failed verification, true : verification successful]
*
* @return #EMAIL_ERROR_NONE on success,
* otherwise an error code (see #EMAIL_ERROR_XXX) on failure
*/
-EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
+EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data,
+ int *output_attachment_count, int *verify);
/**
* @brief Gets a decrypted message.
@@ -120,10 +122,18 @@ EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output
* @param[out] output_mail_data Specifies the mail_data
* @param[out] output_attachment_data Specifies the mail_attachment_data
* @param[out] output_attachment_count Specifies the count of attachment
+ * @param[out] verify The verification state \n
+ * [false : failed verification, true : verification successful]
+
* @return EMAIL_ERROR_NONE on success or an error code (refer to EMAIL_ERROR_XXX) on failure
*/
-EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data, int input_attachment_count,
- email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
+EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data,
+ int input_attachment_count,
+ email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data,
+ int *output_attachment_count,
+ int *verify);
/**
* @brief Verifies a signed mail.
*
diff --git a/email-common-use/email-convert.c b/email-common-use/email-convert.c
index 0545b19..35cc901 100755
--- a/email-common-use/email-convert.c
+++ b/email-common-use/email-convert.c
@@ -117,6 +117,7 @@ INTERNAL_FUNC int em_convert_account_to_account_tbl(email_account_t *account, em
account_tbl->outgoing_server_size_limit = account->outgoing_server_size_limit;
account_tbl->wifi_auto_download = account->wifi_auto_download;
+ account_tbl->user_name = EM_SAFE_STRDUP(account->user_name);
EM_DEBUG_FUNC_END();
return ret;
}
@@ -192,6 +193,7 @@ INTERNAL_FUNC int em_convert_account_tbl_to_account(emstorage_account_tbl_t *acc
account->digest_type = account_tbl->digest_type;
account->outgoing_server_size_limit = account_tbl->outgoing_server_size_limit;
account->wifi_auto_download = account_tbl->wifi_auto_download;
+ account->user_name = EM_SAFE_STRDUP(account_tbl->user_name);
EM_DEBUG_FUNC_END();
return ret;
@@ -346,6 +348,7 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_ta
}
memcpy(temp_mail_data[i].eas_data, mail_table_data[i].eas_data, mail_table_data[i].eas_data_length);
temp_mail_data[i].pgp_password = EM_SAFE_STRDUP(mail_table_data[i].pgp_password);
+ temp_mail_data[i].user_name = EM_SAFE_STRDUP(mail_table_data[i].user_name);
}
*mail_data = temp_mail_data;
@@ -453,6 +456,7 @@ INTERNAL_FUNC int em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_dat
}
memcpy(temp_mail_tbl[i].eas_data, mail_data[i].eas_data, mail_data[i].eas_data_length);
temp_mail_tbl[i].pgp_password = EM_SAFE_STRDUP(mail_data[i].pgp_password);
+ temp_mail_tbl[i].user_name = EM_SAFE_STRDUP(mail_data[i].user_name);
}
*mail_table_data = temp_mail_tbl;
@@ -677,8 +681,87 @@ static int fetch_string_from_stream(char *input_stream, int *input_output_stream
}
/* divide struct at binary field (void* user_data)*/
#define EMAIL_ACCOUNT_FMT "S(" "isiii" "isii" ")" "B" "S(" "issss" "isiss" "iiiii" "iiiii" "isiss" "iii"\
- "$(" "iiiii" "iisii" "iisi" "iiiis" ")" "iiiiiisii" ")"
+ "$(" "iiiii" "iisii" "iisi" "iiiis" ")" "iiiiiisiis" ")"
+/* For converting fmt : to distinguish between 64bit or 32bit */
+static char *convert_format(char *fmt)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ if (fmt == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return NULL;
+ }
+
+ int size = 0;
+ int string_size = 0;
+ int ret = false;
+ char *c = NULL;
+ char *converted_fmt = NULL;
+
+ string_size = strlen(fmt);
+ converted_fmt = em_malloc(string_size + 1);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ return NULL;
+ }
+
+ c = fmt;
+ while (*c != '\0') {
+ switch (*c) {
+ case 'c':
+ case 'i':
+ case 'u':
+ case 'j':
+ case 'v':
+ case 'I':
+ case 'U':
+ case 'f':
+ case 's':
+ case '#':
+ case 'B':
+ case 'A':
+ case 'S':
+ case '$': /* nested structure */
+ case ')':
+ case '(':
+ strncat(converted_fmt, c, 1);
+ break;
+ case 't': /* special charater for time_t */
+ case 'T':
+ size = sizeof(time_t);
+ if (size == 4) {
+ /* 32bit */
+ strncat(converted_fmt, "i", 1);
+ } else if (size == 8) {
+ /* 64bit */
+ strncat(converted_fmt, "I", 1);
+ } else {
+ EM_DEBUG_LOG("size : [%d]", size);
+ }
+
+ break;
+ default:
+ EM_DEBUG_EXCEPTION("unsupported option %c\n", *c);
+ goto FINISH_OFF;
+ }
+ c++;
+ }
+
+ EM_DEBUG_LOG_DEV("original fmt : [%s]", fmt);
+ EM_DEBUG_LOG_DEV("converted_fmt : [%s]", converted_fmt);
+
+ ret = true;
+
+FINISH_OFF:
+
+ if (ret == false) {
+ EM_SAFE_FREE(converted_fmt);
+ }
+
+ EM_DEBUG_FUNC_END();
+ return converted_fmt;
+}
INTERNAL_FUNC char* em_convert_account_to_byte_stream(email_account_t* account, int *stream_len)
{
@@ -687,12 +770,22 @@ INTERNAL_FUNC char* em_convert_account_to_byte_stream(email_account_t* account,
tpl_node *tn = NULL;
tpl_bin tb;
+ char *converted_fmt = NULL;
- tn = tpl_map(EMAIL_ACCOUNT_FMT, account, &tb, &(account->user_data_length));
+ converted_fmt = convert_format(EMAIL_ACCOUNT_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return NULL;
+ }
+
+ tn = tpl_map(converted_fmt, account, &tb, &(account->user_data_length));
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return NULL;
}
+ EM_SAFE_FREE(converted_fmt);
+
tb.sz = account->user_data_length;
tb.addr = account->user_data;
tpl_pack(tn, 0);
@@ -704,6 +797,7 @@ INTERNAL_FUNC char* em_convert_account_to_byte_stream(email_account_t* account,
tpl_free(tn);
*stream_len = len;
+
EM_DEBUG_FUNC_END();
return (char*) buf;
}
@@ -717,12 +811,22 @@ INTERNAL_FUNC void em_convert_byte_stream_to_account(char *stream, int stream_le
tpl_node *tn = NULL;
tpl_bin tb;
+ char *converted_fmt = NULL;
- tn = tpl_map(EMAIL_ACCOUNT_FMT, account, &tb, &(account->user_data_length));
+ converted_fmt = convert_format(EMAIL_ACCOUNT_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return;
+ }
+
+ tn = tpl_map(converted_fmt, account, &tb, &(account->user_data_length));
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
}
+ EM_SAFE_FREE(converted_fmt);
+
tpl_load(tn, TPL_MEM, stream, stream_len);
tpl_unpack(tn, 0);
tpl_free(tn);
@@ -733,8 +837,8 @@ INTERNAL_FUNC void em_convert_byte_stream_to_account(char *stream, int stream_le
EM_DEBUG_FUNC_END();
}
-#define EMAIL_MAIL_DATA_FMT "S(" "iiiis" "iisss" "issss" "sssss" "sisss"\
- "icccc" "cccii" "iiiii" "iisii" "iiiii" "iisi" ")B"
+#define EMAIL_MAIL_DATA_FMT "S(" "iiiis" "tisss" "issss" "sssss" "sisss"\
+ "icccc" "cccii" "iiiii" "iisii" "iitii" "ttsss" "si" ")B"
INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_data, int *stream_len)
{
@@ -744,14 +848,23 @@ INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_
tpl_node *tn = NULL;
tpl_bin tb;
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_MAIL_DATA_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return NULL;
+ }
EM_DEBUG_LOG("eas_data_length[%d]", mail_data->eas_data_length); /*prevent 44369*/
- tn = tpl_map(EMAIL_MAIL_DATA_FMT, mail_data, &tb);
+ tn = tpl_map(converted_fmt, mail_data, &tb);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return NULL;
}
+ EM_SAFE_FREE(converted_fmt);
tb.sz = mail_data->eas_data_length;
tb.addr = mail_data->eas_data;
tpl_pack(tn, 0);
@@ -763,6 +876,7 @@ INTERNAL_FUNC char* em_convert_mail_data_to_byte_stream(email_mail_data_t *mail_
tpl_free(tn);
*stream_len = len;
+
EM_DEBUG_FUNC_END();
return (char*) buf;
}
@@ -775,12 +889,21 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_
tpl_node *tn = NULL;
tpl_bin tb;
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_MAIL_DATA_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return;
+ }
- tn = tpl_map(EMAIL_MAIL_DATA_FMT, mail_data, &tb);
+ tn = tpl_map(converted_fmt, mail_data, &tb);
if(!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
}
+ EM_SAFE_FREE(converted_fmt);
tpl_load(tn, TPL_MEM, stream, stream_len);
tpl_unpack(tn, 0);
@@ -809,14 +932,23 @@ INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(email_attachment_d
email_attachment_data_t cur = {0};
tpl_node *tn = NULL;
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_ATTACHMENT_DATA_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("convertinf failed");
+ return NULL;
+ }
/* tpl_map adds value at 2nd param addr to packing buffer iterately */
/* 2nd param value (not addr via pointer) should be modified at each iteration */
- tn = tpl_map(EMAIL_ATTACHMENT_DATA_FMT, &cur);
+ tn = tpl_map(converted_fmt, &cur);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return NULL;
}
+ EM_SAFE_FREE(converted_fmt);
/* if attachment_count is zero, for loop is skipped */
int i=0;
@@ -849,11 +981,21 @@ INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int s
email_attachment_data_t cur = {0};
tpl_node *tn = NULL;
- tn = tpl_map(EMAIL_ATTACHMENT_DATA_FMT, &cur);
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_ATTACHMENT_DATA_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return;
+ }
+
+ tn = tpl_map(converted_fmt, &cur);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
}
+ EM_SAFE_FREE(converted_fmt);
tpl_load(tn, TPL_MEM, stream, stream_len);
/* tpl does not return the size of variable-length array, but we need variable-length array */
@@ -885,11 +1027,12 @@ INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int s
*attachment_count = num_element;
*attachment_data = attached;
+
EM_DEBUG_FUNC_END();
}
-#define EMAIL_MAILBOX_FMT "S(" "isisi" "iiiii" "iiii" ")B"
+#define EMAIL_MAILBOX_FMT "S(" "isisi" "iiiii" "itii" ")B"
INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(email_mailbox_t *mailbox_data, int *stream_len)
{
@@ -899,14 +1042,23 @@ INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(email_mailbox_t *mailbox_d
tpl_node *tn = NULL;
tpl_bin tb;
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_MAILBOX_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return NULL;
+ }
EM_DEBUG_LOG("eas_data_length[%d]", mailbox_data->eas_data_length);
- tn = tpl_map(EMAIL_MAILBOX_FMT, mailbox_data, &tb);
+ tn = tpl_map(converted_fmt, mailbox_data, &tb);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return NULL;
}
+ EM_SAFE_FREE(converted_fmt);
tb.sz = mailbox_data->eas_data_length;
tb.addr = mailbox_data->eas_data;
tpl_pack(tn, 0);
@@ -920,6 +1072,7 @@ INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(email_mailbox_t *mailbox_d
tpl_free(tn);
*stream_len = len;
+
EM_DEBUG_FUNC_END("serialized len: %d", len);
return (char*) buf;
}
@@ -933,12 +1086,21 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mailbox(char *stream, int stream_le
tpl_node *tn = NULL;
tpl_bin tb;
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_MAILBOX_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return;
+ }
- tn = tpl_map(EMAIL_MAILBOX_FMT, mailbox_data, &tb);
+ tn = tpl_map(converted_fmt, mailbox_data, &tb);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
}
+ EM_SAFE_FREE(converted_fmt);
tpl_load(tn, TPL_MEM, stream, stream_len);
tpl_unpack(tn, 0);
@@ -965,12 +1127,21 @@ INTERNAL_FUNC char* em_convert_option_to_byte_stream(email_option_t* option, int
EM_IF_NULL_RETURN_VALUE(stream_len, NULL);
tpl_node *tn = NULL;
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_OPTION_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return NULL;
+ }
- tn = tpl_map(EMAIL_OPTION_FMT, option);
+ tn = tpl_map(converted_fmt, option);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return NULL;
}
+ EM_SAFE_FREE(converted_fmt);
tpl_pack(tn, 0);
/* write account to buffer */
@@ -980,6 +1151,7 @@ INTERNAL_FUNC char* em_convert_option_to_byte_stream(email_option_t* option, int
tpl_free(tn);
*stream_len = len;
+
EM_DEBUG_FUNC_END("serialized len: %d", len);
return (char*) buf;
}
@@ -991,12 +1163,21 @@ INTERNAL_FUNC void em_convert_byte_stream_to_option(char *stream, int stream_len
EM_NULL_CHECK_FOR_VOID(option);
tpl_node *tn = NULL;
+ char *converted_fmt = NULL;
- tn = tpl_map(EMAIL_OPTION_FMT, option);
+ converted_fmt = convert_format(EMAIL_OPTION_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return;
+ }
+
+ tn = tpl_map(converted_fmt, option);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
}
+ EM_SAFE_FREE(converted_fmt);
tpl_load(tn, TPL_MEM, stream, stream_len);
tpl_unpack(tn, 0);
tpl_free(tn);
@@ -1014,12 +1195,21 @@ INTERNAL_FUNC char* em_convert_rule_to_byte_stream(email_rule_t *rule, int *stre
EM_IF_NULL_RETURN_VALUE(stream_len, NULL);
tpl_node *tn = NULL;
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_RULE_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return NULL;
+ }
- tn = tpl_map(EMAIL_RULE_FMT, rule);
+ tn = tpl_map(converted_fmt, rule);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return NULL;
}
+ EM_SAFE_FREE(converted_fmt);
tpl_pack(tn, 0);
/* write account to buffer */
@@ -1029,6 +1219,7 @@ INTERNAL_FUNC char* em_convert_rule_to_byte_stream(email_rule_t *rule, int *stre
tpl_free(tn);
*stream_len = len;
+
EM_DEBUG_FUNC_END("serialized len: %d", len);
return (char*) buf;
}
@@ -1040,12 +1231,21 @@ INTERNAL_FUNC void em_convert_byte_stream_to_rule(char *stream, int stream_len,
EM_NULL_CHECK_FOR_VOID(rule);
tpl_node *tn = NULL;
+ char *converted_fmt = NULL;
- tn = tpl_map(EMAIL_RULE_FMT, rule);
+ converted_fmt = convert_format(EMAIL_RULE_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return;
+ }
+
+ tn = tpl_map(converted_fmt, rule);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
}
+ EM_SAFE_FREE(converted_fmt);
tpl_load(tn, TPL_MEM, stream, stream_len);
tpl_unpack(tn, 0);
tpl_free(tn);
@@ -1063,8 +1263,15 @@ INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_
tpl_node *tn = NULL;
tpl_bin tb[4];
+ char *converted_fmt = NULL;
- tn = tpl_map(EMAIL_MEETING_REQUEST_FMT,
+ converted_fmt = convert_format(EMAIL_MEETING_REQUEST_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return NULL;
+ }
+
+ tn = tpl_map(converted_fmt,
&meeting_req->mail_id,
&meeting_req->meeting_response,
&tb[0],
@@ -1080,16 +1287,17 @@ INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_
&meeting_req->time_zone.daylight_bias
);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return NULL;
}
+ EM_SAFE_FREE(converted_fmt);
tb[0].sz = tb[1].sz = tb[2].sz = tb[3].sz = sizeof(struct tm);
tb[0].addr = &meeting_req->start_time;
tb[1].addr = &meeting_req->end_time;
tb[2].addr = &meeting_req->time_zone.standard_time_start_date;
tb[3].addr = &meeting_req->time_zone.daylight_time_start_date;
-
tpl_pack(tn, 0);
/* write account to buffer */
@@ -1099,6 +1307,7 @@ INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_
tpl_free(tn);
*stream_len = len;
+
EM_DEBUG_FUNC_END();
return (char*) buf;
}
@@ -1112,8 +1321,15 @@ INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char *stream, int strea
tpl_node *tn = NULL;
tpl_bin tb[4];
+ char *converted_fmt = NULL;
+
+ converted_fmt = convert_format(EMAIL_MEETING_REQUEST_FMT);
+ if (converted_fmt == NULL) {
+ EM_DEBUG_EXCEPTION("converting failed");
+ return;
+ }
- tn = tpl_map(EMAIL_MEETING_REQUEST_FMT,
+ tn = tpl_map(converted_fmt,
&meeting_req->mail_id,
&meeting_req->meeting_response,
&tb[0],
@@ -1129,12 +1345,14 @@ INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char *stream, int strea
&meeting_req->time_zone.daylight_bias
);
if (!tn) {
+ EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
}
tpl_load(tn, TPL_MEM, stream, stream_len);
tpl_unpack(tn, 0);
tpl_free(tn);
+ EM_SAFE_FREE(converted_fmt);
/* tb will be destroyed at end of func, but tb.addr remains */
memcpy(&meeting_req->start_time, tb[0].addr, sizeof(struct tm));
@@ -1192,6 +1410,8 @@ INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_
case EMAIL_SEARCH_FILTER_TYPE_TO :
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
result_stream = append_string_to_stream(result_stream, &stream_size, input_search_filter_list[i].search_filter_key_value.string_type_key_value);
break;
@@ -1272,6 +1492,8 @@ INTERNAL_FUNC void em_convert_byte_stream_to_search_filter(char *input_stream,
case EMAIL_SEARCH_FILTER_TYPE_TO :
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
fetch_string_from_stream(input_stream, &stream_offset, &(local_search_filter[i].search_filter_key_value.string_type_key_value));
break;
diff --git a/email-common-use/email-utilities.c b/email-common-use/email-utilities.c
index 7b486c2..b5215a7 100755
--- a/email-common-use/email-utilities.c
+++ b/email-common-use/email-utilities.c
@@ -53,10 +53,14 @@ INTERNAL_FUNC void* em_malloc(int len)
return NULL;
}
- void *p = calloc(1,len);
- if (!p)
+ void *p = NULL;
+ p = malloc(len);
+ if (!p) {
EM_DEBUG_PERROR("malloc failed");
+ return NULL;
+ }
+ memset(p, 0x00, len);
return p;
}
@@ -113,10 +117,10 @@ INTERNAL_FUNC char *em_trim_right(char *str)
if (!str) return NULL;
p = str+EM_SAFE_STRLEN(str)-1;
- while (((int)p >= (int)str) && (*p == ' ' || *p == '\t' || *p == LF || *p == CR))
+ while ((p >= str) && (*p == ' ' || *p == '\t' || *p == LF || *p == CR))
*p --= '\0';
- if ((int) p < (int)str)
+ if (p < str)
return NULL;
return str;
@@ -426,62 +430,6 @@ FINISH_OFF:
return err;
}
-
-/* Memory clean up */
-#include <sys/mman.h>
-
-/* #define GETSP() ({ unsigned int sp; asm volatile ("mov %0, sp " : "=r"(sp)); sp;}) */
-#define BUF_SIZE 256
-#define PAGE_SIZE (1 << 12)
-#define _ALIGN_UP(addr, size) (((addr)+((size)-1))&(~((size)-1)))
-#define _ALIGN_DOWN(addr, size) ((addr)&(~((size)-1)))
-#define PAGE_ALIGN(addr) _ALIGN_DOWN(addr, PAGE_SIZE)
-
-int stack_trim(void)
-{
- /*
- char buf[BUF_SIZE];
- FILE *file;
- unsigned int stacktop;
- int found = 0;
- unsigned int sp;
-
- asm volatile ("mov %0, sp " : "=r"(sp));
-
- sprintf(buf, "/proc/%d/maps", getpid());
- file = fopen(buf, "r");
- while (fgets(buf, BUF_SIZE, file) != NULL) {
- if (strstr(buf, "[stack]")) {
- found = 1;
- break;
- }
- }
-
- fclose(file);
-
- if (found) {
- sscanf(buf, "%x-", &stacktop);
- if (madvise((void *)PAGE_ALIGN(stacktop), PAGE_ALIGN(sp)-stacktop, MADV_DONTNEED) < 0)
- perror("stack madvise fail");
- }
- */
- return 1;
-}
-
-INTERNAL_FUNC void em_flush_memory()
-{
- EM_DEBUG_FUNC_BEGIN();
- /* flush memory in heap */
- malloc_trim(0);
-
- /* flush memory in stack */
- stack_trim();
-
- /* flush memory for sqlite */
- emstorage_flush_db_cache();
- EM_DEBUG_FUNC_END();
-}
-
INTERNAL_FUNC int em_get_file_name_from_file_path(char *input_source_file_path, char **output_file_name)
{
EM_DEBUG_FUNC_BEGIN_SEC("input_source_file_path[%s], output_file_name [%p]", input_source_file_path, output_file_name);
@@ -617,7 +565,7 @@ INTERNAL_FUNC char *em_shrink_filename(char *fname, int size_limit)
char *modified_name = NULL;
char *extension = NULL;
-
+
modified_name = em_malloc(sizeof(char)*size_limit);
if (!modified_name) {
return NULL;
@@ -668,7 +616,6 @@ INTERNAL_FUNC char *em_shrink_filename(char *fname, int size_limit)
snprintf(modified_name, sizeof(char)*size_limit, "%s", fname);
}
}
-
} else {
snprintf(modified_name, sizeof(char)*size_limit, "%s", fname);
}
@@ -1088,17 +1035,17 @@ INTERNAL_FUNC int em_find_pos_stripped_subject_for_thread_view(char *subject, ch
- while ((result = strstr(curpos, "RE:")) != NULL) {
+ while ((result = g_strrstr(curpos, "RE:")) != NULL) {
curpos = result + 3;
EM_DEBUG_LOG_SEC("RE result : %s", curpos);
}
- while ((result = strstr(curpos, "FWD:")) != NULL) {
+ while ((result = g_strrstr(curpos, "FWD:")) != NULL) {
curpos = result + 4;
EM_DEBUG_LOG_SEC("FWD result : %s", curpos);
}
- while ((result = strstr(curpos, "FW:")) != NULL) {
+ while ((result = g_strrstr(curpos, "FW:")) != NULL) {
curpos = result + 3;
EM_DEBUG_LOG_SEC("FW result : %s", curpos);
}
@@ -1180,7 +1127,7 @@ INTERNAL_FUNC int em_decode_base64(unsigned char *enc_text, unsigned long enc_le
return ret;
}
-INTERNAL_FUNC int em_get_account_server_type_by_account_id(int account_id, email_account_server_t* account_server_type, int flag, int *error)
+INTERNAL_FUNC int em_get_account_server_type_by_account_id(char *multi_user_name, int account_id, email_account_server_t* account_server_type, int flag, int *error)
{
EM_DEBUG_FUNC_BEGIN();
emstorage_account_tbl_t *account_tbl_data = NULL;
@@ -1194,7 +1141,7 @@ INTERNAL_FUNC int em_get_account_server_type_by_account_id(int account_id, email
goto FINISH_OFF;
}
- if( !emstorage_get_account_by_id(account_id, WITHOUT_OPTION, &account_tbl_data, false, &err)) {
+ if( !emstorage_get_account_by_id(multi_user_name, account_id, WITHOUT_OPTION, &account_tbl_data, false, &err)) {
EM_DEBUG_EXCEPTION ("emstorage_get_account_by_id failed [%d] ", err);
ret = false;
goto FINISH_OFF;
@@ -1272,7 +1219,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int em_check_socket_privilege_by_pid(int pid)
+INTERNAL_FUNC int em_check_socket_privilege_by_pid(long pid)
{
EM_DEBUG_FUNC_BEGIN("pid [%d]", pid);
int smack_ret = 0;
@@ -1287,7 +1234,7 @@ INTERNAL_FUNC int em_check_socket_privilege_by_pid(int pid)
return EMAIL_ERROR_NONE;
}
-INTERNAL_FUNC int em_check_db_privilege_by_pid(int pid)
+INTERNAL_FUNC int em_check_db_privilege_by_pid(long pid)
{
EM_DEBUG_FUNC_BEGIN("pid [%d]", pid);
int smack_ret = 0;
@@ -1307,7 +1254,7 @@ INTERNAL_FUNC int em_check_db_privilege_by_pid(int pid)
pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER;
-email_thread_handle_t* em_thread_create (void *(*thread_exit)(void*), void *arg)
+email_thread_handle_t* em_thread_create(void *(*thread_exit)(void*), void *arg)
{
pthread_mutex_lock(&g_mu);
diff --git a/email-common-use/include/email-debug-log.h b/email-common-use/include/email-debug-log.h
index fe981c1..4a05b78 100755
--- a/email-common-use/include/email-debug-log.h
+++ b/email-common-use/include/email-debug-log.h
@@ -252,6 +252,13 @@ extern "C"
((_src) && (_dest))? strcmp(_dest, _src) : -1;\
})
+#define EM_SAFE_STRCASECMP(dest, src) \
+ ({\
+ char* _dest = dest;\
+ char* _src = src;\
+ ((_src) && (_dest))? strcasecmp(_dest, _src) : -1;\
+ })
+
#define EM_SAFE_STRCPY(dest, src) \
({\
char* _dest = dest;\
@@ -292,10 +299,9 @@ extern "C"
#define ERRNO_BUF_SIZE 64
#define EM_STRERROR(errno_buf) ({\
- strerror_r(errno, errno_buf, sizeof(errno_buf));\
- errno_buf;\
- })
-
+ strerror_r(errno, errno_buf, sizeof(errno_buf));\
+ errno_buf;\
+ })
#ifdef __cplusplus
}
diff --git a/email-common-use/include/email-errors.h b/email-common-use/include/email-errors.h
index 73a71b1..12ca356 100755
--- a/email-common-use/include/email-errors.h
+++ b/email-common-use/include/email-errors.h
@@ -29,7 +29,6 @@
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_FRAMEWORK
* @{
*/
@@ -82,6 +81,7 @@
#define EMAIL_ERROR_SECURED_STORAGE_FAILURE -2100 /**< Error from secured storage */
#define EMAIL_ERROR_GCONF_FAILURE -1058 /**< The error occurred on accessing Gconf */
#define EMAIL_ERROR_FILE -1059 /**< File related error */
+#define EMAIL_ERROR_SERVER_STORAGE_FULL -2101 /**< There is no more storage in server */
/* Error codes for network */
#define EMAIL_ERROR_SOCKET_FAILURE -1031 /**< Socket operation failed */
@@ -97,7 +97,6 @@
#define EMAIL_ERROR_TLS_NOT_SUPPORTED -1040 /**< The server doesn't support TLS */
#define EMAIL_ERROR_TLS_SSL_FAILURE -1041 /**< The agent failed TLS/SSL */
#define EMAIL_ERROR_CANNOT_NEGOTIATE_TLS -1400 /**< "Cannot negotiate TLS" */
-
#define EMAIL_ERROR_NO_RESPONSE -1036 /**< There is no server response */
/* Error codes for authentication */
@@ -230,6 +229,15 @@
#define EMAIL_ERROR_FAILED_BY_SECURITY_POLICY -1303 /**< Failed by security policy */
#define EMAIL_ERROR_FLIGHT_MODE -1206 /**< The network is flight mode */
+/* Container : KNOX */
+#define EMAIL_ERROR_CONTAINER_CREATE_FAILED -2001 /**< Failed to create the container (Since 2.4) */
+#define EMAIL_ERROR_CONTAINER_GET_DOMAIN -2002 /**< Failed to get the domain information (Since 2.4) */
+#define EMAIL_ERROR_CONTAINER_NOT_FOUND -2003 /**< Failed to found the container (Since 2.4) */
+#define EMAIL_ERROR_CONTAINER_SET_LINK -2004 /**< Failed to set shared socket link (Since 2.4) */
+#define EMAIL_ERROR_CONTAINER_ITERATE_DOMAIN -2005 /**< Failed to set interate domain (Since 2.4) */
+#define EMAIL_ERROR_CONTAINER_NOT_INITIALIZATION -2006 /**< Not created the container yet (Since 2.4) */
+#define EMAIL_ERROR_CONTAINER_JOIN_ZONE_FAILED -2007 /**< Failed to join zone in the container (Since 2.4) */
+#define EMAIL_ERROR_CONTAINER_LOOKUP_ZONE_FAILED -2008 /**< Failed to lookup the zone (Since 2.4) */
/**
* @}
*/
diff --git a/email-common-use/include/email-internal-types.h b/email-common-use/include/email-internal-types.h
index 7db3be5..fcd5bce 100755
--- a/email-common-use/include/email-internal-types.h
+++ b/email-common-use/include/email-internal-types.h
@@ -63,18 +63,17 @@ extern "C"
#define __FEATURE_XLIST_SUPPORT__
#define __FEATURE_SUPPORT_REPORT_MAIL__
#define __FEATURE_SUPPORT_IMAP_ID__
-#define __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__
-#define __FEATURE_SUPPORT_VALIDATION_SYSTEM__
+/* #define __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__ */
+/* #define __FEATURE_SUPPORT_VALIDATION_SYSTEM__ */
#define __FEATURE_PROGRESS_IN_OUTBOX__
/* #define __FEATURE_USE_SHARED_MUTEX_FOR_PROTECTED_FUNC_CALL__ */
#define __FEATURE_IMAP_IDLE__
-#define __FEATURE_DRIVING_MODE__
+/* #define __FEATURE_DRIVING_MODE__ */
#define __FEATURE_DELETE_MAILBOX_RECURSIVELY__
#define __FEATURE_RENAME_MAILBOX_RECURSIVELY__
#define __FEATURE_AUTO_RETRY_SEND__
#define __FEATURE_SMTP_VALIDATION__
-#define __FEATURE_USE_GMIME__
#define __FEATURE_WIFI_AUTO_DOWNLOAD__
#define __FEATURE_BLOCKING_MODE__
@@ -86,10 +85,12 @@ extern "C"
/* #define __FEATURE_FORK_FOR_CURL__ */
/* #define __FEATURE_USE_DRM_API__ */
#define __FEATURE_SECURE_PGP__
-#define __FEATURE_SYNC_STATUS__
+/* #define __FEATURE_SYNC_STATUS__ */
#define __FEATURE_NOTIFICATION_ENABLE__
+/* #define __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__ */
/* #define __FEATURE_IMAP_QUOTA__ */
+#define __FEATURE_DBUS_CALL_STATUS__
/* ----------------------------------------------------------------------------- */
/* Macro */
@@ -134,7 +135,7 @@ extern "C"
#define EMAILPATH DATA_PATH"/email"
#define MAILHOME DATA_PATH"/email/.email_data"
#define MAILTEMP MAILHOME"/tmp"
-#define DIRECTORY_PERMISSION 0755
+#define DIRECTORY_PERMISSION 0775
#define MIME_SUBTYPE_DRM_OBJECT "vnd.oma.drm.message"
#define MIME_SUBTYPE_DRM_RIGHTS "vnd.oma.drm.rights+xml"
@@ -175,6 +176,7 @@ extern "C"
#define SAVE_TYPE_BUFFER 2 /* save content to buffer */
#define SAVE_TYPE_FILE 3 /* save content to temporary file */
+#define TOKEN_FOR_MULTI_USER "_"
#define SNPRINTF(buff, size, format, args...) snprintf(buff, size, format, ##args)
#define SNPRINTF_OFFSET(base_buf, offset, base_size, format, args...) \
@@ -223,7 +225,7 @@ typedef pthread_t thread_t;
#define VCONF_KEY_DEFAULT_ACCOUNT_ID "db/private/email-service/default_account_id"
#define VCONF_KEY_NOTI_PRIVATE_ID "db/private/email-service/noti_private_id"
-#define VCONF_KEY_TOPMOST_WINDOW "db/private/org.tizen.email/is_topmost_window"
+#define VCONF_KEY_TOPMOST_WINDOW "db/private/org.tizen.email/is_inbox_active"
#define OUTMODE "wb"
#define INMODE "rb"
@@ -242,6 +244,8 @@ typedef pthread_t thread_t;
#define EMAIL_LAUNCHED_BY_UNKNOWN_METHOD 0
#define EMAIL_LAUNCHED_BY_DBUS_ACTIVATION 1
+#define EML_FOLDER 20 /* save eml content to temporary folder */
+
/* __FEATURE_LOCAL_ACTIVITY__ supported
#define BULK_OPERATION_COUNT 50
#define ALL_ACTIVITIES 0
@@ -314,6 +318,14 @@ typedef enum {
EMAIL_ALARM_CLASS_IMAP_IDLE = 5,
} email_alarm_class_t;
+#ifdef __FEATURE_DBUS_CALL_STATUS__
+typedef enum {
+ CALL_STATE_IDLE,
+ CALL_STATE_RINGTONE,
+ CALL_STATE_OFFHOOK,
+ CALL_STATE_MAX
+} call_state_e;
+#endif /* __FEATURE_DBUS_CALL_STATUS__ */
/* event information */
typedef struct
@@ -322,6 +334,7 @@ typedef struct
int handle;
email_event_type_t type;
email_event_status_type_t status;
+ char *multi_user_name;
char *event_param_data_1; /* in general, mailbox name (exception in emcore_send_mail, emcore_send_saved_mail it is email_option_t **/
char *event_param_data_2;
char *event_param_data_3;
@@ -431,15 +444,15 @@ typedef enum
typedef struct
{
- int account_id;
- int mail_id;
- unsigned long server_mail_id;
- int activity_id;
- int mailbox_id;
- char *mailbox_name;
- email_event_type_t event_type; /* Event Type Null means event is created from local activitys */
- int activity_type; /* Activity Type Null means event is created from event queue */
-
+ int account_id;
+ int mail_id;
+ unsigned long server_mail_id;
+ int activity_id;
+ int mailbox_id;
+ char *mailbox_name;
+ char *multi_user_name;
+ email_event_type_t event_type; /* Event Type Null means event is created from local activitys */
+ int activity_type; /* Activity Type Null means event is created from event queue */
} email_event_partial_body_thd;
#endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */
@@ -452,6 +465,102 @@ typedef enum
EMAIL_ALERT_TYPE_NONE,
} EMAIL_ALERT_TYPE;
+enum {
+ /* Account */
+ _EMAIL_API_ADD_ACCOUNT = 0x01000000, /**< IPC API ID for email_add_account */
+ _EMAIL_API_DELETE_ACCOUNT = 0x01000001, /**< IPC API ID for email_delete_account */
+ _EMAIL_API_UPDATE_ACCOUNT = 0x01000002, /**< IPC API ID for email_update_account */
+ _EMAIL_API_GET_ACCOUNT = 0x01000003, /**< IPC API ID for email_get_account */
+ _EMAIL_API_GET_ACCOUNT_LIST = 0x01000005, /**< IPC API ID for email_get_account_list */
+ _EMAIL_API_GET_MAILBOX_COUNT = 0x01000007, /**< IPC API ID for email_get_mailbox_count */
+ _EMAIL_API_VALIDATE_ACCOUNT = 0x01000008, /**< IPC API ID for email_validate_account */
+ _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION = 0x01000009, /**< IPC API ID for email_add_account_with_validation */
+ _EMAIL_API_BACKUP_ACCOUNTS = 0x0100000A, /**< IPC API ID for email_backup_accounts */
+ _EMAIL_API_RESTORE_ACCOUNTS = 0x0100000B, /**< IPC API ID for email_restore_accounts */
+ _EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT = 0x0100000C, /**< IPC API ID for email_get_password_legnth_of_account */
+ _EMAIL_API_VALIDATE_ACCOUNT_EX = 0x0100000D, /**< IPC API ID for email_validate_account_ex */
+ _EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID = 0x0100000E, /**< IPC API ID for email_save_default_account_id */
+ _EMAIL_API_LOAD_DEFAULT_ACCOUNT_ID = 0x01000010, /**< IPC API ID for email_load_default_account_id */
+
+ /* Mail */
+ _EMAIL_API_DELETE_MAIL = 0x01100002, /**< IPC API ID for email_delete_mail */
+ _EMAIL_API_DELETE_ALL_MAIL = 0x01100004, /**< IPC API ID for email_delete_mail_all */
+ _EMAIL_API_GET_MAILBOX_LIST = 0x01100006, /**< IPC API ID for email_get_mailbox_list */
+ _EMAIL_API_GET_SUBMAILBOX_LIST = 0x01100007, /**< IPC API ID for email_get_submailbox_list */
+ _EMAIL_API_CLEAR_DATA = 0x01100009, /**< IPC API ID for email_clear_data */
+ _EMAIL_API_MOVE_MAIL = 0x0110000A, /**< IPC API ID for email_move_mail */
+ _EMAIL_API_MOVE_ALL_MAIL = 0x0110000B, /**< IPC API ID for email_move_all_mail */
+ _EMAIL_API_ADD_ATTACHMENT = 0x0110000C, /**< IPC API ID for email_move_add_attachment */
+ _EMAIL_API_GET_ATTACHMENT = 0x0110000D, /**< IPC API ID for email_get_attachment */
+ _EMAIL_API_DELETE_ATTACHMENT = 0x0110000E, /**< IPC API ID for email_delete_attachment */
+ _EMAIL_API_MODIFY_MAIL_FLAG = 0x0110000F, /**< IPC API ID for email_modify_mail_flag */
+ _EMAIL_API_MODIFY_MAIL_EXTRA_FLAG = 0x01100011, /**< IPC API ID for email_modify_mail_extra_flag */
+ _EMAIL_API_SET_FLAGS_FIELD = 0x01100016, /**< IPC API ID for email_set_flags_field */
+ _EMAIL_API_ADD_MAIL = 0x01100017, /**< IPC API ID for email_add_mail */
+ _EMAIL_API_UPDATE_MAIL = 0x01100018, /**< IPC API ID for email_update_mail */
+ _EMAIL_API_ADD_READ_RECEIPT = 0x01100019, /**< IPC API ID for email_add_read_receipt */
+ _EMAIL_API_EXPUNGE_MAILS_DELETED_FLAGGED = 0x0110001A, /**< IPC API ID for email_expunge_mails_deleted_flagged */
+
+ /* Thread */
+ _EMAIL_API_MOVE_THREAD_TO_MAILBOX = 0x01110000, /**< IPC API ID for email_move_thread_to_mailbox */
+ _EMAIL_API_DELETE_THREAD = 0x01110001, /**< IPC API ID for email_delete_thread */
+ _EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD = 0x01110002, /**< IPC API ID for email_modify_seen_flag_of_thread */
+
+ /* Mailbox */
+ _EMAIL_API_ADD_MAILBOX = 0x01200000, /**< IPC API ID for email_add_mailbox */
+ _EMAIL_API_DELETE_MAILBOX = 0x01200001, /**< IPC API ID for email_delete mailbox */
+ _EMAIL_API_STAMP_SYNC_TIME_OF_MAILBOX = 0x01200006, /**< IPC API ID for email_stamp_sync_time_of_mailbox */
+ _EMAIL_API_SET_MAIL_SLOT_SIZE = 0x01200007, /**< IPC API ID for email_set_mail_slot_size */
+ _EMAIL_API_RENAME_MAILBOX = 0x01200008, /**< IPC API ID for email_rename_mailbox */
+ _EMAIL_API_RENAME_MAILBOX_EX = 0x0120000B, /**< IPC API ID for email_rename_mailbox_ex */
+ _EMAIL_API_SET_MAILBOX_TYPE = 0x01200009, /**< IPC API ID for email_set_mailbox_type */
+ _EMAIL_API_SET_LOCAL_MAILBOX = 0x0120000A, /**< IPC API ID for email_set_local_mailbox */
+
+ /* Network */
+ _EMAIL_API_SEND_MAIL = 0x01300000, /**< IPC API ID for email_send_mail */
+ _EMAIL_API_SYNC_HEADER = 0x01300001, /**< IPC API ID for email_sycn_header */
+ _EMAIL_API_DOWNLOAD_BODY = 0x01300002, /**< IPC API ID for email_download_body */
+ _EMAIL_API_DOWNLOAD_ATTACHMENT = 0x01300003, /**< IPC API ID for email_download_attachment */
+ _EMAIL_API_SEND_SAVED = 0x01300005, /**< IPC API ID for email_send_saved */
+ _EMAIL_API_DELETE_EMAIL = 0x01300007, /**< IPC API ID for email_delete_email */
+ _EMAIL_API_DELETE_EMAIL_ALL = 0x01300008, /**< IPC API ID for email_delete_email_all */
+ _EMAIL_API_GET_IMAP_MAILBOX_LIST = 0x01300015, /**< IPC API ID for email_get_imap_mailbox_list */
+ _EMAIL_API_SEND_MAIL_CANCEL_JOB = 0x01300017, /**< IPC API ID for email_send_mail_cancel_job */
+ _EMAIL_API_SEARCH_MAIL_ON_SERVER = 0x01300019, /**< IPC API ID for email_search_mail_on_server */
+ _EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER = 0x0130001A, /**< IPC API ID for email_clear_result_of_search_mail_on_server */
+ _EMAIL_API_QUERY_SMTP_MAIL_SIZE_LIMIT = 0x0130001B, /**< IPC API ID for email_query_smtp_mail_size_limit */
+
+ /* Rule */
+ _EMAIL_API_ADD_RULE = 0x01400000, /**< IPC API ID for email_add_rule */
+ _EMAIL_API_GET_RULE = 0x01400001, /**< IPC API ID for email_get_rule */
+ _EMAIL_API_GET_RULE_LIST = 0x01400002, /**< IPC API ID for email_get_rule_list */
+ _EMAIL_API_FIND_RULE = 0x01400003, /**< IPC API ID for email_find_rule */
+ _EMAIL_API_DELETE_RULE = 0x01400004, /**< IPC API ID for email_delete_rule */
+ _EMAIL_API_UPDATE_RULE = 0x01400005, /**< IPC API ID for email_update_rule */
+ _EMAIL_API_APPLY_RULE = 0x01400006, /**< IPC API ID for email_apply_rule */
+ _EMAIL_API_CANCEL_JOB = 0x01400007, /**< IPC API ID for email_cancel_job */
+ _EMAIL_API_SEND_RETRY = 0x01400009, /**< IPC API ID for email_send_retry */
+ _EMAIL_API_UPDATE_ACTIVITY = 0x0140000A, /**< IPC API ID for email_update_activity */
+ _EMAIL_API_SYNC_LOCAL_ACTIVITY = 0x0140000B, /**< IPC API ID for email_sync_local_activity */
+
+ /* Etc */
+ _EMAIL_API_PING_SERVICE = 0x01500000, /**< IPC API ID for email_ping_service */
+ _EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL = 0x01500001, /**< IPC API ID for email_update_notification_bar_for_unread_mail */
+ _EMAIL_API_SHOW_USER_MESSAGE = 0x01500002, /**< IPC API ID for email_show_user_message */
+ _EMAIL_API_WRITE_MIME_FILE = 0x01500003, /**< IPC API ID for email_write_mime_file */
+ _EMAIL_API_GET_TASK_INFORMATION = 0x01500004, /**< IPC API ID for email_get_task_information */
+ _EMAIL_API_CLEAR_NOTIFICATION_BAR = 0x01500005,
+ _EMAIL_API_GET_USER_NAME = 0x01500006,
+
+ /* Smime */
+ _EMAIL_API_ADD_CERTIFICATE = 0x01600000, /**< IPC API ID for email_add_certificate */
+ _EMAIL_API_DELETE_CERTIFICATE = 0x01600001, /**< IPC API ID for email_delete_certificate */
+ _EMAIL_API_VERIFY_SIGNATURE = 0x01600002, /**< IPC API ID for email_verify_signature */
+ _EMAIL_API_VERIFY_CERTIFICATE = 0x01600003, /**< IPC API ID for email_verify_certificate */
+};
+
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/email-common-use/include/email-types.h b/email-common-use/include/email-types.h
index e0b7af2..e379c48 100755
--- a/email-common-use/include/email-types.h
+++ b/email-common-use/include/email-types.h
@@ -24,13 +24,11 @@
#define __EMAIL_TYPES_H__
/**
- * @internal
* @file email-types.h
* @brief This file is the header file of Email Framework library.
*/
/**
- * @internal
* @addtogroup EMAIL_SERVICE_FRAMEWORK
* @{
*/
@@ -232,94 +230,6 @@ extern "C"
/* Enumerations */
/*****************************************************************************/
-enum {
- /* Account */
- _EMAIL_API_ADD_ACCOUNT = 0x01000000, /**< IPC API ID for email_add_account */
- _EMAIL_API_DELETE_ACCOUNT = 0x01000001, /**< IPC API ID for email_delete_account */
- _EMAIL_API_UPDATE_ACCOUNT = 0x01000002, /**< IPC API ID for email_update_account */
- _EMAIL_API_GET_ACCOUNT = 0x01000003, /**< IPC API ID for email_get_account */
- _EMAIL_API_GET_ACCOUNT_LIST = 0x01000005, /**< IPC API ID for email_get_account_list */
- _EMAIL_API_GET_MAILBOX_COUNT = 0x01000007, /**< IPC API ID for email_get_mailbox_count */
- _EMAIL_API_VALIDATE_ACCOUNT = 0x01000008, /**< IPC API ID for email_validate_account */
- _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION = 0x01000009, /**< IPC API ID for email_add_account_with_validation */
- _EMAIL_API_BACKUP_ACCOUNTS = 0x0100000A, /**< IPC API ID for email_backup_accounts */
- _EMAIL_API_RESTORE_ACCOUNTS = 0x0100000B, /**< IPC API ID for email_restore_accounts */
- _EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT = 0x0100000C, /**< IPC API ID for email_get_password_legnth_of_account */
- _EMAIL_API_VALIDATE_ACCOUNT_EX = 0x0100000D, /**< IPC API ID for email_validate_account_ex */
-
- /* Mail */
- _EMAIL_API_DELETE_MAIL = 0x01100002, /**< IPC API ID for email_delete_mail */
- _EMAIL_API_DELETE_ALL_MAIL = 0x01100004, /**< IPC API ID for email_delete_mail_all */
- _EMAIL_API_GET_MAILBOX_LIST = 0x01100006, /**< IPC API ID for email_get_mailbox_list */
- _EMAIL_API_GET_SUBMAILBOX_LIST = 0x01100007, /**< IPC API ID for email_get_submailbox_list */
- _EMAIL_API_CLEAR_DATA = 0x01100009, /**< IPC API ID for email_clear_data */
- _EMAIL_API_MOVE_MAIL = 0x0110000A, /**< IPC API ID for email_move_mail */
- _EMAIL_API_MOVE_ALL_MAIL = 0x0110000B, /**< IPC API ID for email_move_all_mail */
- _EMAIL_API_ADD_ATTACHMENT = 0x0110000C, /**< IPC API ID for email_move_add_attachment */
- _EMAIL_API_GET_ATTACHMENT = 0x0110000D, /**< IPC API ID for email_get_attachment */
- _EMAIL_API_DELETE_ATTACHMENT = 0x0110000E, /**< IPC API ID for email_delete_attachment */
- _EMAIL_API_MODIFY_MAIL_FLAG = 0x0110000F, /**< IPC API ID for email_modify_mail_flag */
- _EMAIL_API_MODIFY_MAIL_EXTRA_FLAG = 0x01100011, /**< IPC API ID for email_modify_mail_extra_flag */
- _EMAIL_API_SET_FLAGS_FIELD = 0x01100016, /**< IPC API ID for email_set_flags_field */
- _EMAIL_API_ADD_MAIL = 0x01100017, /**< IPC API ID for email_add_mail */
- _EMAIL_API_UPDATE_MAIL = 0x01100018, /**< IPC API ID for email_update_mail */
- _EMAIL_API_ADD_READ_RECEIPT = 0x01100019, /**< IPC API ID for email_add_read_receipt */
- _EMAIL_API_EXPUNGE_MAILS_DELETED_FLAGGED = 0x0110001A, /**< IPC API ID for email_expunge_mails_deleted_flagged */
-
- /* Thread */
- _EMAIL_API_MOVE_THREAD_TO_MAILBOX = 0x01110000, /**< IPC API ID for email_move_thread_to_mailbox */
- _EMAIL_API_DELETE_THREAD = 0x01110001, /**< IPC API ID for email_delete_thread */
- _EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD = 0x01110002, /**< IPC API ID for email_modify_seen_flag_of_thread */
-
- /* Mailbox */
- _EMAIL_API_ADD_MAILBOX = 0x01200000, /**< IPC API ID for email_add_mailbox */
- _EMAIL_API_DELETE_MAILBOX = 0x01200001, /**< IPC API ID for email_delete mailbox */
- _EMAIL_API_SET_MAIL_SLOT_SIZE = 0x01200007, /**< IPC API ID for email_set_mail_slot_size */
- _EMAIL_API_RENAME_MAILBOX = 0x01200008, /**< IPC API ID for email_rename_mailbox */
- _EMAIL_API_RENAME_MAILBOX_EX = 0x0120000B, /**< IPC API ID for email_rename_mailbox_ex */
- _EMAIL_API_SET_MAILBOX_TYPE = 0x01200009, /**< IPC API ID for email_set_mailbox_type */
- _EMAIL_API_SET_LOCAL_MAILBOX = 0x0120000A, /**< IPC API ID for email_set_local_mailbox */
-
- /* Network */
- _EMAIL_API_SEND_MAIL = 0x01300000, /**< IPC API ID for email_send_mail */
- _EMAIL_API_SYNC_HEADER = 0x01300001, /**< IPC API ID for email_sycn_header */
- _EMAIL_API_DOWNLOAD_BODY = 0x01300002, /**< IPC API ID for email_download_body */
- _EMAIL_API_DOWNLOAD_ATTACHMENT = 0x01300003, /**< IPC API ID for email_download_attachment */
- _EMAIL_API_SEND_SAVED = 0x01300005, /**< IPC API ID for email_send_saved */
- _EMAIL_API_DELETE_EMAIL = 0x01300007, /**< IPC API ID for email_delete_email */
- _EMAIL_API_DELETE_EMAIL_ALL = 0x01300008, /**< IPC API ID for email_delete_email_all */
- _EMAIL_API_GET_IMAP_MAILBOX_LIST = 0x01300015, /**< IPC API ID for email_get_imap_mailbox_list */
- _EMAIL_API_SEND_MAIL_CANCEL_JOB = 0x01300017, /**< IPC API ID for email_send_mail_cancel_job */
- _EMAIL_API_QUERY_SMTP_MAIL_SIZE_LIMIT = 0x0130001B, /**< IPC API ID for email_query_smtp_mail_size_limit */
-
- /* Rule */
- _EMAIL_API_ADD_RULE = 0x01400000, /**< IPC API ID for email_add_rule */
- _EMAIL_API_GET_RULE = 0x01400001, /**< IPC API ID for email_get_rule */
- _EMAIL_API_GET_RULE_LIST = 0x01400002, /**< IPC API ID for email_get_rule_list */
- _EMAIL_API_FIND_RULE = 0x01400003, /**< IPC API ID for email_find_rule */
- _EMAIL_API_DELETE_RULE = 0x01400004, /**< IPC API ID for email_delete_rule */
- _EMAIL_API_UPDATE_RULE = 0x01400005, /**< IPC API ID for email_update_rule */
- _EMAIL_API_APPLY_RULE = 0x01400006, /**< IPC API ID for email_apply_rule */
- _EMAIL_API_CANCEL_JOB = 0x01400007, /**< IPC API ID for email_cancel_job */
- _EMAIL_API_SEND_RETRY = 0x01400009, /**< IPC API ID for email_send_retry */
- _EMAIL_API_UPDATE_ACTIVITY = 0x0140000A, /**< IPC API ID for email_update_activity */
- _EMAIL_API_SYNC_LOCAL_ACTIVITY = 0x0140000B, /**< IPC API ID for email_sync_local_activity */
-
- /* Etc */
- _EMAIL_API_PING_SERVICE = 0x01500000, /**< IPC API ID for email_ping_service */
- _EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL = 0x01500001, /**< IPC API ID for email_update_notification_bar_for_unread_mail */
- _EMAIL_API_SHOW_USER_MESSAGE = 0x01500002, /**< IPC API ID for email_show_user_message */
- _EMAIL_API_WRITE_MIME_FILE = 0x01500003, /**< IPC API ID for email_write_mime_file */
- _EMAIL_API_GET_TASK_INFORMATION = 0x01500004, /**< IPC API ID for email_get_task_information */
- _EMAIL_API_CLEAR_NOTIFICATION_BAR = 0x01500005,
-
- /* Smime */
- _EMAIL_API_ADD_CERTIFICATE = 0x01600000, /**< IPC API ID for email_add_certificate */
- _EMAIL_API_DELETE_CERTIFICATE = 0x01600001, /**< IPC API ID for email_delete_certificate */
- _EMAIL_API_VERIFY_SIGNATURE = 0x01600002, /**< IPC API ID for email_verify_signature */
- _EMAIL_API_VERIFY_CERTIFICATE = 0x01600003, /**< IPC API ID for email_verify_certificate */
-};
-
typedef enum
{
EMAIL_DELETE_LOCALLY = 0, /**< Delete mail locally only */
@@ -793,7 +703,7 @@ typedef enum
EMAIL_SET_SLOT_SIZE_START, /**< Task started */
EMAIL_SET_SLOT_SIZE_FINISH, /**< Task finished */
EMAIL_SET_SLOT_SIZE_FAIL, /**< Task failed */
-}email_set_slot_size_status_e;
+} email_set_slot_size_status_e;
/**
* @brief Enumeration for the status of expunging mails.
@@ -806,11 +716,11 @@ typedef enum
EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_START, /**< Task started */
EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_FINISH, /**< Task finished */
EMAIL_EXPUNGE_MAILS_DELETED_FLAGGED_FAIL, /**< Task failed */
-}email_expunge_mails_deleted_flagged_status_e;
+} email_expunge_mails_deleted_flagged_status_e;
/**
* @brief Enumeration for the status of searching mails on server.
-* @since_tizen 2.3
+* @since_tizen 2.4
*/
typedef enum
{
@@ -819,7 +729,7 @@ typedef enum
EMAIL_SEARCH_ON_SERVER_START, /**< Task started */
EMAIL_SEARCH_ON_SERVER_FINISH, /**< Task finished */
EMAIL_SEARCH_ON_SERVER_FAIL, /**< Task failed */
-}email_search_on_server_status_e;
+} email_search_on_server_status_e;
/**
* @brief Enumeration for the status of moving mails.
@@ -832,7 +742,7 @@ typedef enum
EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_START, /**< Task started */
EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_FINISH, /**< Task finished */
EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_FAIL, /**< Task failed */
-}email_move_mailbox_status_e;
+} email_move_mailbox_status_e;
/**
* @brief Enumeration for the status of updating mails.
@@ -845,7 +755,7 @@ typedef enum
EMAIL_UPDATE_MAIL_START, /**< Task started */
EMAIL_UPDATE_MAIL_FINISH, /**< Task finished */
EMAIL_UPDATE_MAIL_FAIL, /**< Task failed */
-}email_update_mail_status_e;
+} email_update_mail_status_e;
/**
* @brief Enumeration for the mailbox type.
@@ -864,7 +774,7 @@ typedef enum
EMAIL_MAILBOX_TYPE_SEARCH_RESULT = 8, /**< Specified mailbox type for result of search on server */
EMAIL_MAILBOX_TYPE_FLAGGED = 9, /**< Specified flagged mailbox type on gmail */
EMAIL_MAILBOX_TYPE_USER_DEFINED = 0xFF, /**< Specified mailbox type for all other mailboxes */
-}email_mailbox_type_e;
+} email_mailbox_type_e;
/** @brief Enumeration for the sync order.
@@ -1202,6 +1112,8 @@ typedef enum {
EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, /* string type */ /**< Messages with specified message ID */
EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, /* integer type */ /**< Messages that have a header with the specified priority */
EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME = 60, /* string type */ /**< Messages that contain the specified string in attachment name */
+ EMAIL_SEARCH_FILTER_TYPE_CHARSET = 61, /* string type */ /**< Messages of encoded type */
+ EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED = 62, /* string type */ /**< Messages that extend and user defined string */
} email_search_filter_type;
typedef enum {
@@ -1500,6 +1412,7 @@ typedef struct
char *certificate_path; /**< The certificate path of private */
email_cipher_type cipher_type; /**< The encryption algorithm */
email_digest_type digest_type; /**< The digest algorithm */
+ char *user_name; /**< The user name for multi user (Since 2.4) */
} email_account_t;
/**
@@ -1611,6 +1524,9 @@ typedef struct
time_t replied_time; /**< The time of replied */
time_t forwarded_time; /**< The time of forwarded */
char *pgp_password; /**< The password of PGP. */
+ char *user_name; /**< The user information for multi user (Since 2.4) */
+ char *key_list; /**< The key list encryption of mail (Since 2.4) */
+ char *key_id; /**< The key ID for signing of pgp mail (Since 2.4) */
int eas_data_length; /**< The length of eas_data */
void *eas_data; /**< Extended Application Specific data */
} email_mail_data_t;
@@ -2021,18 +1937,21 @@ typedef union
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for sending the mail */
int mail_id; /**< The mail ID for sending the mail */
- } send_mail; /**< Noti data for sending the mail */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
+ } send_mail; /**< Noti data for sending the mail */
struct _send_mail_saved
{/* not defined ye */
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for sending the saved mail */
- } send_mail_saved; /**< Noti data for sending the saved mail */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
+ } send_mail_saved; /**< Noti data for sending the saved mail */
struct _send_report
{/* not defined ye */
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for sending the report */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} send_report; /**< Noti data for sending the report */
struct _sync_header
@@ -2040,6 +1959,7 @@ typedef union
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for syncing the header */
int mailbox_id; /**< The mailbox ID for syncing the header */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} sync_header; /**< Noti data for syncing the header */
struct _download_body
@@ -2048,6 +1968,7 @@ typedef union
int account_id; /**< The account ID for downloading the body */
int mail_id; /**< The mail ID for downloading the body */
int with_attachment; /**< 0: without attachments, 1: with attachment */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} download_body; /**< Noti data for downloading the body */
struct _download_attachment
@@ -2056,6 +1977,7 @@ typedef union
int account_id; /**< The account ID for downloading the attachment */
int mail_id; /**< The mail ID for downloading the attachment */
int attachment_order; /**< The ordered attachment for downloading the attachment */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} download_attachment; /**< Noti data for downloading the attachment */
struct _cancel_job
@@ -2063,12 +1985,14 @@ typedef union
int account_id; /**< The account ID for canceling the job */
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int cancel_type; /**< The canceling type for canceling the job */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} cancel_job; /**< Noti data for canceling the job */
struct _validate_account
{/* not defined yet */
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for validating the account */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} validate_account; /**< Noti data for validating the account */
struct _search_mail_on_server
@@ -2078,12 +2002,14 @@ typedef union
int mailbox_id; /**< The mailbox ID for searching the mail on server */
email_search_filter_t *search_filter_list; /**< The list of search filter for searching the mail on server */
int search_filter_count; /**< The count of search filter for searching the mail on server */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} search_mail_on_server; /**< Noti data for searching the mail on server */
struct _clear_result_of_search_mail_on_server
{
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for clearing the result of search mail on server */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} clear_result_of_search_mail_on_server; /**< Noti data for clearing the result of search mail on server */
struct _expunge_mails_deleted_flagged
@@ -2092,6 +2018,7 @@ typedef union
int account_id; /**< The account ID for expunging the mails flagged for deleting */
int mailbox_id; /**< The mailbox ID for expunging the mails flagged for deleting */
int on_server; /**< The flag indicating whether the mail is on server for expunging the mails flagged for deleting */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} expunge_mails_deleted_flagged; /**< Noti data for expunging the mails flagged for deleting */
struct _get_resolve_recipients
@@ -2099,6 +2026,7 @@ typedef union
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for getting the resolve recipients */
char *email_address; /**< The email address for getting the resolve recipients */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} get_resolve_recipients; /**< Noti data for getting the resolve recipients */
struct _validate_certificate
@@ -2106,6 +2034,7 @@ typedef union
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for validating the certificate */
char *email_address; /**< The email address for validating the certifiate */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} validate_certificate; /**< Noti data for validating the certificate */
struct _add_mailbox
@@ -2116,6 +2045,7 @@ typedef union
char *mailbox_alias; /**< The alias of mailbox for adding the mailbox */
void *eas_data; /**< The eas-data for adding the mailbox */
int eas_data_length; /**< The length of eas-data for adding the mailbox */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} add_mailbox; /**< Noti data for adding the mailbox */
struct _rename_mailbox
@@ -2127,6 +2057,7 @@ typedef union
char *mailbox_alias; /**< The alias of mailbox for renaming the mailbox */
void *eas_data; /**< The eas-data for renaming the mailbox */
int eas_data_length; /**< The length of eas-data for renaming the mailbox */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} rename_mailbox; /**< Noti data for renaming the mailbox */
struct _delete_mailbox
@@ -2134,6 +2065,7 @@ typedef union
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for deleting mailbox */
int mailbox_id; /**< The mailbox ID for deleting mailbox */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} delete_mailbox; /**< Noti data for deleting mailbox */
struct _cancel_sending_mail
@@ -2141,6 +2073,7 @@ typedef union
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for canceled sending mail */
int mail_id; /**< The mail ID for canceled sending mail */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} cancel_sending_mail; /**< Noti data for canceled sending mail */
struct _delete_mailbox_ex
@@ -2150,6 +2083,7 @@ typedef union
int *mailbox_id_array; /**< The mailbox ID array for deleting mailbox (extention) */
int mailbox_id_count; /**< The mailbox ID count for deleting mailbox (extention) */
int on_server; /**< The on server for deleting mailbox (extention) */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} delete_mailbox_ex; /**< Noti data for deleting mailbox (extention) */
struct _send_mail_with_downloading_attachment_of_original_mail
@@ -2157,6 +2091,7 @@ typedef union
int handle; /**< The job handle to be canceled. This value is issued by email-service. */
int account_id; /**< The account ID for downloading attachment */
int mail_id; /**< The mail ID for download attachment */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} send_mail_with_downloading_attachment_of_original_mail; /**< Noti data for send mail with downloading attachment of original mail */
struct _schedule_sending_mail
@@ -2165,6 +2100,7 @@ typedef union
int account_id; /**< The account ID for scheduled sending mail */
int mail_id; /**< The mail ID for scheduled sending mail */
time_t scheduled_time; /**< The scheduled time for scheduled sending mail */
+ char *multi_user_name; /**< Speicifes the supporting for multi user (Since 2.4) */
} schedule_sending_mail; /**< Noti data for schedule sending mail */
} ASNotiData;
diff --git a/email-common-use/include/email-utilities.h b/email-common-use/include/email-utilities.h
index 8df22af..7d7be90 100755
--- a/email-common-use/include/email-utilities.h
+++ b/email-common-use/include/email-utilities.h
@@ -68,11 +68,11 @@ INTERNAL_FUNC int em_decode_base64(unsigned char *enc_text, unsigned long enc_
extern char* strcasestr(__const char *__haystack, __const char *__needle) __THROW __attribute_pure__ __nonnull ((1, 2));
-INTERNAL_FUNC int em_get_account_server_type_by_account_id(int account_id, email_account_server_t* account_server_type, int flag, int *error);
+INTERNAL_FUNC int em_get_account_server_type_by_account_id(char *multi_user_name, int account_id, email_account_server_t* account_server_type, int flag, int *error);
INTERNAL_FUNC int em_get_handle_for_activesync(int *handle, int *error);
-INTERNAL_FUNC int em_check_socket_privilege_by_pid(int pid);
-INTERNAL_FUNC int em_check_db_privilege_by_pid(int pid);
+INTERNAL_FUNC int em_check_socket_privilege_by_pid(long pid);
+INTERNAL_FUNC int em_check_db_privilege_by_pid(long pid);
/* thread handle definition */
typedef struct {
diff --git a/email-core/CMakeLists.txt b/email-core/CMakeLists.txt
index ab63631..c2aa3a8 100755
--- a/email-core/CMakeLists.txt
+++ b/email-core/CMakeLists.txt
@@ -29,7 +29,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/email-core/email-device/include
)
-
INCLUDE(FindPkgConfig)
pkg_check_modules(device_pkgs REQUIRED glib-2.0 dlog vconf capi-system-device dbus-1)
@@ -132,6 +131,39 @@ SET_TARGET_PROPERTIES(${NETWORK-LIB} PROPERTIES VERSION ${VERSION})
INSTALL(TARGETS ${NETWORK-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
##########################################################
+# Define container lib
+##########################################################
+
+SET(CONTAINER-LIB "email-container")
+SET(CONTAINER-SRCS
+ ${CMAKE_SOURCE_DIR}/email-core/email-core-container.c
+)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/email-common-use/include
+)
+
+INCLUDE(FindPkgConfig)
+SET(PKG_MODULES glib-2.0 vasum)
+
+pkg_check_modules(container_pkgs REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${container_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${CONTAINER-LIB} SHARED ${CONTAINER-SRCS})
+TARGET_LINK_LIBRARIES(${CONTAINER-LIB} ${container_pkgs_LDFLAGS} dl)
+SET_TARGET_PROPERTIES(${CONTAINER-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${CONTAINER-LIB} PROPERTIES VERSION ${VERSION})
+
+INSTALL(TARGETS ${CONTAINER-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
+
+##########################################################
# Define Core lib
##########################################################
@@ -169,11 +201,13 @@ INCLUDE_DIRECTORIES(
INCLUDE(FindPkgConfig)
-pkg_check_modules(core_pkgs REQUIRED glib-2.0 dlog dbus-1 gthread-2.0
+SET(PKG_MODULES glib-2.0 dlog dbus-1 gthread-2.0
uw-imap-toolkit vconf vconf-internal-keys contacts-service2 secure-storage
- openssl accounts-svc alarm-service notification libcurl libxml-2.0 feedback
+ openssl accounts-svc alarm-service notification libcurl libxml-2.0
cert-svc cert-svc-vcore badge capi-appfw-application icu-i18n gmime-2.6 storage)
+pkg_check_modules(core_pkgs REQUIRED ${PKG_MODULES})
+
set(EXTRA_CFLAGS "")
FOREACH(flag ${core_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -208,7 +242,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
ADD_LIBRARY(${CORE-LIB} SHARED ${CORE-SRCS})
-TARGET_LINK_LIBRARIES(${CORE-LIB} ${core_pkgs_LDFLAGS} ${STORAGE-LIB} ${NETWORK-LIB} ${DEVICE-LIB})
+TARGET_LINK_LIBRARIES(${CORE-LIB} ${core_pkgs_LDFLAGS} ${STORAGE-LIB} ${NETWORK-LIB} ${DEVICE-LIB} ${CONTAINER-LIB})
SET_TARGET_PROPERTIES(${CORE-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${CORE-LIB} PROPERTIES VERSION ${VERSION})
diff --git a/email-core/email-core-account.c b/email-core/email-core-account.c
index 27c4d2b..0a42f25 100755
--- a/email-core/email-core-account.c
+++ b/email-core/email-core-account.c
@@ -53,6 +53,7 @@
#include "email-core-mailbox.h"
#include "email-core-signal.h"
#include "email-core-imap-mailbox.h"
+#include "email-core-container.h"
#include "imap4r1.h"
@@ -89,57 +90,86 @@ email_mailbox_type_e g_default_mbox_type[MAILBOX_COUNT] =
EMAIL_MAILBOX_TYPE_SPAMBOX,
};
-static email_account_list_t *g_account_list = NULL;
-static int g_account_num = 0;
-static pthread_mutex_t _account_ref_lock = PTHREAD_MUTEX_INITIALIZER;
-
-INTERNAL_FUNC email_account_t* emcore_get_account_reference(int account_id)
+INTERNAL_FUNC email_account_t* emcore_get_account_reference(char *multi_user_name, int account_id, int with_password)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
- email_account_list_t **p;
- email_account_t *result_account = NULL;
-
- if (account_id < 0){
- emcore_get_account_from_unvalidated_account_list(account_id, &result_account);
- return result_account;
- }
- else if (account_id > 0) {
- ENTER_CRITICAL_SECTION(_account_ref_lock);
- p = &g_account_list;
- while (*p) {
- if ((*p)->account->account_id == account_id) {
- emcore_duplicate_account((*p)->account, &result_account, NULL);
- break;
+ int err = EMAIL_ERROR_NONE;
+ email_account_t *result_account = NULL;
+ emstorage_account_tbl_t *p_result_account = NULL;
+
+ if (account_id < 0){
+ emcore_get_account_from_unvalidated_account_list(account_id, &result_account);
+ return result_account;
+ } else if (account_id > 0) {
+ if (with_password) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, EMAIL_ACC_GET_OPT_FULL_DATA, &p_result_account, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed : [%d]", err);
+ return NULL;
+ }
+ } else {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &p_result_account, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed : [%d]", err);
+ return NULL;
+ }
}
- p = &(*p)->next;
- }
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
-
- if (result_account)
- goto FINISH_OFF;
- /* refresh and check once again */
- EM_DEBUG_LOG ("init_account_id [%d]", account_id);
- emcore_init_account_reference();
- ENTER_CRITICAL_SECTION(_account_ref_lock);
- if (g_account_num > 0 && g_account_list) {
- p = &g_account_list;
- while (*p) {
- if ((*p)->account->account_id == account_id) {
- emcore_duplicate_account((*p)->account, &result_account, NULL);
- break;
- }
- p = &(*p)->next;
+ result_account = (email_account_t *)em_malloc(sizeof(email_account_t));
+ if (result_account == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ return NULL;
}
- }
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
- }
-FINISH_OFF:
+ em_convert_account_tbl_to_account(p_result_account, result_account);
+
+ emstorage_free_account(&p_result_account, 1, NULL);
+ }
+
EM_DEBUG_FUNC_END("[%p]", result_account);
return result_account;
}
+INTERNAL_FUNC int emcore_get_account_reference_list(char *multi_user_name, email_account_t **output_account_list, int *output_count)
+{
+ EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%p]", output_account_list, output_count);
+ int err = EMAIL_ERROR_NONE;
+ int i = 0;
+ int account_count = 0;
+ email_account_t *account_list = NULL;
+ emstorage_account_tbl_t *account_list_tbl = NULL;
+
+ if (!emstorage_get_account_list(multi_user_name, &account_count, &account_list_tbl, false, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_list failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (account_count > 0) {
+ account_list = em_malloc(sizeof(email_account_t) * (account_count));
+ if (account_list == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ }
+
+ for (i = 0; i < account_count; i++) {
+ em_convert_account_tbl_to_account(&account_list_tbl[i], &account_list[i]);
+ }
+
+FINISH_OFF:
+
+ if (account_list_tbl)
+ emstorage_free_account(&account_list_tbl, account_count, NULL);
+
+ if (output_account_list)
+ *output_account_list = account_list;
+
+ if (output_count)
+ *output_count = account_count;
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
static char *emcore_get_imap_capability_string(MAILSTREAM *input_stream)
{
EM_DEBUG_FUNC_BEGIN_SEC("input_stream[%p]", input_stream);
@@ -165,7 +195,7 @@ static char *emcore_get_imap_capability_string(MAILSTREAM *input_stream)
return result_string;
}
-INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *account, email_event_type_t event_type, char **output_server_capability_string, int event_handle, int *err_code)
+INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_name, email_account_t *account, email_event_type_t event_type, char **output_server_capability_string, int event_handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account[%p] output_server_capability_string[%p] err_code[%p] incoming_server_address [%s]", account, output_server_capability_string, err_code, account->incoming_server_address);
@@ -199,7 +229,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *acc
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
- if (!emcore_connect_to_remote_mailbox_with_account_info(account, 0, (void **)&tmp_stream, &err) || !tmp_stream) {
+ if (!emcore_connect_to_remote_mailbox_with_account_info(multi_user_name, account, 0, (void **)&tmp_stream, &err) || !tmp_stream) {
EM_DEBUG_LOG("emcore_connect_to_remote_mailbox failed [%d]", err);
if (EMAIL_ERROR_AUTHENTICATE == err || EMAIL_ERROR_LOGIN_FAILURE == err) { /* wrong password or etc */
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed : Login or Authentication failed - %d", err);
@@ -218,7 +248,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *acc
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
- if (!emcore_connect_to_remote_mailbox_with_account_info(account, EMAIL_CONNECT_FOR_SENDING, (void **)&stream, &err) || !stream) {
+ if (!emcore_connect_to_remote_mailbox_with_account_info(multi_user_name, account, EMAIL_CONNECT_FOR_SENDING, (void **)&stream, &err) || !stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
err = EMAIL_ERROR_VALIDATE_ACCOUNT_OF_SMTP;
goto FINISH_OFF;
@@ -230,7 +260,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *acc
EM_DEBUG_LOG("Retry with TLS");
account->outgoing_server_secure_connection = 0x02; /* 0x02 == TLS */
- if (!emcore_connect_to_remote_mailbox_with_account_info(account, EMAIL_CONNECT_FOR_SENDING, (void **)&stream, &err) || !stream) {
+ if (!emcore_connect_to_remote_mailbox_with_account_info(multi_user_name, account, EMAIL_CONNECT_FOR_SENDING, (void **)&stream, &err) || !stream) {
EM_DEBUG_LOG("emcore_connect_to_remote_mailbox failed [%d]", err);
err = EMAIL_ERROR_VALIDATE_ACCOUNT_OF_SMTP;
account->outgoing_server_secure_connection = 0x01; /* restore to the previous value */
@@ -258,7 +288,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *acc
if (!emcore_check_event_thread_status(&dummy, event_handle)) {
EM_DEBUG_LOG ("canceled event: [%d]", dummy);
if (event_type == EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT || event_type == EMAIL_EVENT_VALIDATE_ACCOUNT_EX) {
- if (!emcore_delete_account(account->account_id, false, NULL))
+ if (!emcore_delete_account(multi_user_name, account->account_id, false, NULL))
EM_DEBUG_EXCEPTION("emdaemon_delete_account failed [%d]", account->account_id);
}
err = EMAIL_ERROR_CANCELLED;
@@ -303,7 +333,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_validate_account(int account_id, int handle, int *err_code)
+INTERNAL_FUNC int emcore_validate_account(char *multi_user_name, int account_id, int handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], err_code[%p]", account_id, err_code);
@@ -317,9 +347,9 @@ INTERNAL_FUNC int emcore_validate_account(int account_id, int handle, int *err_c
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
- if (ref_account && emcore_validate_account_with_account_info(ref_account, EMAIL_EVENT_VALIDATE_ACCOUNT, NULL, handle, &err) == false) {
+ if (ref_account && emcore_validate_account_with_account_info(multi_user_name, ref_account, EMAIL_EVENT_VALIDATE_ACCOUNT, NULL, handle, &err) == false) {
EM_DEBUG_EXCEPTION("emcore_validate_account_with_account_info failed (%d)", err);
goto FINISH_OFF;
}
@@ -343,7 +373,7 @@ FINISH_OFF:
key_t del_account_key = 4511; /* name of the segment d/4 e/5 l/11 */
-INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_account_svc, int *err_code)
+INTERNAL_FUNC int emcore_delete_account(char *multi_user_name, int account_id, int input_delete_from_account_svc, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], err_code[%p]", account_id, err_code);
@@ -380,11 +410,10 @@ INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_ac
#ifdef __FEATURE_LOCAL_ACTIVITY__
/* Delete all local activities of previous account */
-
-
emstorage_activity_tbl_t activity;
memset(&activity, 0x00, sizeof(emstorage_activity_tbl_t));
activity.account_id = account_id;
+ activity.multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_delete_activity(&activity, &err)) {
EM_DEBUG_LOG("\t emcore_delete_activity failed - %d", err);
@@ -397,7 +426,7 @@ INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_ac
if (false == emcore_clear_partial_body_thd_event_que(&err))
EM_DEBUG_EXCEPTION(" emcore_clear_partial_body_thd_event_que [%d]", err);
- if (false == emstorage_delete_full_pbd_activity_data(account_id, true, &err))
+ if (false == emstorage_delete_full_pbd_activity_data(multi_user_name, account_id, true, &err))
EM_DEBUG_EXCEPTION("emstorage_delete_full_pbd_activity_data failed [%d]", err);
#endif
@@ -406,23 +435,35 @@ INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_ac
if (!emcore_clear_auto_download_queue())
EM_DEBUG_EXCEPTION("emcore_clear_auto_download_queue failed");
- if (!emstorage_delete_all_auto_download_activity(account_id, true, &err))
+ if (!emstorage_delete_all_auto_download_activity(multi_user_name, account_id, true, &err))
EM_DEBUG_EXCEPTION("emstorage_delete_all_auto_download_activity failed [%d]", err);
#endif
if (input_delete_from_account_svc == true) {
- int error_code_from_account_svc;
+ int error_code_from_account_svc = 0;
email_account_t *account_to_be_deleted;
+ void *join_zone = NULL;
- account_to_be_deleted = emcore_get_account_reference(account_id);
+ account_to_be_deleted = emcore_get_account_reference(multi_user_name, account_id, false);
if (account_to_be_deleted && account_to_be_deleted->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
EM_DEBUG_LOG("Calling account_svc_delete with account_svc_id[%d]", account_to_be_deleted->account_svc_id);
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+
error_code_from_account_svc = account_connect();
+
EM_DEBUG_LOG("account_connect returns [%d]", error_code_from_account_svc);
error_code_from_account_svc = account_delete_from_db_by_id(account_to_be_deleted->account_svc_id);
EM_DEBUG_LOG("account_delete_from_db_by_id returns [%d]", error_code_from_account_svc);
error_code_from_account_svc = account_disconnect();
EM_DEBUG_LOG("account_disconnect returns [%d]", error_code_from_account_svc);
+
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
}
if (account_to_be_deleted) {
@@ -431,7 +472,7 @@ INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_ac
}
}
- if (emcore_cancel_all_threads_of_an_account(account_id) < EMAIL_ERROR_NONE) {
+ if (emcore_cancel_all_threads_of_an_account(multi_user_name, account_id) < EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("There are some remaining jobs. I couldn't stop them.");
err = EMAIL_ERROR_CANNOT_STOP_THREAD;
before_tr_begin = 1;
@@ -439,18 +480,18 @@ INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_ac
}
/* Delete contact log */
- if ( ((err = emcore_delete_contacts_log(account_id)) != EMAIL_ERROR_NONE) && (err != EMAIL_ERROR_DATA_NOT_FOUND) ) {
- EM_DEBUG_EXCEPTION("emcore_delete_contacts_log failed : [%d]", err);
+ if (((err = emcore_delete_contacts_log(multi_user_name, account_id)) != EMAIL_ERROR_NONE) && (err != EMAIL_ERROR_DATA_NOT_FOUND)) {
+ EM_DEBUG_EXCEPTION("emcore_delete_contacts_log failed : [%d]", err);
}
/* BEGIN TRANSACTION; */
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
}
- if (!emstorage_delete_account(account_id, false, &err)) {
+ if (!emstorage_delete_account(multi_user_name, account_id, false, &err)) {
if(err != EMAIL_ERROR_SYSTEM_FAILURE) {
EM_DEBUG_EXCEPTION("emstorage_delete_account failed [%d]", err);
goto FINISH_OFF;
@@ -461,14 +502,14 @@ INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_ac
/* emcore_reset_streams(); */
emcore_remove_connection_info(account_id);
#endif
-
- if ((err = emcore_delete_all_mails_of_acount(account_id)) != EMAIL_ERROR_NONE) {
+
+ if ((err = emcore_delete_all_mails_of_acount(multi_user_name, account_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_acount failed [%d]", err);
goto FINISH_OFF;
}
/* delete all mailboxes */
- if (!emstorage_delete_mailbox(account_id, -1, 0, false, &err)) {
+ if (!emstorage_delete_mailbox(multi_user_name, account_id, -1, 0, false, &err)) {
if(err != EMAIL_ERROR_MAILBOX_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emstorage_delete_mailbox failed - %d", err);
goto FINISH_OFF;
@@ -476,19 +517,19 @@ INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_ac
}
/* delete local imap sync mailbox from imap mailbox table */
- if (!emstorage_remove_downloaded_mail(account_id, NULL, NULL, false, &err)) {
+ if (!emstorage_remove_downloaded_mail(multi_user_name, account_id, NULL, NULL, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_remove_downloaded_mail failed - %d", err);
goto FINISH_OFF;
}
- emcore_display_unread_in_badge(NULL);
- emcore_delete_notification_by_account(account_id, true);
+ emcore_display_unread_in_badge(multi_user_name);
+ emcore_delete_notification_by_account(multi_user_name, account_id, true);
ret = true;
FINISH_OFF:
if (ret == true) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
ret = false;
}
@@ -497,14 +538,12 @@ FINISH_OFF:
}
else { /* ROLLBACK TRANSACTION; */
- if (!before_tr_begin && emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (!before_tr_begin && emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
if (!emcore_notify_storage_event (NOTI_ACCOUNT_DELETE_FAIL, account_id, err, NULL, 0))
EM_DEBUG_EXCEPTION (" emcore_notify_storage_event[ NOTI_ACCOUNT_DELETE] : Notification Failed >>> ");
}
- emcore_init_account_reference();
-
if (err_code)
*err_code = err;
@@ -518,7 +557,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_account_to_account_svc, int *err_code)
+INTERNAL_FUNC int emcore_create_account(char *multi_user_name, email_account_t *account, int add_account_to_account_svc, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account[%p] add_account_to_account_svc [%d] err_code[%p]", account, add_account_to_account_svc, err_code);
@@ -536,7 +575,7 @@ INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_accoun
goto FINISH_OFF;
}
- if (!emstorage_get_account_count(&count, true, &err)) {
+ if (!emstorage_get_account_count(multi_user_name, &count, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_count failed - %d", err);
goto FINISH_OFF;
}
@@ -573,12 +612,22 @@ INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_accoun
if (add_account_to_account_svc) {
if (account->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
int account_svc_id = 0;
- int error_code;
+ int error_code = 0;
account_h account_handle = NULL;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_set_join_zone(multi_user_name, &join_zone);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
error_code = account_connect();
if(error_code != ACCOUNT_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("account_connect failed [%d]", error_code);
+ if (join_zone) emcore_unset_join_zone(join_zone);
+ EM_DEBUG_EXCEPTION("account_connect_to_container failed [%d]", error_code);
err = error_code;
goto FINISH_OFF;
}
@@ -588,6 +637,7 @@ INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_accoun
EM_DEBUG_EXCEPTION("account_create failed [%d]", error_code);
err = error_code;
account_disconnect();
+ if (join_zone) emcore_unset_join_zone(join_zone);
goto FINISH_OFF;
}
@@ -647,6 +697,7 @@ INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_accoun
account_destroy(account_handle);
account_disconnect();
+ if (join_zone) emcore_unset_join_zone(join_zone);
}
}
@@ -658,7 +709,7 @@ INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_accoun
em_convert_account_to_account_tbl(account, temp_account_tbl);
- if (!emstorage_add_account(temp_account_tbl, true, &err)) {
+ if (!emstorage_add_account(multi_user_name, temp_account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_account failed - %d", err);
goto FINISH_OFF;
}
@@ -672,7 +723,7 @@ INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_accoun
local_mailbox.account_id = temp_account_tbl->account_id;
local_mailbox.mailbox_name = EM_SAFE_STRDUP(g_default_mbox_name[i]);
local_mailbox.alias = EM_SAFE_STRDUP(g_default_mbox_alias[i]);
- local_mailbox.mailbox_type = g_default_mbox_type[i];
+ local_mailbox.mailbox_type = g_default_mbox_type[i];
local_mailbox.mail_slot_size = temp_account_tbl->default_mail_slot_size;
local_mailbox.eas_data = NULL;
local_mailbox.eas_data_length = 0;
@@ -682,7 +733,7 @@ INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_accoun
else
local_mailbox.local = EMAIL_MAILBOX_FROM_LOCAL;
- if (!emcore_create_mailbox(&local_mailbox, 0, account->incoming_server_type, account->default_mail_slot_size, &err)) {
+ if (!emcore_create_mailbox(multi_user_name, &local_mailbox, 0, account->incoming_server_type, account->default_mail_slot_size, &err)) {
EM_DEBUG_EXCEPTION("emcore_create failed [%d]", err);
emcore_free_mailbox(&local_mailbox);
goto FINISH_OFF;
@@ -709,7 +760,7 @@ FINISH_OFF:
emstorage_free_account(&temp_account_tbl, 1, NULL);
if (ret == false && account != NULL) {
- if (!emcore_delete_account(account->account_id, false, NULL))
+ if (!emcore_delete_account(multi_user_name, account->account_id, false, NULL))
EM_DEBUG_EXCEPTION("emdaemon_delete_account Failed [%d]", account->account_id);
}
@@ -720,179 +771,6 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emcore_init_account_reference()
-{
-// static int num_call = 0;
-// EM_DEBUG_LOG("num_call [%d]", num_call++);
-
- int err = EMAIL_ERROR_NONE;
-
- email_account_list_t *account_list = NULL;
- email_account_list_t **p = NULL;
- email_account_t *account = NULL;
- emstorage_account_tbl_t *account_tbl_array = NULL;
- int count = 0;
- int i = 0;
-
- /* free account reference if any */
- emcore_free_account_reference();
-
- if (!emstorage_get_account_list(&count, &account_tbl_array, true, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
- goto FINISH_OFF;
- }
-
- for (p = &account_list, i = 0; i < count; i++) {
- account = em_malloc(sizeof(email_account_t));
- if (!account) {
- EM_DEBUG_EXCEPTION("malloc failed...");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- em_convert_account_tbl_to_account(account_tbl_array + i, account);
-
- *p = (email_account_list_t*) em_malloc(sizeof(email_account_list_t));
- if (!(*p)) {
- EM_DEBUG_EXCEPTION("malloc failed...");
- emcore_free_account(account);
- EM_SAFE_FREE(account);
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- (*p)->account = account;
-
- p = &(*p)->next;
- }
-
- ENTER_CRITICAL_SECTION(_account_ref_lock);
- g_account_num = count;
- g_account_list = account_list;
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
-
-FINISH_OFF:
- if (account_tbl_array)
- emstorage_free_account(&account_tbl_array, count, NULL);
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_add_account_reference(email_account_t *account)
-{
- EM_DEBUG_FUNC_BEGIN();
-
- email_account_list_t *account_iter = NULL;
- email_account_list_t **p = NULL;
- email_account_t *dup_account = NULL;
- int account_count = 0;
-
- if (account == NULL) {
- EM_DEBUG_EXCEPTION("account [%p]", account);
- return false;
- }
-
- emcore_duplicate_account(account, &dup_account, NULL);
-
- if (dup_account == NULL) {
- EM_DEBUG_EXCEPTION("dup_account [%p]", dup_account);
- return false;
- }
-
- ENTER_CRITICAL_SECTION(_account_ref_lock);
- account_iter = g_account_list;
-
- p = &g_account_list;
- while (*p) {
- if ((*p)->account->account_id == account->account_id) {
- EM_DEBUG_LOG("already added to g_account_list");
- emcore_free_account(dup_account);
- EM_SAFE_FREE(dup_account);
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
- return false;
- }
- p = &(*p)->next;
- }
-
- if (account_iter == NULL) {
- email_account_list_t *new_item = (email_account_list_t*) em_malloc(sizeof(email_account_list_t));
- if (!new_item) {
- EM_DEBUG_EXCEPTION("malloc failed...");
- emcore_free_account(dup_account);
- EM_SAFE_FREE(dup_account);
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
- return false;
- }
-
- new_item->account = dup_account;
- new_item->next = NULL;
-
- g_account_list = new_item;
- EM_DEBUG_LOG("added 1 th item to g_account_list");
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
- return true;
- }
-
- while(account_iter) {
- if (account_iter->account)
- account_count++;
-
- EM_DEBUG_LOG_DEV("account count[%d]", account_count);
-
- if (account_iter->next == NULL) {
- email_account_list_t *new_item = (email_account_list_t*) em_malloc(sizeof(email_account_list_t));
- if (!new_item) {
- EM_DEBUG_EXCEPTION("malloc failed...");
- emcore_free_account(dup_account);
- EM_SAFE_FREE(dup_account);
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
- return false;
- }
-
- new_item->account = dup_account;
- new_item->next = NULL;
-
- account_iter->next = new_item;
- EM_DEBUG_LOG("added %d th item to g_account_list", account_count+1);
- break;
- }
- else {
- account_iter = account_iter->next;
- }
- }
-
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
-
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-INTERNAL_FUNC int emcore_free_account_reference()
-{
- EM_DEBUG_FUNC_BEGIN();
- ENTER_CRITICAL_SECTION(_account_ref_lock);
-
- email_account_list_t *p = g_account_list;
- email_account_list_t *p_next = NULL;
- while (p) {
- emcore_free_account(p->account);
- EM_SAFE_FREE(p->account);
-
- p_next = p->next;
- EM_SAFE_FREE(p);
- p = p_next;
- }
-
- g_account_num = 0;
- g_account_list = NULL;
-
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
- EM_DEBUG_FUNC_END();
- return true;
-}
-
INTERNAL_FUNC int emcore_free_account_list(email_account_t **account_list, int count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%d], err_code[%p]", account_list, count, err_code);
@@ -1003,67 +881,6 @@ INTERNAL_FUNC void emcore_duplicate_account(const email_account_t *account, emai
EM_DEBUG_FUNC_END();
}
-INTERNAL_FUNC int emcore_get_account_reference_list(email_account_t **account_list, int *count, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%p], err_code[%p]", account_list, count, err_code);
- int i, countOfAccounts = 0;
- int ret = false;
- int err = EMAIL_ERROR_NONE;
- email_account_t *accountRef;
- email_account_list_t *p;
-
- ENTER_CRITICAL_SECTION(_account_ref_lock);
-
- if (!account_list || !count) {
- EM_DEBUG_EXCEPTION("account_list[%p], count[%p]", account_list, count);
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- p = g_account_list;
-
- while (p) {
- countOfAccounts++;
- p = p->next;
- }
-
- EM_DEBUG_LOG("Result count[%d]", countOfAccounts);
- *count = countOfAccounts;
-
- if (countOfAccounts > 0) {
- *account_list = em_malloc(sizeof(email_account_t) * countOfAccounts);
- if (!*account_list) {
- EM_DEBUG_LOG("malloc failed...");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- }
-
- p = g_account_list;
- for (i = 0; i < countOfAccounts; i++) {
- accountRef = (*account_list) + i;
- emcore_free_account(accountRef);
- emcore_duplicate_account_members(p->account, accountRef);
- EM_DEBUG_LOG_SEC("Result account id[%d], name[%s]", accountRef->account_id, accountRef->account_name);
- p = p->next;
- }
-
- ret = true;
-
-FINISH_OFF:
- if (ret == false) {
- if (account_list && *account_list)
- EM_SAFE_FREE(*account_list);
- }
-
- LEAVE_CRITICAL_SECTION(_account_ref_lock);
-
- if (err_code != NULL)
- *err_code = err;
- EM_DEBUG_FUNC_END();
- return ret;
-}
-
#ifdef __FEATURE_BACKUP_ACCOUNT__
#include <ss_manager.h>
@@ -1152,7 +969,7 @@ FINISH_OFF:
return ret_code;
}
-INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code)
+INTERNAL_FUNC int emcore_backup_accounts(char *multi_user_name, const char *file_path, int *error_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("file_path [%s], error_code [%p]", file_path, error_code);
int local_error_code = EMAIL_ERROR_NONE, local_error_code_2 = EMAIL_ERROR_NONE, ret_code = false;
@@ -1170,7 +987,7 @@ INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code)
select_num = 1000;
- if (!emstorage_get_account_list(&select_num, &account_list, true, true, &local_error_code)) {
+ if (!emstorage_get_account_list(multi_user_name, &select_num, &account_list, true, true, &local_error_code)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", local_error_code);
goto FINISH_OFF;
}
@@ -1215,6 +1032,7 @@ INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code)
int data_length = 0;
char *encrypted_data_block = NULL;
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
local_error_code = em_open(file_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR, &fd);
if (local_error_code != EMAIL_ERROR_NONE) {
@@ -1230,7 +1048,7 @@ INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code)
}
if (write(fd, encrypted_data_block, data_length) != data_length) {
- EM_DEBUG_EXCEPTION("write failed : [%s]", strerror(errno));
+ EM_DEBUG_EXCEPTION("write failed : [%d][%s]", errno, EM_STRERROR(errno_buf));
local_error_code = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -1252,7 +1070,7 @@ FINISH_OFF:
return ret_code;
}
-INTERNAL_FUNC int emcore_restore_accounts(const char *file_path)
+INTERNAL_FUNC int emcore_restore_accounts(char *multi_user_name, const char *file_path)
{
EM_DEBUG_FUNC_BEGIN_SEC("file_path [%s]", file_path);
int err = EMAIL_ERROR_NONE, buffer_length = 0, read_length = 0;
@@ -1272,10 +1090,10 @@ INTERNAL_FUNC int emcore_restore_accounts(const char *file_path)
goto FINISH_OFF;
}
- if (emcore_get_account_reference_list(&account_list, &account_count, &err)) {
+ if ((err = emcore_get_account_reference_list(multi_user_name, &account_list, &account_count)) == EMAIL_ERROR_NONE) {
for (i = 0; i < account_count; i++) {
if (account_list[i].incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
- if (!emcore_delete_account(account_list[i].account_id, true, &err)) {
+ if (!emcore_delete_account(multi_user_name, account_list[i].account_id, true, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_account failed [%d]", err);
goto FINISH_OFF;
}
@@ -1347,7 +1165,7 @@ INTERNAL_FUNC int emcore_restore_accounts(const char *file_path)
em_convert_byte_stream_to_account(account_stream, account_stream_length, &temp_account);
EM_SAFE_FREE(account_stream);
- if ((emstorage_check_duplicated_account(&temp_account, true, &err) == false) && (err = EMAIL_ERROR_ALREADY_EXISTS)) {
+ if ((emstorage_check_duplicated_account(multi_user_name, &temp_account, true, &err) == false) && (err = EMAIL_ERROR_ALREADY_EXISTS)) {
EM_DEBUG_EXCEPTION("An account is duplicated. ");
buffer_ptr += account_stream_length;
account_stream_length = 0;
@@ -1356,13 +1174,12 @@ INTERNAL_FUNC int emcore_restore_accounts(const char *file_path)
continue;
}
- if (!emcore_create_account(&temp_account, true, &err)) {
+ if (!emcore_create_account(multi_user_name, &temp_account, true, &err)) {
EM_DEBUG_EXCEPTION("emcore_create_account() failed. [%d]", err);
goto FINISH_OFF;
}
emcore_free_account(&temp_account);
- emcore_init_account_reference();
}
buffer_ptr += account_stream_length;
account_stream_length = 0;
@@ -1392,7 +1209,6 @@ FINISH_OFF:
account_list = NULL;
}
emcore_free_account(&temp_account);
-
EM_SAFE_FREE(account_stream);
EM_SAFE_FREE(temp_buffer);
EM_SAFE_FREE(encrypt_buffer);
@@ -1403,7 +1219,7 @@ FINISH_OFF:
#endif /* __FEATURE_BACKUP_ACCOUNT_ */
-INTERNAL_FUNC int emcore_save_default_account_id(int input_account_id)
+INTERNAL_FUNC int emcore_save_default_account_id(char *multi_user_name, int input_account_id)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d]", input_account_id);
int ret_code = EMAIL_ERROR_NONE, result_value = 0;
@@ -1418,7 +1234,7 @@ INTERNAL_FUNC int emcore_save_default_account_id(int input_account_id)
return ret_code;
}
-static int _recover_from_invalid_default_account_id(int *output_account_id)
+static int _recover_from_invalid_default_account_id(char *multi_user_name, int *output_account_id)
{
EM_DEBUG_FUNC_BEGIN("account_id [%p]", output_account_id);
int ret_code = EMAIL_ERROR_NONE;
@@ -1430,7 +1246,7 @@ static int _recover_from_invalid_default_account_id(int *output_account_id)
goto FINISH_OFF;
}
- if(!emstorage_get_account_list(&account_count, &result_account_list, false, false, &ret_code) || !result_account_list) {
+ if(!emstorage_get_account_list(multi_user_name, &account_count, &result_account_list, false, false, &ret_code) || !result_account_list) {
if (ret_code == EMAIL_ERROR_ACCOUNT_NOT_FOUND)
EM_DEBUG_LOG ("no account found");
else
@@ -1454,7 +1270,7 @@ FINISH_OFF:
return ret_code;
}
-INTERNAL_FUNC int emcore_load_default_account_id(int *output_account_id)
+INTERNAL_FUNC int emcore_load_default_account_id(char *multi_user_name, int *output_account_id)
{
EM_DEBUG_FUNC_BEGIN("account_id [%p]", output_account_id);
int ret_code = EMAIL_ERROR_NONE;
@@ -1475,7 +1291,7 @@ INTERNAL_FUNC int emcore_load_default_account_id(int *output_account_id)
}
if (*output_account_id != 0) {
- if (!emstorage_get_account_by_id(*output_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &result_account, false, &ret_code)) {
+ if (!emstorage_get_account_by_id(multi_user_name, *output_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &result_account, false, &ret_code)) {
if (ret_code == EMAIL_ERROR_ACCOUNT_NOT_FOUND) {
EM_DEBUG_LOG ("no account found account_id[%d]", *output_account_id);
*output_account_id = 0;
@@ -1488,7 +1304,7 @@ INTERNAL_FUNC int emcore_load_default_account_id(int *output_account_id)
}
if (*output_account_id == 0) {
- if ((ret_code = _recover_from_invalid_default_account_id (output_account_id)) != EMAIL_ERROR_NONE) {
+ if ((ret_code = _recover_from_invalid_default_account_id (multi_user_name, output_account_id)) != EMAIL_ERROR_NONE) {
if (ret_code == EMAIL_ERROR_ACCOUNT_NOT_FOUND)
EM_DEBUG_LOG ("no account found");
else
@@ -1505,7 +1321,7 @@ FINISH_OFF:
return ret_code;
}
-INTERNAL_FUNC int emcore_recover_from_secured_storage_failure()
+INTERNAL_FUNC int emcore_recover_from_secured_storage_failure(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
@@ -1514,15 +1330,15 @@ INTERNAL_FUNC int emcore_recover_from_secured_storage_failure()
emstorage_account_tbl_t *temp_account_tbl_list = NULL;
emstorage_account_tbl_t *temp_account_tbl = NULL;
- if (!emstorage_get_account_list(&account_count, &temp_account_tbl_list, true, false, &err)) {
+ if (!emstorage_get_account_list(multi_user_name, &account_count, &temp_account_tbl_list, true, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
for (i = 0; i < account_count; i++) {
- if(!emstorage_get_account_by_id(temp_account_tbl_list[i].account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_PASSWORD, &temp_account_tbl, true, &err)) {
+ if(!emstorage_get_account_by_id(multi_user_name, temp_account_tbl_list[i].account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_PASSWORD, &temp_account_tbl, true, &err)) {
if(err == EMAIL_ERROR_SECURED_STORAGE_FAILURE) {
- if(!emcore_delete_account(temp_account_tbl_list[i].account_id, true, &err)) {
+ if(!emcore_delete_account(multi_user_name, temp_account_tbl_list[i].account_id, true, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_account failed [%d]", err);
goto FINISH_OFF;
}
@@ -1539,7 +1355,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_update_sync_status_of_account(int input_account_id, email_set_type_t input_set_operator, int input_sync_status)
+INTERNAL_FUNC int emcore_update_sync_status_of_account(char *multi_user_name, int input_account_id, email_set_type_t input_set_operator, int input_sync_status)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_set_operator [%d], input_sync_status [%d]", input_account_id, input_set_operator, input_sync_status);
int err = EMAIL_ERROR_NONE;
@@ -1547,12 +1363,22 @@ INTERNAL_FUNC int emcore_update_sync_status_of_account(int input_account_id, ema
#ifdef __FEATURE_USING_ACCOUNT_SVC_FOR_SYNC_STATUS__
int err_from_account_svc = 0;
emstorage_account_tbl_t *account_tbl_data = NULL;
+ void *join_zone = NULL;
+
if (input_account_id != ALL_ACCOUNT && (input_sync_status == SYNC_STATUS_SYNCING)) {
- if (!emstorage_get_account_by_id(input_account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_OPTIONS, &account_tbl_data, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, input_account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_OPTIONS, &account_tbl_data, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_set_join_zone(multi_user_name, &join_zone);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+
err_from_account_svc = account_connect();
EM_DEBUG_LOG_DEV("account_connect returns [%d]", err_from_account_svc);
@@ -1565,10 +1391,11 @@ INTERNAL_FUNC int emcore_update_sync_status_of_account(int input_account_id, ema
err_from_account_svc = account_disconnect();
EM_DEBUG_LOG_DEV("account_disconnect returns [%d]", err_from_account_svc);
+ if (join_zone) emcore_unset_join_zone(join_zone);
}
#endif /* __FEATURE_USING_ACCOUNT_SVC_FOR_SYNC_STATUS__ */
- if (!emstorage_update_sync_status_of_account(input_account_id, input_set_operator, input_sync_status, true, &err))
+ if (!emstorage_update_sync_status_of_account(multi_user_name, input_account_id, input_set_operator, input_sync_status, true, &err))
EM_DEBUG_EXCEPTION("emstorage_update_sync_status_of_account failed [%d]", err);
#ifdef __FEATURE_USING_ACCOUNT_SVC_FOR_SYNC_STATUS__
@@ -1733,7 +1560,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(int input_account_id)
+INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(char *multi_user_name, int input_account_id)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d]", input_account_id);
int err = EMAIL_ERROR_NONE;
@@ -1746,8 +1573,7 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(int input_account_id)
email_account_t *ref_account = NULL;
- ref_account = emcore_get_account_reference(input_account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, input_account_id, true);
if(ref_account == NULL) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference() failed");
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -1755,7 +1581,6 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(int input_account_id)
}
access_token = EM_SAFE_STRDUP(strtok_r(ref_account->incoming_server_password, "\001", &saveptr));
-
if(access_token == NULL) {
EM_DEBUG_EXCEPTION("invalid token string.");
err = EMAIL_ERROR_XOAUTH_BAD_REQUEST;
@@ -1790,13 +1615,11 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(int input_account_id)
SNPRINTF(new_password_string, new_password_string_length, "%s\001%s", new_access_token, refresh_token);
- if((err = emstorage_update_account_password(input_account_id, new_password_string, new_password_string)) != EMAIL_ERROR_NONE) {
+ if((err = emstorage_update_account_password(multi_user_name, input_account_id, new_password_string, new_password_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_update_account_password() failed [%d]", err);
goto FINISH_OFF;
}
- emcore_init_account_reference();
-
FINISH_OFF:
EM_SAFE_FREE(access_token);
diff --git a/email-core/email-core-alarm.c b/email-core/email-core-alarm.c
index d1d75f3..0876dce 100755
--- a/email-core/email-core-alarm.c
+++ b/email-core/email-core-alarm.c
@@ -154,7 +154,7 @@ INTERNAL_FUNC int emcore_check_alarm_by_class_id(email_alarm_class_t input_class
return err;
}
-static int emcore_add_alarm_data_to_alarm_data_list(alarm_id_t input_alarm_id, email_alarm_class_t input_class_id, int input_reference_id, time_t input_trigger_at_time, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *user_data)
+static int emcore_add_alarm_data_to_alarm_data_list(char *multi_user_name, alarm_id_t input_alarm_id, email_alarm_class_t input_class_id, int input_reference_id, time_t input_trigger_at_time, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *user_data)
{
EM_DEBUG_FUNC_BEGIN("input_alarm_id [%d] input_class_id[%d] input_reference_id[%d] input_trigger_at_time[%d] input_alarm_callback [%p] user_data[%p]", input_alarm_id, input_class_id, input_reference_id, input_trigger_at_time, input_alarm_callback, user_data);
int err = EMAIL_ERROR_NONE;
@@ -173,12 +173,14 @@ static int emcore_add_alarm_data_to_alarm_data_list(alarm_id_t input_alarm_id, e
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
+
alarm_data->alarm_id = input_alarm_id;
alarm_data->class_id = input_class_id;
alarm_data->reference_id = input_reference_id;
alarm_data->trigger_at_time = input_trigger_at_time;
alarm_data->alarm_callback = input_alarm_callback;
alarm_data->user_data = user_data;
+ alarm_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
ENTER_CRITICAL_SECTION(alarm_data_lock);
alarm_data_list = g_list_append(alarm_data_list, (gpointer)alarm_data);
@@ -203,6 +205,7 @@ static int emcore_remove_alarm(email_alarm_data_t *input_alarm_data)
EM_DEBUG_EXCEPTION ("alarmmgr_remove_alarm failed [%d]", ret);
err = EMAIL_ERROR_SYSTEM_FAILURE;
}
+ EM_SAFE_FREE(input_alarm_data->multi_user_name);
LEAVE_CRITICAL_SECTION(alarm_data_lock);
EM_DEBUG_FUNC_END("err [%d]", err);
@@ -232,7 +235,9 @@ INTERNAL_FUNC int emcore_delete_alram_data_from_alarm_data_list(email_alarm_data
alarm_data_list = NULL;
}
LEAVE_CRITICAL_SECTION(alarm_data_lock);
+
FINISH_OFF:
+
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
@@ -244,7 +249,7 @@ INTERNAL_FUNC int emcore_delete_alram_data_by_reference_id(email_alarm_class_t i
email_alarm_data_t *alarm_data = NULL;
if ((err = emcore_get_alarm_data_by_reference_id(input_class_id, input_reference_id, &alarm_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_LOG ("emcore_remove_alarm return [%d]", err);
+ EM_DEBUG_LOG ("emcore_get_alarm_data_by_reference_id return [%d]", err);
goto FINISH_OFF;
}
@@ -257,7 +262,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_add_alarm(time_t input_trigger_at_time, email_alarm_class_t input_class_id, int input_reference_id, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *input_user_data)
+INTERNAL_FUNC int emcore_add_alarm(char *multi_user_name, time_t input_trigger_at_time, email_alarm_class_t input_class_id, int input_reference_id, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *input_user_data)
{
EM_DEBUG_FUNC_BEGIN("input_trigger_at_time[%d] input_class_id[%d] input_reference_id[%d] input_alarm_callback[%p] input_user_data[%p]", input_trigger_at_time, input_class_id, input_reference_id, input_alarm_callback, input_user_data);
@@ -279,7 +284,7 @@ INTERNAL_FUNC int emcore_add_alarm(time_t input_trigger_at_time, email_alarm_cla
goto FINISH_OFF;
}
- if((err = emcore_add_alarm_data_to_alarm_data_list(alarm_id, input_class_id, input_reference_id, input_trigger_at_time, input_alarm_callback, input_user_data)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_alarm_data_to_alarm_data_list(multi_user_name, alarm_id, input_class_id, input_reference_id, input_trigger_at_time, input_alarm_callback, input_user_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm_data_to_alarm_data_list failed [%d]", err);
goto FINISH_OFF;
}
diff --git a/email-core/email-core-auto-download.c b/email-core/email-core-auto-download.c
index f5bdc5c..66f7a3e 100755
--- a/email-core/email-core-auto-download.c
+++ b/email-core/email-core-auto-download.c
@@ -346,7 +346,7 @@ static void* worker_auto_download_queue(void *arg)
email_event_auto_download *activity_list = NULL;
- if (!emstorage_open(&err)) {
+ if (!emstorage_open(NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_open falied [%d]", err);
return false;
}
@@ -364,7 +364,7 @@ static void* worker_auto_download_queue(void *arg)
}
activity_count = 0;
- if (!emstorage_get_auto_download_activity_count(&activity_count, false, &err)) {
+ if (!emstorage_get_auto_download_activity_count(NULL, &activity_count, false, &err)) {
EM_DEBUG_LOG("emstorage_get_auto_download_activity_count failed [%d]", err);
goto CHECK_CONTINUE;
}
@@ -376,7 +376,7 @@ static void* worker_auto_download_queue(void *arg)
account_count = 0;
EM_SAFE_FREE(account_list);
- if (!emstorage_get_auto_download_account_list(&account_list, &account_count, false, &err)) {
+ if (!emstorage_get_auto_download_account_list(NULL, &account_list, &account_count, false, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_auto_download_account_list failed.. [%d]", err);
goto CHECK_CONTINUE;
}
@@ -389,7 +389,7 @@ static void* worker_auto_download_queue(void *arg)
for (ai = 0; ai < account_count; ai++) {
email_account_t *account_ref = NULL;
- if (!(account_ref = emcore_get_account_reference(account_list[ai]))) {
+ if (!(account_ref = emcore_get_account_reference(NULL, account_list[ai], false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_list[ai]);
err = EMAIL_ERROR_INVALID_ACCOUNT;
continue;
@@ -411,7 +411,7 @@ static void* worker_auto_download_queue(void *arg)
mailbox_count = 0;
EM_SAFE_FREE(mailbox_list);
- if (!emstorage_get_auto_download_mailbox_list(account_list[ai], &mailbox_list, &mailbox_count, false, &err)) {
+ if (!emstorage_get_auto_download_mailbox_list(NULL, account_list[ai], &mailbox_list, &mailbox_count, false, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_auto_download_mailbox_list failed.. [%d]", err);
goto CHECK_CONTINUE;
}
@@ -427,7 +427,7 @@ static void* worker_auto_download_queue(void *arg)
activity_list_count = 0;
EM_SAFE_FREE(activity_list);
- if ((err = emstorage_get_mailbox_by_id(mailbox_list[mi], &target_mailbox)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(NULL, mailbox_list[mi], &target_mailbox)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
}
@@ -440,7 +440,7 @@ static void* worker_auto_download_queue(void *arg)
emstorage_free_mailbox(&target_mailbox, 1, NULL);
}
- if (!emstorage_get_auto_download_activity(account_list[ai], mailbox_list[mi], &activity_list, &activity_list_count, false, &err)) {
+ if (!emstorage_get_auto_download_activity(NULL, account_list[ai], mailbox_list[mi], &activity_list, &activity_list_count, false, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_auto_download_activity failed.. [%d]", err);
goto CHECK_CONTINUE;
}
@@ -524,7 +524,7 @@ CHECK_CONTINUE:
auto_download_thread_run = 1;
}
- if (!(account_ref = emcore_get_account_reference(event_data->account_id))) {
+ if (!(account_ref = emcore_get_account_reference(event_data->multi_user_name, event_data->account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", event_data->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto POP_HEAD;
@@ -540,7 +540,7 @@ CHECK_CONTINUE:
EM_SAFE_FREE(account_ref);
}
- if ((err = emstorage_get_mailbox_by_id(event_data->mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(event_data->multi_user_name, event_data->mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
}
@@ -568,7 +568,12 @@ CHECK_CONTINUE:
}
snprintf(uid_str, sizeof(uid_str), "%ld", event_data->server_mail_id);
- if (!emstorage_get_maildata_by_servermailid(event_data->mailbox_id, uid_str, &mail, true, &err) || !mail) {
+ if (!emstorage_get_maildata_by_servermailid(event_data->multi_user_name,
+ uid_str,
+ event_data->mailbox_id,
+ &mail,
+ true,
+ &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_data_by_servermailid failed : [%d]", err);
}
else {
@@ -580,7 +585,7 @@ CHECK_CONTINUE:
event_data->account_id, event_data->mailbox_id,
event_data->mail_id, event_data->server_mail_id, event_data->activity_id);
- if (!emcore_gmime_download_body_sections(NULL, event_data->account_id, event_data->mail_id,
+ if (!emcore_gmime_download_body_sections(event_data->multi_user_name, NULL, event_data->account_id, event_data->mail_id,
1, NO_LIMITATION, -1, 0, 1, &err))
EM_DEBUG_EXCEPTION("emcore_gmime_download_body_sections failed - %d", err);
}
@@ -591,7 +596,7 @@ CHECK_CONTINUE:
int attachment_count = 0;
emstorage_attachment_tbl_t *attachment_list = NULL;
- if ((err = emstorage_get_attachment_list(event_data->mail_id, true, &attachment_list, &attachment_count)) != EMAIL_ERROR_NONE ) {
+ if ((err = emstorage_get_attachment_list(event_data->multi_user_name, event_data->mail_id, true, &attachment_list, &attachment_count)) != EMAIL_ERROR_NONE ) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
} else {
for (i = 0; i < attachment_count; i++) {
@@ -607,7 +612,7 @@ CHECK_CONTINUE:
j, event_data->account_id, event_data->mailbox_id,
event_data->mail_id, event_data->server_mail_id, event_data->activity_id);
- if (!emcore_gmime_download_attachment(event_data->mail_id, j, 0, -1, 1, &err))
+ if (!emcore_gmime_download_attachment(event_data->multi_user_name, event_data->mail_id, j, 0, -1, 1, &err))
EM_DEBUG_EXCEPTION("emcore_gmime_download_attachment failed [%d]", err);
}
@@ -621,7 +626,7 @@ CHECK_CONTINUE:
}
DELETE_ACTIVITY:
- if (!emcore_delete_auto_download_activity(event_data->account_id, event_data->mail_id, event_data->activity_id, &err)) {
+ if (!emcore_delete_auto_download_activity(event_data->multi_user_name, event_data->account_id, event_data->mail_id, event_data->activity_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_auto_download_activity failed [%d]", err);
}
@@ -635,6 +640,7 @@ POP_HEAD:
EM_DEBUG_EXCEPTION("Failed to g_queue_pop_head");
}
else {
+ EM_SAFE_FREE(started_event->multi_user_name);
EM_SAFE_FREE(started_event);
}
@@ -642,8 +648,6 @@ POP_HEAD:
emcore_free_account(account_ref);
EM_SAFE_FREE(account_ref);
}
-
- em_flush_memory();
}
}
@@ -657,7 +661,7 @@ POP_HEAD:
}
-INTERNAL_FUNC int emcore_insert_auto_download_job(int account_id, int mailbox_id, int mail_id, int auto_download_on, char *uid, int *err_code)
+INTERNAL_FUNC int emcore_insert_auto_download_job(char *multi_user_name, int account_id, int mailbox_id, int mail_id, int auto_download_on, char *uid, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], maibox_id[%d], mail_id[%d], uid[%p]", account_id, mailbox_id, mail_id, uid);
@@ -685,6 +689,7 @@ INTERNAL_FUNC int emcore_insert_auto_download_job(int account_id, int mailbox_id
ad_event->mail_id = mail_id;
ad_event->server_mail_id = strtoul(uid, NULL, 0);
ad_event->mailbox_id = mailbox_id;
+ ad_event->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_auto_download_activity(ad_event, &(ad_event->activity_id), &err)) {
EM_DEBUG_EXCEPTION("Inserting auto download activity failed with error[%d]", err);
@@ -711,8 +716,12 @@ INTERNAL_FUNC int emcore_insert_auto_download_job(int account_id, int mailbox_id
FINISH_OFF:
- if (!event_pushed)
- EM_SAFE_FREE(ad_event);
+ if (!event_pushed) {
+ if (ad_event) {
+ EM_SAFE_FREE(ad_event->multi_user_name);
+ free(ad_event);
+ }
+ }
EM_DEBUG_FUNC_END();
return ret;
@@ -734,13 +743,13 @@ INTERNAL_FUNC int emcore_insert_auto_download_activity(email_event_auto_download
int err = EMAIL_ERROR_NONE;
int before_tr_begin = 0;
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(local_activity->multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
}
- if (!emstorage_add_auto_download_activity(local_activity, activity_id, false, &err)) {
+ if (!emstorage_add_auto_download_activity(local_activity->multi_user_name, local_activity, activity_id, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_auto_download_activity failed [%d]", err);
goto FINISH_OFF;
}
@@ -749,12 +758,12 @@ INTERNAL_FUNC int emcore_insert_auto_download_activity(email_event_auto_download
FINISH_OFF:
if (ret == true) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(local_activity->multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
ret = false;
}
} else { /* ROLLBACK TRANSACTION; */
- if (!before_tr_begin && emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (!before_tr_begin && emstorage_rollback_transaction(local_activity->multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
@@ -765,7 +774,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_delete_auto_download_activity(int account_id, int mail_id, int activity_id, int *err_code)
+INTERNAL_FUNC int emcore_delete_auto_download_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], err_code[%p]", account_id, mail_id, err_code);
@@ -780,13 +789,13 @@ INTERNAL_FUNC int emcore_delete_auto_download_activity(int account_id, int mail_
int err = EMAIL_ERROR_NONE;
int before_tr_begin = 0;
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
}
- if (!emstorage_delete_auto_download_activity(account_id, mail_id, activity_id, false, &err)) {
+ if (!emstorage_delete_auto_download_activity(multi_user_name, account_id, mail_id, activity_id, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_auto_download_activity failed [%d]", err);
goto FINISH_OFF;
}
@@ -798,12 +807,12 @@ INTERNAL_FUNC int emcore_delete_auto_download_activity(int account_id, int mail_
FINISH_OFF:
if (ret == true) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
ret = false;
}
} else { /* ROLLBACK TRANSACTION; */
- if (!before_tr_begin && emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (!before_tr_begin && emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
diff --git a/email-core/email-core-cert.c b/email-core/email-core-cert.c
index 0b7de69..39be3fb 100755
--- a/email-core/email-core-cert.c
+++ b/email-core/email-core-cert.c
@@ -238,6 +238,10 @@ INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, EVP_PKEY **pri_key, X5
CertSvcInstance cert_instance;
CertSvcCertificate csc_cert;
CertSvcCertificateList certificate_list;
+ CertSvcStoreCertList* certList = NULL;
+ CertSvcStoreCertList* tempList = NULL;
+ char *alias = NULL;
+ int length = 0;
if (certificate == NULL) {
EM_DEBUG_EXCEPTION("Invalid parameter");
@@ -245,6 +249,8 @@ INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, EVP_PKEY **pri_key, X5
goto FINISH_OFF;
}
+ EM_DEBUG_LOG("emcore_load_PFX_file - certificate passed : %s", certificate);
+
/* Create instance */
err = certsvc_instance_new(&cert_instance);
if (err != CERTSVC_SUCCESS) {
@@ -253,8 +259,32 @@ INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, EVP_PKEY **pri_key, X5
goto FINISH_OFF;
}
+ if (certsvc_pkcs12_get_end_user_certificate_list_from_store(cert_instance, EMAIL_STORE, &certList, &length)!=CERTSVC_SUCCESS)
+ {
+ EM_DEBUG_EXCEPTION("certsvc_string_new failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+ tempList = certList;
+ while(tempList!=NULL)
+ {
+ if (strcmp(tempList->title, certificate)==0)
+ {
+ alias = strdup(tempList->gname);
+ break;
+ }
+ if (strcmp(tempList->gname, certificate)==0)
+ {
+ alias = strdup(tempList->gname);
+ break;
+ }
+ tempList = tempList->next;
+ }
+
+ certsvc_pkcs12_free_certificate_list_loaded_from_store(cert_instance, &certList);
+
/* Make the pfxID string */
- err = certsvc_string_new(cert_instance, certificate, EM_SAFE_STRLEN(certificate), &csstring);
+ err = certsvc_string_new(cert_instance, alias, EM_SAFE_STRLEN(alias), &csstring);
if (err != CERTSVC_SUCCESS) {
EM_DEBUG_EXCEPTION("certsvc_string_new failed : [%d]", err);
err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
@@ -262,11 +292,23 @@ INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, EVP_PKEY **pri_key, X5
}
/* Load the certificate list of pkcs12 type */
- err = certsvc_pkcs12_load_certificate_list(cert_instance, csstring, &certificate_list);
+ err = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, EMAIL_STORE, csstring, &certificate_list);
if (err != CERTSVC_SUCCESS) {
- EM_DEBUG_EXCEPTION("certsvc_pkcs12_load_certificate_list failed : [%d]", err);
- err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
- goto FINISH_OFF;
+ certsvc_string_free(csstring);
+ err = certsvc_string_new(cert_instance, certificate, EM_SAFE_STRLEN(certificate), &csstring);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_string_new failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* Load the certificate list of pkcs12 type */
+ err = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, EMAIL_STORE, csstring, &certificate_list);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_pkcs12_load_certificate_list_from_store failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
}
/* Get a certificate */
@@ -286,9 +328,9 @@ INTERNAL_FUNC int emcore_load_PFX_file(char *certificate, EVP_PKEY **pri_key, X5
}
/* Get the private key */
- err = certsvc_pkcs12_private_key_dup(cert_instance, csstring, &private_key, &key_size);
+ err = certsvc_pkcs12_private_key_dup_from_store(cert_instance, EMAIL_STORE, csstring, &private_key, &key_size);
if (err != CERTSVC_SUCCESS) {
- EM_DEBUG_EXCEPTION("certsvc_pkcs12_private_key_dup failed : [%d]", err);
+ EM_DEBUG_EXCEPTION("certsvc_pkcs12_private_key_dup_from_store failed : [%d]", err);
err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
goto FINISH_OFF;
}
@@ -334,8 +376,8 @@ FINISH_OFF:
EVP_PKEY_free(t_pri_key);
}
- if (private_key)
- EM_SAFE_FREE(private_key);
+ EM_SAFE_FREE(private_key);
+ EM_SAFE_FREE(alias);
if (err_code)
*err_code = err;
@@ -350,6 +392,10 @@ INTERNAL_FUNC int emcore_load_PFX_file_from_string(char *certificate, char **key
int ret = false;
size_t p_key_size = 0;
char *private_key = NULL;
+ CertSvcStoreCertList* certList = NULL;
+ CertSvcStoreCertList* tempList = NULL;
+ char *alias = NULL;
+ int length = 0;
/* Variable for certificate */
X509 *t_cert = NULL;
@@ -369,6 +415,8 @@ INTERNAL_FUNC int emcore_load_PFX_file_from_string(char *certificate, char **key
goto FINISH_OFF;
}
+ EM_DEBUG_EXCEPTION("emcore_load_PFX_file_from_string - certificate passed : %s",certificate);
+
/* Create instance */
err = certsvc_instance_new(&cert_instance);
if (err != CERTSVC_SUCCESS) {
@@ -385,14 +433,46 @@ INTERNAL_FUNC int emcore_load_PFX_file_from_string(char *certificate, char **key
goto FINISH_OFF;
}
- /* Load the certificate list of pkcs12 type */
- err = certsvc_pkcs12_load_certificate_list(cert_instance, csstring, &certificate_list);
- if (err != CERTSVC_SUCCESS) {
- EM_DEBUG_EXCEPTION("certsvc_pkcs12_load_certificate_list failed : [%d]", err);
+ if (certsvc_pkcs12_get_end_user_certificate_list_from_store(cert_instance, EMAIL_STORE, &certList, &length)!=CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_string_new failed : [%d]", err);
err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
goto FINISH_OFF;
}
+ tempList = certList;
+ while(tempList!=NULL) {
+ if (strcmp(tempList->title, certificate)==0) {
+ alias = strdup(tempList->gname);
+ break;
+ } else if (strcmp(tempList->gname, certificate)==0) {
+ alias = strdup(tempList->gname);
+ break;
+ }
+ tempList = tempList->next;
+ }
+
+ certsvc_pkcs12_free_certificate_list_loaded_from_store(cert_instance, &certList);
+
+ /* Load the certificate list of pkcs12 type */
+ err = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, EMAIL_STORE, csstring, &certificate_list);
+ if (err != CERTSVC_SUCCESS) {
+ certsvc_string_free(csstring);
+ err = certsvc_string_new(cert_instance, alias, EM_SAFE_STRLEN(alias), &csstring);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_string_new failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* Load the certificate list of pkcs12 type */
+ err = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, EMAIL_STORE, csstring, &certificate_list);
+ if (err != CERTSVC_SUCCESS) {
+ EM_DEBUG_EXCEPTION("certsvc_pkcs12_load_certificate_list_from_store failed : [%d]", err);
+ err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
+ goto FINISH_OFF;
+ }
+ }
+
/* Get a certificate */
err = certsvc_certificate_list_get_one(certificate_list, 0, &csc_cert);
if (err != CERTSVC_SUCCESS) {
@@ -410,9 +490,9 @@ INTERNAL_FUNC int emcore_load_PFX_file_from_string(char *certificate, char **key
}
/* Get the private key */
- err = certsvc_pkcs12_private_key_dup(cert_instance, csstring, &private_key, &p_key_size);
+ err = certsvc_pkcs12_private_key_dup_from_store(cert_instance, EMAIL_STORE, csstring, &private_key, &p_key_size);
if (err != CERTSVC_SUCCESS) {
- EM_DEBUG_EXCEPTION("certsvc_pkcs12_private_key_dup failed : [%d]", err);
+ EM_DEBUG_EXCEPTION("certsvc_pkcs12_private_key_dup_from_store failed : [%d]", err);
err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
goto FINISH_OFF;
}
@@ -434,13 +514,15 @@ FINISH_OFF:
EM_SAFE_FREE(private_key);
}
+ EM_SAFE_FREE(alias);
+
if (err_code)
*err_code = err;
return ret;
}
-INTERNAL_FUNC int emcore_add_public_certificate(char *public_cert_path, char *save_name, int *err_code)
+INTERNAL_FUNC int emcore_add_public_certificate(char *multi_user_name, char *public_cert_path, char *save_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("Path [%s], filename [%s]", public_cert_path, save_name);
int err = EMAIL_ERROR_NONE;
@@ -547,7 +629,7 @@ INTERNAL_FUNC int emcore_add_public_certificate(char *public_cert_path, char *sa
cert->subject_str = EM_SAFE_STRDUP(context->certDesc->info.issuerStr);
cert->filepath = EM_SAFE_STRDUP(filepath);
- if (!emstorage_add_certificate(cert, true, &err)) {
+ if (emstorage_add_certificate(multi_user_name, cert, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_certificate failed");
goto FINISH_OFF;
}
@@ -563,9 +645,11 @@ FINISH_OFF:
emstorage_delete_file(temp_file, NULL);
- emstorage_free_certificate(&cert, 1, NULL);
+ if (cert)
+ emstorage_free_certificate(&cert, 1, NULL);
- cert_svc_cert_context_final(context);
+ if (context)
+ cert_svc_cert_context_final(context);
if (err_code != NULL) {
*err_code = err;
@@ -577,7 +661,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_delete_public_certificate(char *email_address, int *err_code)
+INTERNAL_FUNC int emcore_delete_public_certificate(char *multi_user_name, char *email_address, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int ret = false;
@@ -590,7 +674,7 @@ INTERNAL_FUNC int emcore_delete_public_certificate(char *email_address, int *err
goto FINISH_OFF;
}
- if (!emstorage_get_certificate_by_email_address(email_address, &certificate, false, 0, &err)) {
+ if (!emstorage_get_certificate_by_email_address(multi_user_name, email_address, &certificate, false, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_certificate failed");
goto FINISH_OFF;
}
@@ -600,7 +684,7 @@ INTERNAL_FUNC int emcore_delete_public_certificate(char *email_address, int *err
goto FINISH_OFF;
}
- if (!emstorage_delete_certificate(certificate->certificate_id, true, &err)) {
+ if (!emstorage_delete_certificate(multi_user_name, certificate->certificate_id, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_certificate failed");
goto FINISH_OFF;
}
@@ -628,9 +712,7 @@ INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity
int flags = PKCS7_NOVERIFY;
BIO *bio_p7s = NULL;
-
BIO *bio_indata = NULL;
-
PKCS7 *pkcs7_p7s = NULL;
/* Open p7s file */
@@ -652,13 +734,15 @@ INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity
/* Load the p7s file */
pkcs7_p7s = d2i_PKCS7_bio(bio_p7s, NULL);
if (!pkcs7_p7s) {
- EM_DEBUG_EXCEPTION("d2i_PKCS7_bio failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("d2i_PKCS7_bio failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_LOAD_CERTIFICATE_FAILURE;
goto FINISH_OFF;
}
if (!PKCS7_verify(pkcs7_p7s, NULL, NULL, bio_indata, NULL, flags)) {
- EM_DEBUG_EXCEPTION("PKCS7_verify failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_verify failed : [%ld][%s]", error, ERR_error_string(error, NULL));
goto FINISH_OFF;
}
@@ -668,14 +752,9 @@ INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity
FINISH_OFF:
- if (pkcs7_p7s)
- PKCS7_free(pkcs7_p7s);
-
- if (bio_p7s)
- BIO_free(bio_p7s);
-
- if (bio_indata)
- BIO_free(bio_indata);
+ PKCS7_free(pkcs7_p7s);
+ BIO_free(bio_p7s);
+ BIO_free(bio_indata);
if (validity)
*validity = t_validity;
diff --git a/email-core/email-core-container.c b/email-core/email-core-container.c
new file mode 100644
index 0000000..da21028
--- /dev/null
+++ b/email-core/email-core-container.c
@@ -0,0 +1,441 @@
+/*
+* email-service
+*
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+*
+* 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.
+*
+*/
+
+/**
+ *
+ * This file contains functionality related to KNOX
+ * to interact with email-service.
+ * @file email-core-container.c
+ * @author
+ * @version 0.1
+ * @brief This file contains functionality to provide KNOX support in email-service.
+ */
+
+#include <vasum.h>
+
+#include "email-utilities.h"
+#include "email-core-container.h"
+#include "email-debug-log.h"
+
+int vsm_state_handle = 0;
+int vsm_event_handle = 0;
+vsm_context_h container;
+
+enum {
+ CONTAINER_DISABLE = 0,
+ CONTAINER_ENABLE = 1
+};
+
+static int container_status = CONTAINER_DISABLE;
+
+static int container_state_listener(vsm_zone_h zone, vsm_zone_state_t state, void *user_data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ EM_DEBUG_LOG("Container name : [%s]", vsm_get_zone_name(zone));
+ EM_DEBUG_LOG("Container state : [%d]", state);
+ EM_DEBUG_FUNC_END();
+ return 0;
+}
+
+static int container_event_listener(vsm_zone_h zone, vsm_zone_event_t event, void *user_data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ EM_DEBUG_LOG("Container name : [%s]", vsm_get_zone_name(zone));
+ EM_DEBUG_LOG("Container event : [%d]", event);
+ EM_DEBUG_FUNC_END();
+ return 0;
+}
+
+INTERNAL_FUNC void emcore_create_container()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ container = NULL;
+
+ container = vsm_create_context();
+ if (container == NULL) {
+ EM_DEBUG_EXCEPTION("vsm_create_context failed");
+ return;
+ }
+
+ vsm_state_handle = vsm_add_state_changed_callback(container, container_state_listener, NULL);
+ vsm_event_handle = vsm_add_event_callback(container, container_event_listener, NULL);
+
+ EM_DEBUG_FUNC_END();
+}
+
+INTERNAL_FUNC void emcore_destroy_container()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ if (container) {
+ vsm_del_state_changed_callback(container, vsm_state_handle);
+
+ vsm_del_event_callback(container, vsm_event_handle);
+
+ vsm_cleanup_context(container);
+
+ container = NULL;
+ }
+
+ EM_DEBUG_FUNC_END();
+}
+
+static gboolean mainloop_callback(GIOChannel *channel, GIOCondition condition, void *data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ vsm_context_h ctx = (vsm_context_h)data;
+
+ EM_DEBUG_LOG("Enter event loop");
+ vsm_enter_eventloop(ctx, 0, 0);
+ EM_DEBUG_LOG("Finish event loop");
+
+ EM_DEBUG_FUNC_END();
+ return TRUE;
+}
+
+INTERNAL_FUNC void emcore_bind_vsm_context()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int fd;
+
+ GIOChannel *domain_channel = NULL;
+
+ fd = vsm_get_poll_fd(container);
+ if (fd < 0) {
+ EM_DEBUG_EXCEPTION("vsm_get_poll_fd failed");
+ return;
+ }
+
+ domain_channel = g_io_channel_unix_new(fd);
+ if (domain_channel == NULL) {
+ EM_DEBUG_EXCEPTION("Channel allocation failed");
+ return;
+ }
+
+ g_io_add_watch(domain_channel, G_IO_IN, mainloop_callback, container);
+
+ EM_DEBUG_FUNC_END();
+}
+
+INTERNAL_FUNC int emcore_get_container_path(char *multi_user, char **container_path)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+
+ if (multi_user == NULL) {
+ EM_DEBUG_LOG("user_name is NULL");
+ return EMAIL_ERROR_INVALID_PARAM;
+ }
+
+ if (container_status == CONTAINER_DISABLE) {
+ EM_DEBUG_LOG("Single container");
+ return err;
+ }
+
+ if (container == NULL) {
+ EM_DEBUG_LOG("Container not intialize");
+ return EMAIL_ERROR_CONTAINER_NOT_INITIALIZATION;
+ }
+
+ vsm_zone_h zone = NULL;
+ char *p_container_path = NULL;
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
+
+ if (EM_SAFE_STRLEN(multi_user) == 0) {
+ EM_DEBUG_LOG("multi_user name is NULL");
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("name : [%s], container : [%p]", multi_user, container);
+ zone = vsm_lookup_zone_by_name(container, multi_user);
+ if (zone == NULL) {
+ EM_DEBUG_EXCEPTION("NULL returned : %s, %d", EM_STRERROR(errno_buf), errno);
+ err = EMAIL_ERROR_CONTAINER_GET_DOMAIN;
+ goto FINISH_OFF;
+ }
+
+ p_container_path = (char *)vsm_get_zone_rootpath(zone);
+
+FINISH_OFF:
+
+ if (container_path)
+ *container_path = EM_SAFE_STRDUP(p_container_path);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+INTERNAL_FUNC int emcore_get_user_name(int pid, char **multi_user)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMAIL_ERROR_NONE;
+
+ if (pid <= 0) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return EMAIL_ERROR_INVALID_PARAM;
+ }
+
+ if (container_status == CONTAINER_DISABLE) {
+ EM_DEBUG_LOG("Single container");
+ return err;
+ }
+
+ if (container == NULL) {
+ EM_DEBUG_LOG("Container not intialize");
+ return EMAIL_ERROR_CONTAINER_NOT_INITIALIZATION;
+ }
+
+ char *user_name = NULL;
+ vsm_zone_h zone = NULL;
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
+
+ EM_DEBUG_LOG("pid : [%d], container : [%p]", pid, container);
+ zone = vsm_lookup_zone_by_pid(container, pid);
+ if (zone == NULL) {
+ EM_DEBUG_EXCEPTION("NULL returned : %s, %d", EM_STRERROR(errno_buf), errno);
+ err = EMAIL_ERROR_CONTAINER_GET_DOMAIN;
+ goto FINISH_OFF;
+ }
+
+ user_name = (char *)vsm_get_zone_name(zone);
+ EM_DEBUG_LOG("user_name : [%s]", user_name);
+
+FINISH_OFF:
+
+ if (multi_user)
+ *multi_user = EM_SAFE_STRDUP(user_name);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+INTERNAL_FUNC int emcore_lookup_zone_by_name(char *user_name)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int ret = false;
+
+ if (EM_SAFE_STRLEN(user_name) == 0) {
+ EM_DEBUG_LOG("user_name is NULL");
+ return ret;
+ }
+
+ if (container_status == CONTAINER_DISABLE) {
+ EM_DEBUG_LOG("Single container");
+ return true;
+ }
+
+ if (container == NULL) {
+ EM_DEBUG_LOG("Container not intialize");
+ return ret;
+ }
+
+ vsm_zone_h zone = NULL;
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
+
+ EM_DEBUG_LOG("name : [%s], container : [%p]", user_name, container);
+ zone = vsm_lookup_zone_by_name(container, user_name);
+ if (zone == NULL) {
+ EM_DEBUG_EXCEPTION("NULL returned : %s, %d", EM_STRERROR(errno_buf), errno);
+ goto FINISH_OFF;
+ }
+
+ ret = true;
+
+FINISH_OFF:
+
+ EM_DEBUG_FUNC_END();
+ return ret;
+}
+
+INTERNAL_FUNC void emcore_set_declare_link(const char *file_path)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ if (container_status == CONTAINER_DISABLE) {
+ EM_DEBUG_LOG("Single container");
+ return;
+ }
+
+ if (container == NULL) {
+ EM_DEBUG_EXCEPTION("Not initialize");
+ return;
+ }
+
+ int ret = 0;
+ if ((ret = vsm_declare_link(container, file_path /* src path */, file_path /* dst path */)) != 0) {
+ EM_DEBUG_EXCEPTION("vsm_declare_link failed : [%s] [%d]", file_path, ret);
+ }
+
+ EM_DEBUG_FUNC_END();
+}
+
+void iterate_callback(vsm_zone_h zone, void *user_data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ char *zone_name = NULL;
+ GList *zone_name_list = (GList *)user_data;
+
+ zone_name = EM_SAFE_STRDUP(vsm_get_zone_name(zone));
+ if (EM_SAFE_STRLEN(zone_name) > 0)
+ zone_name_list = g_list_append(zone_name_list, zone_name);
+
+ EM_DEBUG_FUNC_END();
+}
+
+INTERNAL_FUNC int emcore_get_zone_name_list(GList **output_name_list)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ int ret = 0;
+ GList *zone_name_list = NULL;
+ GList *node = NULL;
+
+ if (output_name_list == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if (container_status == CONTAINER_DISABLE) {
+ EM_DEBUG_LOG("Single container");
+ goto FINISH_OFF;
+ }
+
+ if (container == NULL) {
+ EM_DEBUG_EXCEPTION("Not initialize");
+ err = EMAIL_ERROR_CONTAINER_CREATE_FAILED;
+ goto FINISH_OFF;
+ }
+
+ zone_name_list = g_list_alloc();
+ if (zone_name_list == NULL) {
+ EM_DEBUG_EXCEPTION("g_list_alloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if ((ret = vsm_iterate_zone(container, iterate_callback, (void *)zone_name_list)) < 0) {
+ EM_DEBUG_EXCEPTION("vsm_iterate_domain failed : [%d]", ret);
+ err = EMAIL_ERROR_CONTAINER_ITERATE_DOMAIN;
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ if (err != EMAIL_ERROR_NONE) {
+ node = g_list_first(zone_name_list);
+ while (node != NULL) {
+ /* Free the domain name */
+ EM_SAFE_FREE(node->data);
+ node = g_list_next(node);
+ }
+ g_list_free(zone_name_list);
+ zone_name_list = NULL;
+ }
+
+ if (output_name_list)
+ *output_name_list = zone_name_list;
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+INTERNAL_FUNC int emcore_get_canonicalize_path(char *db_path, char **output_path)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+
+ int ret = 0;
+ ret = vsm_canonicalize_path(db_path, output_path);
+ if (ret < 0) {
+ EM_DEBUG_EXCEPTION("vsm_canonicalize_path failed : [%d]", ret);
+ err = EMAIL_ERROR_FILE_NOT_FOUND;
+ }
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+INTERNAL_FUNC int emcore_set_join_zone(char *multi_user_name, void **join_zone)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
+ vsm_zone_h temp_zone = NULL;
+ vsm_zone_h p_join_zone = NULL;
+
+ if (container_status == CONTAINER_DISABLE) {
+ EM_DEBUG_LOG("Single container");
+ goto FINISH_OFF;
+ }
+
+ if (container == NULL) {
+ EM_DEBUG_EXCEPTION("Not initialize");
+ err = EMAIL_ERROR_CONTAINER_CREATE_FAILED;
+ goto FINISH_OFF;
+ }
+
+ if (EM_SAFE_STRLEN(multi_user_name) == 0) {
+ EM_DEBUG_LOG("multi_user_name is NULL");
+ return err;
+ }
+
+ temp_zone = vsm_lookup_zone_by_name(container, multi_user_name);
+ if (temp_zone == NULL) {
+ EM_DEBUG_EXCEPTION("NULL returned : %s %d", EM_STRERROR(errno_buf), errno);
+ err = EMAIL_ERROR_CONTAINER_LOOKUP_ZONE_FAILED;
+ goto FINISH_OFF;
+ }
+
+ p_join_zone = vsm_join_zone(temp_zone);
+ if (p_join_zone == NULL) {
+ EM_DEBUG_EXCEPTION("NULL returned : %s %d", EM_STRERROR(errno_buf), errno);
+ err = EMAIL_ERROR_CONTAINER_JOIN_ZONE_FAILED;
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ if (join_zone)
+ *join_zone = (void *)p_join_zone;
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+INTERNAL_FUNC void emcore_unset_join_zone(void *join_zone)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
+ vsm_zone_h temp_zone = NULL;
+
+ temp_zone = vsm_join_zone((vsm_zone_h)join_zone);
+ if (temp_zone == NULL) {
+ EM_DEBUG_EXCEPTION("NULL returned : %s %d", EM_STRERROR(errno_buf), errno);
+ }
+
+ EM_DEBUG_FUNC_END();
+}
diff --git a/email-core/email-core-event.c b/email-core/email-core-event.c
index f40374e..de6a63f 100755
--- a/email-core/email-core-event.c
+++ b/email-core/email-core-event.c
@@ -160,67 +160,72 @@ static void fail_status_notify(email_event_t *event_data, int error)
case EMAIL_EVENT_SEND_MAIL:
/* case EMAIL_EVENT_SEND_MAIL_SAVED: */
/* emcore_execute_event_callback(EMAIL_ACTION_SEND_MAIL, 0, 0, EMAIL_SEND_FAIL, account_id, mail_id, -1, error); */
- emcore_show_user_message(mail_id, EMAIL_ACTION_SEND_MAIL, error);
+ emcore_show_user_message(event_data->multi_user_name, mail_id, EMAIL_ACTION_SEND_MAIL, error);
break;
case EMAIL_EVENT_SYNC_HEADER:
emcore_execute_event_callback(EMAIL_ACTION_SYNC_HEADER, 0, 0, EMAIL_LIST_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_SYNC_HEADER, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_SYNC_HEADER, error);
break;
case EMAIL_EVENT_DOWNLOAD_BODY:
emcore_execute_event_callback(EMAIL_ACTION_DOWNLOAD_BODY, 0, 0, EMAIL_DOWNLOAD_FAIL, account_id, mail_id, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_DOWNLOAD_BODY, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_DOWNLOAD_BODY, error);
break;
case EMAIL_EVENT_DOWNLOAD_ATTACHMENT:
emcore_execute_event_callback(EMAIL_ACTION_DOWNLOAD_ATTACHMENT, 0, 0, EMAIL_DOWNLOAD_FAIL, account_id, mail_id, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_DOWNLOAD_ATTACHMENT, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_DOWNLOAD_ATTACHMENT, error);
break;
case EMAIL_EVENT_DELETE_MAIL:
case EMAIL_EVENT_DELETE_MAIL_ALL:
emcore_execute_event_callback(EMAIL_ACTION_DELETE_MAIL, 0, 0, EMAIL_DELETE_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_DELETE_MAIL, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_DELETE_MAIL, error);
break;
case EMAIL_EVENT_VALIDATE_ACCOUNT:
emcore_execute_event_callback(EMAIL_ACTION_VALIDATE_ACCOUNT, 0, 0, EMAIL_VALIDATE_ACCOUNT_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_VALIDATE_ACCOUNT, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_VALIDATE_ACCOUNT, error);
break;
case EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT:
emcore_execute_event_callback(EMAIL_ACTION_VALIDATE_AND_CREATE_ACCOUNT, 0, 0, EMAIL_VALIDATE_ACCOUNT_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_VALIDATE_AND_CREATE_ACCOUNT, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_VALIDATE_AND_CREATE_ACCOUNT, error);
break;
case EMAIL_EVENT_VALIDATE_ACCOUNT_EX:
emcore_execute_event_callback(EMAIL_ACTION_VALIDATE_ACCOUNT_EX, 0, 0, EMAIL_VALIDATE_ACCOUNT_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_VALIDATE_ACCOUNT_EX, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_VALIDATE_ACCOUNT_EX, error);
break;
case EMAIL_EVENT_CREATE_MAILBOX:
emcore_execute_event_callback(EMAIL_ACTION_CREATE_MAILBOX, 0, 0, EMAIL_LIST_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_CREATE_MAILBOX, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_CREATE_MAILBOX, error);
break;
case EMAIL_EVENT_DELETE_MAILBOX:
emcore_execute_event_callback(EMAIL_ACTION_DELETE_MAILBOX, 0, 0, EMAIL_LIST_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_DELETE_MAILBOX, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_DELETE_MAILBOX, error);
break;
case EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT:
emcore_execute_event_callback(EMAIL_ACTION_VALIDATE_AND_UPDATE_ACCOUNT, 0, 0, EMAIL_VALIDATE_ACCOUNT_FAIL, account_id, 0, -1, error);
- emcore_show_user_message(account_id, EMAIL_ACTION_VALIDATE_AND_UPDATE_ACCOUNT, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_VALIDATE_AND_UPDATE_ACCOUNT, error);
break;
case EMAIL_EVENT_SET_MAIL_SLOT_SIZE:
emcore_execute_event_callback(EMAIL_ACTION_SET_MAIL_SLOT_SIZE, 0, 0, EMAIL_SET_SLOT_SIZE_FAIL, account_id, 0, -1, EMAIL_ERROR_NONE);
break;
+ case EMAIL_EVENT_SEARCH_ON_SERVER:
+ emcore_execute_event_callback(EMAIL_ACTION_SEARCH_ON_SERVER, 0, 0, EMAIL_SEARCH_ON_SERVER_FAIL, account_id, 0, -1, EMAIL_ERROR_NONE);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_SEARCH_ON_SERVER, error);
+ break;
+
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
emcore_execute_event_callback(EMAIL_ACTION_MOVE_MAILBOX, 0, 0, EMAIL_MOVE_MAILBOX_ON_IMAP_SERVER_FAIL, account_id, 0, -1, EMAIL_ERROR_NONE);
- emcore_show_user_message(account_id, EMAIL_ACTION_SEARCH_ON_SERVER, error);
+ emcore_show_user_message(event_data->multi_user_name, account_id, EMAIL_ACTION_SEARCH_ON_SERVER, error);
break;
case EMAIL_EVENT_UPDATE_MAIL:
@@ -400,6 +405,12 @@ INTERNAL_FUNC int emcore_insert_event(email_event_t *event_data, int *handle, in
WAKE_CONDITION_VARIABLE(_event_available_signal);
ret = true;
}
+ else {
+ EM_DEBUG_EXCEPTION("event queue is full...");
+ error = EMAIL_ERROR_EVENT_QUEUE_FULL;
+ ret = false;
+ }
+
}
LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
@@ -424,6 +435,7 @@ INTERNAL_FUNC int emcore_insert_event(email_event_t *event_data, int *handle, in
case EMAIL_EVENT_SET_MAIL_SLOT_SIZE:
case EMAIL_EVENT_UPDATE_MAIL:
case EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED:
+ case EMAIL_EVENT_SEARCH_ON_SERVER:
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
break;
@@ -432,6 +444,7 @@ INTERNAL_FUNC int emcore_insert_event(email_event_t *event_data, int *handle, in
{
int is_local_activity_event_inserted = false;
emcore_partial_body_thd_local_activity_sync (
+ event_data->multi_user_name,
&is_local_activity_event_inserted,
&error);
if (error != EMAIL_ERROR_NONE) {
@@ -583,12 +596,12 @@ INTERNAL_FUNC void emcore_get_sync_fail_event_data(email_event_t **event_data)
new_event->event_param_data_3 = EM_SAFE_STRDUP(sync_failed_event_data->event_param_data_3);
new_event->event_param_data_4 = sync_failed_event_data->event_param_data_4;
new_event->event_param_data_5 = sync_failed_event_data->event_param_data_5;
+ new_event->multi_user_name = EM_SAFE_STRDUP(sync_failed_event_data->multi_user_name);
*event_data = new_event;
emcore_free_event(sync_failed_event_data);
EM_SAFE_FREE(sync_failed_event_data);
- sync_failed_event_data = NULL;
}
INTERNAL_FUNC int emcore_insert_event_for_sending_mails(email_event_t *event_data, int *handle, int *err_code)
@@ -809,6 +822,7 @@ case EMAIL_EVENT_UPDATE_MAIL:
case EMAIL_EVENT_SET_MAIL_SLOT_SIZE:
case EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED:
case EMAIL_EVENT_LOCAL_ACTIVITY:
+case EMAIL_EVENT_SEARCH_ON_SERVER:
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
case EMAIL_EVENT_QUERY_SMTP_MAIL_SIZE_LIMIT:
*/
@@ -922,6 +936,7 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code)
case EMAIL_EVENT_CREATE_MAILBOX:
case EMAIL_EVENT_DELETE_MAILBOX:
case EMAIL_EVENT_SET_MAIL_SLOT_SIZE:
+ case EMAIL_EVENT_SEARCH_ON_SERVER:
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
EM_DEBUG_LOG("EMAIL_EVENT_DELETE_MAIL, EMAIL_EVENT_SYNC_IMAP_MAILBOX");
break;
@@ -946,7 +961,7 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code)
EM_DEBUG_LOG("EMAIL_EVENT_SYNC_HEADER");
if (!emcore_notify_network_event(NOTI_DOWNLOAD_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, err))
EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_CANCEL] Failed >>>>");
- if ((err = emcore_update_sync_status_of_account(found_elm->account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(found_elm->multi_user_name, found_elm->account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
break;
@@ -1033,6 +1048,7 @@ INTERNAL_FUNC int emcore_cancel_all_thread(int *err_code)
case EMAIL_EVENT_CREATE_MAILBOX:
case EMAIL_EVENT_DELETE_MAILBOX:
case EMAIL_EVENT_SET_MAIL_SLOT_SIZE:
+ case EMAIL_EVENT_SEARCH_ON_SERVER:
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
EM_DEBUG_LOG("EMAIL_EVENT_DELETE_MAIL, EMAIL_EVENT_SYNC_IMAP_MAILBOX");
break;
@@ -1053,7 +1069,7 @@ INTERNAL_FUNC int emcore_cancel_all_thread(int *err_code)
}
else {
- pop_elm->status = EMAIL_EVENT_STATUS_CANCELED;
+ if (pop_elm) pop_elm->status = EMAIL_EVENT_STATUS_CANCELED;
}
}
LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
@@ -1100,7 +1116,7 @@ INTERNAL_FUNC int emcore_check_send_mail_thread_status(void)
return ret;
}
-INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id)
+INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(char *multi_user_name, int account_id)
{
EM_DEBUG_FUNC_BEGIN();
int error_code = EMAIL_ERROR_NONE;
@@ -1116,7 +1132,9 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id)
for (i = 0; i < q_length; i++) {
found_elm = (email_event_t *)g_queue_peek_nth(g_event_que, i);
- if (found_elm && (found_elm->account_id == account_id || found_elm->account_id == ALL_ACCOUNT)) {
+ if (found_elm && (found_elm->account_id == account_id || found_elm->account_id == ALL_ACCOUNT) &&
+ ((!found_elm->multi_user_name && !multi_user_name) || (
+ (multi_user_name) && !EM_SAFE_STRCASECMP(found_elm->multi_user_name, multi_user_name)))) {
EM_DEBUG_LOG("Found Queue element[%d]", i);
if (found_elm->status == EMAIL_EVENT_STATUS_WAIT) {
@@ -1127,13 +1145,15 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id)
case EMAIL_EVENT_SEND_MAIL:
case EMAIL_EVENT_SEND_MAIL_SAVED:
EM_DEBUG_LOG("EMAIL_EVENT_SEND_MAIL or EMAIL_EVENT_SEND_MAIL_SAVED");
- if (!emcore_notify_network_event(NOTI_SEND_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, error_code))
+ if (!emcore_notify_network_event(NOTI_SEND_CANCEL, found_elm->account_id, NULL ,
+ found_elm->event_param_data_4, error_code))
EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>>");
break;
case EMAIL_EVENT_DOWNLOAD_BODY:
EM_DEBUG_LOG("EMAIL_EVENT_DOWNLOAD_BODY");
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, error_code))
+ if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_CANCEL, found_elm->account_id, NULL,
+ found_elm->event_param_data_4, error_code))
EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>>");
break;
@@ -1159,6 +1179,7 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id)
case EMAIL_EVENT_CREATE_MAILBOX:
case EMAIL_EVENT_DELETE_MAILBOX:
case EMAIL_EVENT_SET_MAIL_SLOT_SIZE:
+ case EMAIL_EVENT_SEARCH_ON_SERVER:
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
EM_DEBUG_LOG("EMAIL_EVENT_DELETE_MAIL, EMAIL_EVENT_SYNC_IMAP_MAILBOX");
break;
@@ -1303,7 +1324,7 @@ INTERNAL_FUNC int emcore_cancel_all_send_mail_thread(int *err_code)
q_length = g_queue_get_length(g_send_event_que);
} else {
- pop_elm->status = EMAIL_EVENT_STATUS_CANCELED;
+ if (pop_elm) pop_elm->status = EMAIL_EVENT_STATUS_CANCELED;
}
}
LEAVE_RECURSIVE_CRITICAL_SECTION(_send_event_queue_lock);
@@ -1462,6 +1483,37 @@ INTERNAL_FUNC int emcore_free_event(email_event_t *event_data)
break;
#endif /* __FEATURE_LOCAL_ACTIVITY__*/
+ case EMAIL_EVENT_SEARCH_ON_SERVER: {
+ int i = 0;
+ int search_filter_count = event_data->event_param_data_5;
+ email_search_filter_t *search_filter = (email_search_filter_t *)event_data->event_param_data_1;
+
+ if (event_data->event_param_data_1) {
+ for(i = 0; i < search_filter_count; i++) {
+ switch(search_filter[i].search_filter_type) {
+ case EMAIL_SEARCH_FILTER_TYPE_BCC :
+ case EMAIL_SEARCH_FILTER_TYPE_BODY :
+ case EMAIL_SEARCH_FILTER_TYPE_CC :
+ case EMAIL_SEARCH_FILTER_TYPE_FROM :
+ case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
+ case EMAIL_SEARCH_FILTER_TYPE_TEXT :
+ case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
+ case EMAIL_SEARCH_FILTER_TYPE_TO :
+ case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
+ case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
+ EM_SAFE_FREE(search_filter[i].search_filter_key_value.string_type_key_value);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ EM_SAFE_FREE(event_data->event_param_data_1);
+ break;
+
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
EM_SAFE_FREE(event_data->event_param_data_1);
EM_SAFE_FREE(event_data->event_param_data_2);
@@ -1488,6 +1540,7 @@ INTERNAL_FUNC int emcore_free_event(email_event_t *event_data)
EM_DEBUG_EXCEPTION("event %d is NOT freed, possibly memory leaks", event_data->type);
}
+ EM_SAFE_FREE(event_data->multi_user_name);
event_data->event_param_data_1 = event_data->event_param_data_2 = event_data->event_param_data_3 = NULL;
EM_DEBUG_FUNC_END();
@@ -1776,7 +1829,7 @@ static int emcore_copy_partial_body_thd_event(email_event_partial_body_thd *src,
dest->mailbox_name = EM_SAFE_STRDUP(src->mailbox_name);
dest->activity_type = src->activity_type;
dest->event_type = src->event_type;
-
+ dest->multi_user_name = EM_SAFE_STRDUP(src->multi_user_name);
ret = true;
@@ -1816,6 +1869,7 @@ INTERNAL_FUNC int emcore_free_partial_body_thd_event(email_event_partial_body_th
/*Free character pointers in event_data cell */
EM_SAFE_FREE(pbd_event->mailbox_name);
+ EM_SAFE_FREE(pbd_event->multi_user_name);
memset(pbd_event, 0x00, sizeof(email_event_partial_body_thd));
EM_DEBUG_FUNC_END();
return true;
@@ -1951,7 +2005,7 @@ INTERNAL_FUNC int emcore_retrieve_partial_body_thread_event(email_event_partial_
}
/*Function to flush the bulk partial body download queue [santosh.br@samsung.com]*/
-static int emcore_partial_body_bulk_flush(int *error_code)
+static int emcore_partial_body_bulk_flush(char *multi_user_name, int *error_code)
{
EM_DEBUG_FUNC_BEGIN();
int error = EMAIL_ERROR_NONE;
@@ -1959,7 +2013,7 @@ static int emcore_partial_body_bulk_flush(int *error_code)
MAILSTREAM *stream = NULL;
void *tmp_stream = NULL;
- if (!emcore_connect_to_remote_mailbox(g_partial_body_bulk_dwd_que[0].account_id, g_partial_body_bulk_dwd_que[0].mailbox_id, (void **)&tmp_stream, &error) || (NULL == tmp_stream)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, g_partial_body_bulk_dwd_que[0].account_id, g_partial_body_bulk_dwd_que[0].mailbox_id, (void **)&tmp_stream, &error) || (NULL == tmp_stream)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", error);
goto FINISH_OFF;
}
@@ -2020,7 +2074,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
EM_DEBUG_LOG("Event is for the same mailbox and same account as the already present events in download que");
EM_DEBUG_LOG("Check if the download que reached its limit. If yes then first flush the que.");
if (g_partial_body_bulk_dwd_next_event_idx == BULK_PARTIAL_BODY_DOWNLOAD_COUNT) {
- if (false == emcore_partial_body_bulk_flush(&error)) {
+ if (false == emcore_partial_body_bulk_flush(pbd_event->multi_user_name, &error)) {
EM_DEBUG_EXCEPTION("Partial Body thread emcore_partial_body_bulk_flush failed - %d", error);
goto FINISH_OFF;
}
@@ -2031,7 +2085,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
EM_DEBUG_LOG("Flush the current que if not empty");
EM_DEBUG_LOG("g_partial_body_bulk_dwd_queue_empty [%d]", g_partial_body_bulk_dwd_queue_empty);
if (!g_partial_body_bulk_dwd_queue_empty) {
- if (false == emcore_partial_body_bulk_flush(&error)) {
+ if (false == emcore_partial_body_bulk_flush(pbd_event->multi_user_name, &error)) {
EM_DEBUG_EXCEPTION("Partial Body thread emcore_partial_body_bulk_flush failed - %d", error);
goto FINISH_OFF;
}
@@ -2053,7 +2107,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
EM_DEBUG_LOG("Event is coming from local activity.");
/* Get all the accounts for which local activities are pending */
- if (false == emstorage_get_pbd_account_list(&account_list, &account_count, false, &error)) {
+ if (false == emstorage_get_pbd_account_list(pbd_event->multi_user_name, &account_list, &account_count, false, &error)) {
EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_list failed.. [%d]", error);
error = EMAIL_ERROR_MAILBOX_NOT_FOUND;
goto FINISH_OFF;
@@ -2061,7 +2115,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
for (m = 0; m < account_count; ++m) {
/* Get the mailbox list for the account to start bulk partial body fetch for mails in each mailbox of accounts one by one*/
- if (false == emstorage_get_pbd_mailbox_list(account_list[m], &mailbox_list, &count, false, &error)) {
+ if (false == emstorage_get_pbd_mailbox_list(pbd_event->multi_user_name, account_list[m], &mailbox_list, &count, false, &error)) {
EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_list failed.. [%d]", error);
error = EMAIL_ERROR_MAILBOX_NOT_FOUND;
goto FINISH_OFF;
@@ -2071,17 +2125,17 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
int k = 0;
int activity_count = 0;
- if (!emcore_connect_to_remote_mailbox(account_list[m], mailbox_list[i], (void **)&stream, &error)) {
+ if (!emcore_connect_to_remote_mailbox(pbd_event->multi_user_name, account_list[m], mailbox_list[i], (void **)&stream, &error)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", error);
stream = mail_close (stream);
goto FINISH_OFF;
}
- if (false == emstorage_get_pbd_activity_data(account_list[m], mailbox_list[i], &activity_data_list, &activity_count, false, &error))
+ if (false == emstorage_get_pbd_activity_data(pbd_event->multi_user_name, account_list[m], mailbox_list[i], &activity_data_list, &activity_count, false, &error))
EM_DEBUG_EXCEPTION(" emstorage_get_pbd_activity_data failed.. [%d]", error);
/* it is duplicated with emstorage_get_pbd_activity_data
- if (false == emstorage_get_mailbox_pbd_activity_count(account_list[m], mailbox_list[i], &activity_count, false, &error)) {
+ if (false == emstorage_get_mailbox_pbd_activity_count(pbd_evnet->multi_user_name, account_list[m], mailbox_list[i], &activity_count, false, &error)) {
EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_pbd_activity_count failed.. [%d]", error);
continue;
}
@@ -2095,7 +2149,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
int index = 0;
/*
- if (false == emstorage_get_pbd_activity_data(account_list[j], mailbox_list[i], &activity_data_list, &num_activity, false, &error))
+ if (false == emstorage_get_pbd_activity_data(pbd_event->multi_user_name, account_list[j], mailbox_list[i], &activity_data_list, &num_activity, false, &error))
EM_DEBUG_EXCEPTION(" emstorage_get_pbd_activity_data failed.. [%d]", error);
if (NULL == activity_data_list) {
@@ -2126,6 +2180,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
for (k = 0; k < activity_count; k++)
emcore_free_partial_body_thd_event(activity_data_list + k, &error);
+
EM_SAFE_FREE(activity_data_list);
/*check: empty check required?*/
@@ -2150,7 +2205,8 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
ret = true;
goto FINISH_OFF; /* Stop Local Activity Sync */
}
- if (false == emcore_partial_body_bulk_flush(&error)) {
+
+ if (false == emcore_partial_body_bulk_flush(pbd_event->multi_user_name, &error)) {
EM_DEBUG_EXCEPTION("\t Partial Body thread emcore_partial_body_bulk_flush failed - %d", error);
goto FINISH_OFF;
}
diff --git a/email-core/email-core-gmime.c b/email-core/email-core-gmime.c
index e4d885d..ebf2f97 100755
--- a/email-core/email-core-gmime.c
+++ b/email-core/email-core-gmime.c
@@ -63,6 +63,10 @@ INTERNAL_FUNC void emcore_gmime_init(void)
#endif
g_mime_init(0);
+#ifdef __FEATURE_SECURE_PGP__
+ setenv("GNUPGHOME", "/opt/usr/apps/org.tizen.email/data/.gnupg", 1);
+#endif
+
EM_DEBUG_FUNC_END();
}
@@ -172,7 +176,10 @@ INTERNAL_FUNC int emcore_gmime_pop3_parse_mime(char *eml_path, struct _m_content
}
-INTERNAL_FUNC int emcore_gmime_eml_parse_mime(char *eml_path, struct _rfc822header *rfc822_header, struct _m_content_info *cnt_info, int *err_code)
+INTERNAL_FUNC int emcore_gmime_eml_parse_mime(char *eml_path,
+ struct _rfc822header *rfc822_header,
+ struct _m_content_info *cnt_info,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN("cnt_info[%p], err_code[%p]", cnt_info, err_code);
EM_DEBUG_LOG_SEC("eml_path[%s]", eml_path);
@@ -372,6 +379,9 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
EM_DEBUG_LOG("Multi Part Count:%d", multi_count);
EM_DEBUG_LOG("Boundary:%s\n\n", g_mime_multipart_get_boundary(multi_part));
+ if (GMIME_IS_MULTIPART_SIGNED(part))
+ cnt_info->text.mime_entity = emcore_gmime_get_mime_entity_signed_message(part);
+
} else if (GMIME_IS_PART(part)) {
EM_DEBUG_LOG("Part");
int content_size = 0;
@@ -482,44 +492,20 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
/*Figure out TEXT or ATTACHMENT(INLINE) ?*/
int result = false;
- if (disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) {
+ if (content_id && (emcore_search_string_from_file(cnt_info->text.html, content_id, NULL, &result) == EMAIL_ERROR_NONE && result)) {
+ content_disposition_type = INLINE_ATTACHMENT;
+ EM_DEBUG_LOG("INLINE_ATTACHMENT");
+ } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || disposition_filename || ctype_name) {
+ content_disposition_type = ATTACHMENT;
+ EM_DEBUG_LOG("ATTACHMENT");
+ } else if (ctype_subtype && g_ascii_strcasecmp(ctype_subtype, "delivery-status") == 0) {
+ content_disposition_type = ATTACHMENT;
+ EM_DEBUG_LOG("ATTACHMENT");
+ } else if (ctype_subtype && g_ascii_strcasecmp(ctype_subtype, "calendar") == 0) {
content_disposition_type = ATTACHMENT;
EM_DEBUG_LOG("ATTACHMENT");
- } else if ((content_id || content_location) && (ctype_name || disposition_filename)) {
- if (cnt_info->attachment_only) {
- content_disposition_type = ATTACHMENT;
- EM_DEBUG_LOG("ATTACHMENT");
- } else {
- content_disposition_type = INLINE_ATTACHMENT;
- EM_DEBUG_LOG("INLINE_ATTACHMENT");
- }
} else {
- if (content_id &&
- (emcore_search_string_from_file(cnt_info->text.html, content_id, NULL, &result) == EMAIL_ERROR_NONE && result)) {
- content_disposition_type = INLINE_ATTACHMENT;
- EM_DEBUG_LOG("INLINE_ATTACHMENT");
- } else if (content_id || content_location) {
- if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
- EM_DEBUG_LOG("TEXT");
- } else {
- if (cnt_info->attachment_only) {
- content_disposition_type = ATTACHMENT;
- EM_DEBUG_LOG("ATTACHMENT");
- } else {
- content_disposition_type = INLINE_ATTACHMENT;
- EM_DEBUG_LOG("INLINE_ATTACHMENT");
- }
- }
- } else {
- if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
- EM_DEBUG_LOG("TEXT");
- } else {
- content_disposition_type = ATTACHMENT;
- EM_DEBUG_LOG("ATTACHMENT");
- }
- }
+ EM_DEBUG_LOG("Not INLINE or ATTACHMENT");
}
if (content_disposition_type != ATTACHMENT && content_disposition_type != INLINE_ATTACHMENT) {
@@ -681,7 +667,6 @@ FINISH_OFF:
EM_DEBUG_FUNC_END();
}
-
static int emcore_gmime_parse_mime_header(GMimeMessage *message, struct _rfc822header *rfc822_header)
{
EM_DEBUG_FUNC_BEGIN("message[%p], rfc822header[%p]", message, rfc822_header);
@@ -696,7 +681,7 @@ static int emcore_gmime_parse_mime_header(GMimeMessage *message, struct _rfc822h
rfc822_header->reply_to = EM_SAFE_STRDUP(g_mime_message_get_reply_to(message));
EM_DEBUG_LOG_SEC("reply_to : [%s]", rfc822_header->reply_to);
- rfc822_header->date = g_mime_message_get_date_as_string(message); //PREVENT
+ rfc822_header->date = EM_SAFE_STRDUP(g_mime_message_get_date_as_string(message));
EM_DEBUG_LOG_SEC("date : [%s]", rfc822_header->date);
rfc822_header->subject = EM_SAFE_STRDUP(g_mime_message_get_subject(message));
@@ -794,8 +779,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
if (msg_disposition) {
msg_disposition_str = (char *)g_mime_content_disposition_get_disposition(msg_disposition);
msg_disposition_filename = (char *)g_mime_content_disposition_get_parameter(msg_disposition, "filename");
- if (EM_SAFE_STRLEN(msg_disposition_filename) == 0)
- msg_disposition_filename = NULL;
+ if (EM_SAFE_STRLEN(msg_disposition_filename) == 0) msg_disposition_filename = NULL;
}
EM_DEBUG_LOG("RFC822/Message Disposition[%s]", msg_disposition_str);
EM_DEBUG_LOG_SEC("RFC822/Message Disposition-Filename[%s]", msg_disposition_filename);
@@ -924,6 +908,9 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
EM_DEBUG_LOG("Multi Part Count:%d", multi_count);
EM_DEBUG_LOG("Boundary:%s\n\n", g_mime_multipart_get_boundary(multi_part));
+ if (GMIME_IS_MULTIPART_SIGNED(part))
+ cnt_info->text.mime_entity = emcore_gmime_get_mime_entity_signed_message(part);
+
} else if (GMIME_IS_PART(part)) {
EM_DEBUG_LOG("Part");
int content_size = 0;
@@ -1182,21 +1169,21 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
EM_DEBUG_EXCEPTION("emcore_get_content_from_file failed");
}
- EM_DEBUG_LOG_SEC("html_charset : [%s]", cnt_info->text.html_charset);
- if (strcasecmp(cnt_info->text.html_charset, "UTF-8") != 0) {
- cd = g_mime_iconv_open(cnt_info->text.html_charset, "UTF-8");
- if (cd) {
- encoding_file_name = g_mime_iconv_strdup(cd, file->name);
- }
+ EM_DEBUG_LOG_SEC("html_charset : [%s]", cnt_info->text.html_charset);
+ if (strcasecmp(cnt_info->text.html_charset, "UTF-8") != 0) {
+ cd = g_mime_iconv_open(cnt_info->text.html_charset, "UTF-8");
+ if (cd) {
+ encoding_file_name = g_mime_iconv_strdup(cd, file->name);
+ }
- if (cd)
- g_mime_iconv_close(cd);
+ if (cd)
+ g_mime_iconv_close(cd);
- } else {
- encoding_file_name = g_strdup(file->name);
- }
+ } else {
+ encoding_file_name = g_strdup(file->name);
+ }
- EM_DEBUG_LOG_SEC("File name : [%s], encoding file name : [%s]", file->name, encoding_file_name);
+ EM_DEBUG_LOG_SEC("File name : [%s], encoding file name : [%s]", file->name, encoding_file_name);
if (file_content && html_size > 0) {
em_replace_string_ex(&file_content, "cid:", "");
@@ -1209,7 +1196,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
}
g_free(file_content); /* prevent 39110 */
- g_free(encoding_file_name);
+ g_free(encoding_file_name);
}
if(ctype_type && ctype_subtype) {
@@ -1381,7 +1368,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
int multi_count = g_mime_multipart_get_count(multi_part);
EM_DEBUG_LOG("Multi Part Count:%d", multi_count);
- EM_DEBUG_LOG("Boundary:%s\n\n", g_mime_multipart_get_boundary(multi_part));
+ EM_DEBUG_LOG("Boundary:%s", g_mime_multipart_get_boundary(multi_part));
} else if (GMIME_IS_PART(part)) {
/* a normal leaf part, could be text/plain or
@@ -1451,14 +1438,16 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
/*Figure out TEXT or ATTACHMENT(INLINE) ?*/
int result = false;
if (disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) {
- if (content_id &&
- (emcore_search_string_from_file(cnt_info->text.html, content_id, NULL, &result) == EMAIL_ERROR_NONE && result)) {
+ if (content_id && (emcore_search_string_from_file(cnt_info->text.html,
+ content_id,
+ NULL,
+ &result) == EMAIL_ERROR_NONE && result)) {
content_disposition_type = INLINE_ATTACHMENT;
EM_DEBUG_LOG("INLINE_ATTACHMENT");
- } else {
- content_disposition_type = ATTACHMENT;
- EM_DEBUG_LOG("ATTACHMENT");
- }
+ } else {
+ content_disposition_type = ATTACHMENT;
+ EM_DEBUG_LOG("ATTACHMENT");
+ }
} else if ((content_id || content_location) && (ctype_name || disposition_filename)) {
if (cnt_info->attachment_only) {
content_disposition_type = ATTACHMENT;
@@ -1800,7 +1789,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
char *msg_tmp_content_path = NULL;
int real_size = 0;
- if (cnt_info->grab_type != (GRAB_TYPE_TEXT|GRAB_TYPE_ATTACHMENT) &&
+ if (cnt_info->grab_type != (GRAB_TYPE_TEXT | GRAB_TYPE_ATTACHMENT) &&
cnt_info->grab_type != GRAB_TYPE_ATTACHMENT) {
goto FINISH_OFF;
}
@@ -1900,6 +1889,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
int multi_count = g_mime_multipart_get_count(multi_part);
EM_DEBUG_LOG("Multi Part Count:%d", multi_count);
EM_DEBUG_LOG("Boundary:%s\n\n", g_mime_multipart_get_boundary(multi_part));
+
} else if (GMIME_IS_PART(part)) {
EM_DEBUG_LOG("Part");
int content_disposition_type = 0;
@@ -1968,8 +1958,10 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
EM_DEBUG_LOG("INLINE_ATTACHMENT");
}
} else {
- if (content_id &&
- (emcore_search_string_from_file(cnt_info->text.html, content_id, NULL, &result) == EMAIL_ERROR_NONE && result)) {
+ if (content_id && (emcore_search_string_from_file(cnt_info->text.html,
+ content_id,
+ NULL,
+ &result) == EMAIL_ERROR_NONE && result)) {
content_disposition_type = INLINE_ATTACHMENT;
EM_DEBUG_LOG("INLINE_ATTACHMENT");
} else if (content_id || content_location) {
@@ -1986,8 +1978,9 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
}
}
} else {
- if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
EM_DEBUG_LOG("TEXT");
} else {
content_disposition_type = ATTACHMENT;
@@ -2343,6 +2336,8 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_bodystructure_foreach_cb(GMimeObject
} else if (GMIME_IS_MESSAGE_PARTIAL(part)) {
EM_DEBUG_LOG("Partial Part");
//TODO
+ } else if (GMIME_IS_MULTIPART_SIGNED(part)) {
+ EM_DEBUG_LOG("Multi Part Signed");
} else if (GMIME_IS_MULTIPART(part)) {
EM_DEBUG_LOG("Multi Part");
GMimeMultipart *multi_part = NULL;
@@ -2426,7 +2421,8 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_bodystructure_foreach_cb(GMimeObject
} else {
if (content_id || content_location) {
if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
cnt_info->total_body_size += content_size;
EM_DEBUG_LOG("TEXT");
} else {
@@ -2442,7 +2438,8 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_bodystructure_foreach_cb(GMimeObject
}
} else {
if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
cnt_info->total_body_size += content_size;
EM_DEBUG_LOG("TEXT");
} else {
@@ -2490,7 +2487,9 @@ FINISH_OFF:
}
-INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent, GMimeObject *part, gpointer user_data)
+INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent,
+ GMimeObject *part,
+ gpointer user_data)
{
EM_DEBUG_FUNC_BEGIN("parent[%p], part[%p], user_data[%p]", parent, part, user_data);
@@ -2558,6 +2557,14 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
EM_DEBUG_LOG("sections <%s>", cnt_info->sections);
} else if (GMIME_IS_MESSAGE_PARTIAL(part)) {
EM_DEBUG_LOG("Partial Part");
+ } else if (GMIME_IS_MULTIPART_SIGNED(part)) {
+ EM_DEBUG_LOG("Multi Part Signed");
+ snprintf(sections, sizeof(sections), "BODY.PEEK[1.mime] BODY.PEEK[1]");
+
+ cnt_info->content_type = 1;
+ cnt_info->sections = EM_SAFE_STRDUP(sections);
+
+ EM_DEBUG_LOG("sections <%s>", cnt_info->sections);
} else if (GMIME_IS_MULTIPART(part)) {
EM_DEBUG_LOG("Multi Part");
} else if (GMIME_IS_PART(part)) {
@@ -2593,7 +2600,7 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
goto FINISH_OFF;
}
/*Content Type - END*/
-
+
/*Content Disposition*/
disposition = g_mime_object_get_content_disposition(mobject);
if (disposition) {
@@ -2628,7 +2635,8 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
} else {
if (content_id || content_location) {
if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
EM_DEBUG_LOG("TEXT");
} else {
if (cnt_info->attachment_only) {
@@ -2641,7 +2649,8 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
}
} else {
if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
EM_DEBUG_LOG("TEXT");
} else {
content_disposition_type = ATTACHMENT;
@@ -2658,8 +2667,13 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
}
else {
snprintf(sections, sizeof(sections), "BODY.PEEK[%s.MIME] BODY.PEEK[%s]", ctype_section, ctype_section);
-
+
if (cnt_info->sections) {
+ /* Signed message : Did not need sections */
+ if (cnt_info->content_type == 1) {
+ goto FINISH_OFF;
+ }
+
char *tmp_str = NULL;
tmp_str = g_strconcat(cnt_info->sections, " ", sections, NULL);
@@ -2682,7 +2696,9 @@ FINISH_OFF:
}
-INTERNAL_FUNC void emcore_gmime_get_attachment_section_foreach_cb(GMimeObject *parent, GMimeObject *part, gpointer user_data)
+INTERNAL_FUNC void emcore_gmime_get_attachment_section_foreach_cb(GMimeObject *parent,
+ GMimeObject *part,
+ gpointer user_data)
{
EM_DEBUG_FUNC_BEGIN("parent[%p], part[%p], user_data[%p]", parent, part, user_data);
@@ -2819,7 +2835,8 @@ INTERNAL_FUNC void emcore_gmime_get_attachment_section_foreach_cb(GMimeObject *p
} else {
if (content_id || content_location) {
if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
EM_DEBUG_LOG("TEXT");
} else {
if (cnt_info->attachment_only) {
@@ -2832,7 +2849,8 @@ INTERNAL_FUNC void emcore_gmime_get_attachment_section_foreach_cb(GMimeObject *p
}
} else {
if (g_ascii_strcasecmp(ctype_type, "text") == 0 &&
- (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
+ (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 ||
+ g_ascii_strcasecmp(ctype_subtype, "html") == 0)) {
EM_DEBUG_LOG("TEXT");
} else {
content_disposition_type = ATTACHMENT;
@@ -2868,7 +2886,7 @@ INTERNAL_FUNC void emcore_gmime_search_section_foreach_cb(GMimeObject *parent, G
search_section *search_info = (search_section *)user_data;
GMimeContentType *ctype = NULL;
- char buf[255] = {0};
+ char buf[255] = {0};
char *ctype_section = NULL;
if (!search_info) {
@@ -2900,23 +2918,47 @@ INTERNAL_FUNC void emcore_gmime_search_section_foreach_cb(GMimeObject *parent, G
goto FINISH_OFF;
}
- SNPRINTF(buf, sizeof(buf), "%s.MIME", ctype_section);
+ SNPRINTF(buf, sizeof(buf), "%s.MIME", ctype_section);
if (g_ascii_strcasecmp(ctype_section, search_info->section) == 0) {
EM_DEBUG_LOG("found section");
if (!(search_info->section_object)) search_info->section_object = part;
- } else if (g_ascii_strcasecmp(search_info->section, buf) == 0) {
- EM_DEBUG_LOG("Mime header");
- if (!(search_info->section_object)) search_info->section_object = part;
- }
+ } else if (g_ascii_strcasecmp(search_info->section, buf) == 0) {
+ EM_DEBUG_LOG("Mime header");
+ if (!(search_info->section_object)) search_info->section_object = part;
+ }
FINISH_OFF:
EM_DEBUG_FUNC_END();
}
+INTERNAL_FUNC void emcore_gmime_get_mime_entity_cb(GMimeObject *parent, GMimeObject *part, gpointer user_data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ struct _m_content_info *cnt_info = (struct _m_content_info *)user_data;
+
+ if (GMIME_IS_MESSAGE_PART(part)) {
+ EM_DEBUG_LOG("Message Part");
+ } else if (GMIME_IS_MESSAGE_PARTIAL(part)) {
+ EM_DEBUG_LOG("Partial Part");
+ } else if (GMIME_IS_MULTIPART_SIGNED(part)) {
+ EM_DEBUG_LOG("Multi Part Signed");
+ cnt_info->text.mime_entity = emcore_gmime_get_mime_entity_signed_message(part);
+ } else if (GMIME_IS_MULTIPART(part)) {
+ EM_DEBUG_LOG("Multi Part");
+ } else if (GMIME_IS_PART(part)) {
+ EM_DEBUG_LOG("Part");
+ }
+
+ EM_DEBUG_FUNC_END();
+}
+
INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
- BODY *body, const char *spec, int *total_mail_size)
+ BODY *body,
+ const char *spec,
+ int *total_mail_size)
{
EM_DEBUG_FUNC_BEGIN();
PART *part = NULL;
@@ -2959,8 +3001,8 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
if (EM_SAFE_STRLEN(subspec) > 2)
section = EM_SAFE_STRDUP(subspec+2);
- EM_DEBUG_LOG("constructing a %s/%s part (%s/%s)", body_types[part->body.type],
- part->body.subtype, subspec, section);
+ EM_DEBUG_LOG("constructing a %s/%s part (%s/%s)", body_types[part->body.type], part->body.subtype,
+ subspec, section);
if (part->body.type == TYPEMULTIPART) {
/*multipart*/
@@ -3069,7 +3111,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
if (part->body.parameter) {
PARAMETER *param = part->body.parameter;
while(param) {
- EM_DEBUG_LOG_SEC("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
+ EM_DEBUG_LOG("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
if (param->attribute || param->value)
g_mime_object_set_content_type_parameter(subpart, param->attribute, param->value);
param = param->next;
@@ -3130,7 +3172,9 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
}
INTERNAL_FUNC void emcore_gmime_construct_part (GMimePart *part,
- BODY *body, const char *spec, int *total_mail_size)
+ BODY *body,
+ const char *spec,
+ int *total_mail_size)
{
EM_DEBUG_FUNC_BEGIN();
GMimeObject *part_object = NULL;
@@ -3155,8 +3199,8 @@ INTERNAL_FUNC void emcore_gmime_construct_part (GMimePart *part,
ctype_subtype = (char *)g_mime_content_type_get_media_subtype(ctype);
/* Type-Subtype */
- if (g_strcmp0(ctype_type, "text") == 0 && g_strcmp0(ctype_subtype, "plain") == 0 &&
- body->type >= (unsigned int)0 && body->subtype) {
+ if (g_strcmp0(ctype_type, "text") == 0 && g_strcmp0(ctype_subtype, "plain") == 0
+ && body->subtype) {
GMimeContentType *content_type = NULL;
char *type = g_ascii_strdown(body_types[body->type], -1);
char *subtype = g_ascii_strdown(body->subtype, -1);
@@ -3268,18 +3312,20 @@ INTERNAL_FUNC void emcore_gmime_construct_part (GMimePart *part,
EM_DEBUG_LOG("Content-ID: %s", body->id);
int i = 0;
char *cid = EM_SAFE_STRDUP(body->id);
- if (cid) g_strstrip(cid);
+ if (cid) {
+ g_strstrip(cid);
- while (strlen(cid) > 0 && cid[i] != '\0') {
- if (cid[i] == '<' || cid[i] == '>')
- cid[i] = ' ';
- i++;
- }
+ while (strlen(cid) > 0 && cid[i] != '\0') {
+ if (cid[i] == '<' || cid[i] == '>')
+ cid[i] = ' ';
+ i++;
+ }
- g_strstrip(cid);
- EM_DEBUG_LOG_DEV("Content-ID stripped: %s", cid);
- g_mime_object_set_content_id(part_object, cid);
- EM_SAFE_FREE(cid);
+ g_strstrip(cid);
+ EM_DEBUG_LOG_DEV("Content-ID stripped: %s", cid);
+ g_mime_object_set_content_id(part_object, cid);
+ free(cid);
+ }
}
EM_DEBUG_FUNC_END();
@@ -3311,7 +3357,6 @@ INTERNAL_FUNC int emcore_gmime_construct_mime_part_with_bodystructure(BODY *mbod
if (mbody->parameter) {
PARAMETER *param = mbody->parameter;
while(param) {
- EM_DEBUG_LOG("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
if (g_ascii_strcasecmp(param->attribute, "boundary") == 0 && param->value)
boundary_ok = 1;
param = param->next;
@@ -3324,13 +3369,28 @@ INTERNAL_FUNC int emcore_gmime_construct_mime_part_with_bodystructure(BODY *mbod
}
char *subtype = g_ascii_strdown(mbody->subtype, -1);
- multipart = g_mime_multipart_new_with_subtype(subtype);
+ EM_DEBUG_LOG("Constructing a MULTIPART/%s", subtype);
+ if (g_ascii_strcasecmp(subtype, "signed") == 0) {
+ multipart = (GMimeMultipart *)g_mime_multipart_signed_new();
+ } else {
+ multipart = g_mime_multipart_new_with_subtype(subtype);
+ }
/* Fill up mime part of message1 using bodystructure info */
emcore_gmime_construct_multipart(multipart, mbody, spec, &total_size);
mime_part = GMIME_OBJECT(multipart);
EM_SAFE_FREE(subtype);
+
+ if (mbody->parameter) {
+ PARAMETER *param = mbody->parameter;
+ while(param) {
+ EM_DEBUG_LOG("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
+ if (param->attribute || param->value)
+ g_mime_object_set_content_type_parameter(mime_part, param->attribute, param->value);
+ param = param->next;
+ }
+ }
}
else {
char *type = g_ascii_strdown(body_types[mbody->type], -1);
@@ -3363,7 +3423,8 @@ FINISH_OFF:
}
INTERNAL_FUNC int emcore_gmime_get_body_sections_from_message(GMimeMessage *message,
- struct _m_content_info *cnt_info, char **sections_to_fetch)
+ struct _m_content_info *cnt_info,
+ char **sections_to_fetch)
{
EM_DEBUG_FUNC_BEGIN();
@@ -3461,7 +3522,9 @@ FINISH_OFF:
}
INTERNAL_FUNC int emcore_gmime_get_attachment_section_from_message(GMimeMessage *message,
- struct _m_content_info *cnt_info, int nth, char **section_to_fetch)
+ struct _m_content_info *cnt_info,
+ int nth,
+ char **section_to_fetch)
{
EM_DEBUG_FUNC_BEGIN();
@@ -3597,7 +3660,9 @@ static int emcore_gmime_get_section_n_bodysize(char *response, char *section, in
}
INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int msg_uid, int mail_id,
- struct _m_content_info *cnt_info, GMimeMessage *message, int event_handle, int auto_download, int *err_code)
+ struct _m_content_info *cnt_info,
+ GMimeMessage *message, int event_handle,
+ int auto_download, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], cnt_info[%p], err_code[%p]",
stream, msg_uid, cnt_info, err_code);
@@ -3624,13 +3689,20 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
int flag_first_write = 1;
char *tag_position = NULL;
- int part_header = 0;
+ int part_header = 0;
+ int signed_message = 0;
int download_interval = 0;
int download_total_size = 0;
int downloaded_size = 0;
int download_progress = 0;
int last_notified_download_size = 0;
+ char *full_text = NULL;
+ char *body_string = NULL;
+ char *header_string = NULL;
+ GMimeObject *entity_part = NULL;
+ GMimeParser *entity_parser = NULL;
+
GMimeDataWrapper *content = NULL;
GMimeStream *content_stream = NULL;
GMimeObject *mime_object = NULL;
@@ -3648,8 +3720,9 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
}
if (!cnt_info || !cnt_info->sections) {
- EM_DEBUG_EXCEPTION("invalid parameter detected...");
- err = EMAIL_ERROR_INVALID_PARAM;
+ EM_DEBUG_LOG("invalid parameter detected...");
+ /* Encrypted message did not have a text body So did not have a body section */
+ ret = TRUE;
goto FINISH_OFF;
}
@@ -3664,6 +3737,11 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
goto FINISH_OFF;
}
+ if (GMIME_IS_MULTIPART_SIGNED(message->mime_part)) {
+ EM_DEBUG_LOG("Multi Part Signed");
+ signed_message = 1;
+ }
+
while (imaplocal->netstream) {
/* receive response */
@@ -3686,13 +3764,13 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
server_response_yn = 1;
}
- part_header = 0;
+ part_header = 0;
flag_first_write = 1;
total = 0;
memset(encoded, 0x00, sizeof(encoded));
if (!emcore_gmime_get_section_n_bodysize(response, section, &body_size)) {
- EM_DEBUG_EXCEPTION("emcore_get_section_body_size failed [%d]", err);
+ EM_DEBUG_EXCEPTION("emcore_gmime_get_section_body_size failed [%d]", err);
err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
@@ -3751,26 +3829,30 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
mime_part = NULL;
mime_object = search_info->section_object;
if (GMIME_IS_MESSAGE_PART(mime_object)) {
- if (strcasestr(section, "MIME"))
- part_header = 1;
+ if (strcasestr(section, "MIME"))
+ part_header = 1;
- mime_message_part = GMIME_MESSAGE_PART(mime_object);
+ mime_message_part = GMIME_MESSAGE_PART(mime_object);
} else if (GMIME_IS_PART(mime_object)) {
- if (strcasestr(section, "MIME"))
- part_header = 1;
+ if (strcasestr(section, "MIME"))
+ part_header = 1;
mime_part = GMIME_PART(mime_object);
+ } else if (signed_message) {
+ if (strcasestr(section, "MIME"))
+ part_header = 1;
} else {
EM_DEBUG_EXCEPTION("invalid mime part type");
goto FINISH_OFF;
}
-
+
if (!part_header) {
if (!emcore_get_temp_file_name(&buf, &err) || !buf) {
EM_DEBUG_EXCEPTION("emcore_get_temp_file_name failed [%d]", err);
goto FINISH_OFF;
}
+ EM_DEBUG_LOG("TMP name : [%s]", buf);
g_mime_object_set_content_type_parameter(mime_object, "tmp_content_path", buf);
if (event_handle > 0)
@@ -3780,7 +3862,11 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
if (cnt_info->total_body_size > body_size) {
EM_DEBUG_LOG("Multipart body size is [%d]", cnt_info->total_body_size);
if (!auto_download) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, buf, cnt_info->total_body_size, 0))
+ if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY,
+ mail_id,
+ buf,
+ cnt_info->total_body_size,
+ 0))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
}
@@ -3800,7 +3886,11 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
if (cnt_info->grab_type == (GRAB_TYPE_TEXT | GRAB_TYPE_ATTACHMENT)) {
if (!auto_download) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, buf, cnt_info->total_mail_size, 0))
+ if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY,
+ mail_id,
+ buf,
+ cnt_info->total_mail_size,
+ 0))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
}
@@ -3819,8 +3909,18 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
goto FINISH_OFF;
}
- if (GMIME_IS_PART(mime_object) && mime_part) {
- content_stream = g_mime_stream_mem_new_with_buffer((const char *)encoded, EM_SAFE_STRLEN(encoded));
+ if (signed_message) {
+ content_stream = g_mime_stream_mem_new_with_buffer((const char *)encoded,
+ EM_SAFE_STRLEN(encoded));
+ entity_parser = g_mime_parser_new_with_stream(content_stream);
+ if (content_stream) g_object_unref(content_stream);
+
+ entity_part = g_mime_parser_construct_part(entity_parser);
+ if (entity_parser) g_object_unref(entity_parser);
+ }
+ else if (GMIME_IS_PART(mime_object) && mime_part) {
+ content_stream = g_mime_stream_mem_new_with_buffer((const char *)encoded,
+ EM_SAFE_STRLEN(encoded));
//parser = g_mime_parser_new_with_stream(content_stream);
content = g_mime_data_wrapper_new_with_stream(content_stream, mime_part->encoding);
if (content_stream) g_object_unref (content_stream);
@@ -3983,7 +4083,22 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
EM_DEBUG_LOG("%d has been written", EM_SAFE_STRLEN((char *)test_buffer));
}
- if (GMIME_IS_PART(mime_object) && mime_part) {
+ if (signed_message) {
+ err = em_open(buf, O_RDONLY, 0, &fd);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("holder open failed : holder is a filename that will be saved.");
+ goto FINISH_OFF;
+ }
+
+ content_stream = g_mime_stream_fs_new(fd);
+
+ entity_parser = g_mime_parser_new_with_stream(content_stream);
+ if (content_stream) g_object_unref(content_stream);
+
+ entity_part = g_mime_parser_construct_part(entity_parser);
+ if (entity_parser) g_object_unref(entity_parser);
+ }
+ else if (GMIME_IS_PART(mime_object) && mime_part) {
err = em_open(buf, O_RDONLY, 0, &fd);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("holder open failed : holder is a filename that will be saved.");
@@ -3996,54 +4111,58 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
if (content_stream) g_object_unref (content_stream);
g_mime_part_set_content_object(mime_part, content);
if (content) g_object_unref(content);
- }
+ }
}
} else {
- EM_DEBUG_LOG("MIME header");
-
- char *file_name = NULL;
-
- GMimeObject *object_header = NULL;
- GMimeParser *parser_header = NULL;
- GMimeContentType *ctype_header = NULL;
- GMimeContentDisposition *disposition_header = NULL;
-
- if (net_getbuffer(imaplocal->netstream, (long)body_size, (char *)encoded) <= 0) {
- EM_DEBUG_EXCEPTION("net_getbuffer failed...");
- err = EMAIL_ERROR_NO_RESPONSE;
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG_DEV("Data : [%s]", encoded);
+ EM_DEBUG_LOG("MIME header");
- content_stream = g_mime_stream_mem_new_with_buffer((const char *)encoded, EM_SAFE_STRLEN(encoded));
+ char *file_name = NULL;
- parser_header = g_mime_parser_new_with_stream(content_stream);
- if (content_stream) g_object_unref (content_stream);
+ GMimeObject *object_header = NULL;
+ GMimeParser *parser_header = NULL;
+ GMimeContentType *ctype_header = NULL;
+ GMimeContentDisposition *disposition_header = NULL;
- object_header = g_mime_parser_construct_part(parser_header);
- if (parser_header) g_object_unref(parser_header);
+ if (net_getbuffer(imaplocal->netstream, (long)body_size, (char *)encoded) <= 0) {
+ EM_DEBUG_EXCEPTION("net_getbuffer failed...");
+ err = EMAIL_ERROR_NO_RESPONSE;
+ goto FINISH_OFF;
+ }
- /* Content type */
- ctype_header = g_mime_object_get_content_type(object_header);
- file_name = (char *)g_mime_content_type_get_parameter(ctype_header, "name");
- EM_DEBUG_LOG_DEV("Content name : [%s]", file_name);
+ EM_DEBUG_LOG_DEV("Data : [%s]", encoded);
- if (file_name == NULL) {
- /* Content Disposition */
- disposition_header = g_mime_object_get_content_disposition(object_header);
- file_name = (char *)g_mime_content_disposition_get_parameter(disposition_header, "filename");
- EM_DEBUG_LOG_DEV("Disposition name : [%s]", file_name);
- }
+ if (signed_message) {
+ header_string = g_strdup((const gchar *)encoded);
+ } else {
+ content_stream = g_mime_stream_mem_new_with_buffer((const char *)encoded, EM_SAFE_STRLEN(encoded));
+ parser_header = g_mime_parser_new_with_stream(content_stream);
+ if (content_stream) g_object_unref(content_stream);
+
+ object_header = g_mime_parser_construct_part(parser_header);
+ if (parser_header) g_object_unref(parser_header);
+
+ /* Content type */
+ ctype_header = g_mime_object_get_content_type(object_header);
+ file_name = (char *)g_mime_content_type_get_parameter(ctype_header, "name");
+ EM_DEBUG_LOG_DEV("Content name : [%s]", file_name);
+
+ if (file_name == NULL) {
+ /* Content Disposition */
+ disposition_header = g_mime_object_get_content_disposition(object_header);
+ file_name = (char *)g_mime_content_disposition_get_parameter(disposition_header, "filename");
+ EM_DEBUG_LOG_DEV("Disposition name : [%s]", file_name);
+ }
- /* Replace the file name (Becase the server sometimes send the invalid name in bodystructure) */
- if (mime_part && file_name) g_mime_part_set_filename(mime_part, file_name);
+ /* Replace the file name (Becase the server sometimes send the invalid name in bodystructure) */
+ if (mime_part && file_name) g_mime_part_set_filename(mime_part, file_name);
+ }
- if (object_header) g_object_unref(object_header);
- if (ctype_header) g_object_unref(ctype_header);
- if (disposition_header) g_object_unref(disposition_header);
- }
+ if (object_header) g_object_unref(object_header);
+ if (ctype_header) g_object_unref(ctype_header);
+ if (disposition_header) g_object_unref(disposition_header);
+ }
+ if (buf) g_remove(buf);
EM_SAFE_FREE(buf);
}
else if ((tag_position = g_strrstr(response, tag))) /* end of response */ {
@@ -4062,6 +4181,43 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
EM_SAFE_FREE (response);
}
+ if (signed_message) {
+ int part_index = -1;
+
+ GMimeStream *tmp_stream = NULL;
+ GMimeParser *tmp_parser = NULL;
+ GMimeMessage *tmp_message = NULL;
+
+ body_string = g_mime_object_to_string(entity_part);
+ if (entity_part) g_object_unref(entity_part);
+
+ full_text = g_strconcat(header_string, body_string, NULL);
+ tmp_stream = g_mime_stream_mem_new_with_buffer(full_text, EM_SAFE_STRLEN(full_text));
+
+ tmp_parser = g_mime_parser_new_with_stream(tmp_stream);
+ if (tmp_stream) g_object_unref(tmp_stream);
+
+ tmp_message = g_mime_parser_construct_message(tmp_parser);
+ if (tmp_parser) g_object_unref(tmp_parser);
+
+ /* Search get index of multipart for replacing */
+ part_index = g_mime_multipart_index_of(GMIME_MULTIPART(message->mime_part), mime_object);
+ if (part_index == -1) {
+ EM_DEBUG_EXCEPTION("g_mime_multipart_index_of failed");
+ if (tmp_message) g_object_unref(tmp_message);
+ goto FINISH_OFF;
+ }
+
+ /* replace the entity part */
+ if (g_mime_multipart_replace(GMIME_MULTIPART(message->mime_part), part_index, tmp_message->mime_part) == NULL) {
+ EM_DEBUG_EXCEPTION("g_mime_multipart_replaced failed");
+ if (tmp_message) g_object_unref(tmp_message);
+ goto FINISH_OFF;
+ }
+
+ if (tmp_message) g_object_unref(tmp_message);
+ }
+
ret = TRUE;
FINISH_OFF:
@@ -4071,11 +4227,19 @@ FINISH_OFF:
mime_iter = NULL;
}*/
+ EM_SAFE_FREE(header_string);
+ EM_SAFE_FREE(body_string);
+ EM_SAFE_FREE(full_text);
+
+ if (entity_part) g_object_unref(entity_part);
+ if (entity_parser) g_object_unref(entity_parser);
+
if (search_info) {
EM_SAFE_FREE(search_info->section);
EM_SAFE_FREE(search_info);
}
+ if (buf) g_remove(buf);
EM_SAFE_FREE(buf);
EM_SAFE_FREE(response);
@@ -4747,3 +4911,114 @@ INTERNAL_FUNC char *emcore_gmime_get_encoding_to_utf8(const char *text)
return encoded_text;
}
+
+INTERNAL_FUNC char *emcore_gmime_get_decoding_text(const char *text)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ if (text == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return NULL;
+ }
+
+ char *decoded_text = NULL;
+
+ decoded_text = g_mime_utils_header_decode_text(text);
+ if (decoded_text == NULL) {
+ EM_DEBUG_EXCEPTION("g_mime_utils_header_encode_text failed : [%s]", text);
+ return NULL;
+ }
+
+ EM_DEBUG_LOG("decoded_text : [%s]", decoded_text);
+
+ return decoded_text;
+}
+
+INTERNAL_FUNC char *emcore_gmime_get_mime_entity_signed_message(GMimeObject *multipart)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int entity_fd = 0;
+ int error = EMAIL_ERROR_NONE;
+ char *mime_entity_path = NULL;
+
+ GMimeObject *mime_entity = NULL;
+ GMimeStream *out_stream = NULL, *filtered = NULL, *stream = NULL;
+ GMimeFilter *filter = NULL;
+
+ if (!GMIME_IS_MULTIPART_SIGNED(multipart)) {
+ EM_DEBUG_EXCEPTION("Invalid param");
+ error = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if (!emcore_get_temp_file_name(&mime_entity_path, &error)) {
+ EM_DEBUG_EXCEPTION("emcore_get_temp_file_name failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+
+ entity_fd = open(mime_entity_path, O_WRONLY|O_CREAT, 0644);
+ if (entity_fd < 0) {
+ EM_DEBUG_EXCEPTION("open failed");
+ error = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ mime_entity = g_mime_multipart_get_part(GMIME_MULTIPART(multipart), GMIME_MULTIPART_SIGNED_CONTENT);
+ stream = g_mime_stream_mem_new();
+ g_mime_object_write_to_stream(mime_entity, stream);
+ g_mime_stream_reset(stream);
+
+ filtered = g_mime_stream_filter_new(stream);
+ filter = g_mime_filter_crlf_new(TRUE, FALSE);
+ g_mime_stream_filter_add(GMIME_STREAM_FILTER(filtered), filter);
+
+ if (filter) g_object_unref(filter);
+ if (stream) g_object_unref(stream);
+ if (filtered) g_mime_stream_reset(filtered);
+
+ out_stream = g_mime_stream_fs_new(entity_fd);
+ g_mime_stream_write_to_stream(filtered, out_stream);
+ g_mime_stream_flush(out_stream);
+
+ if (filtered) g_object_unref(filtered);
+ if (out_stream) g_object_unref(out_stream);
+
+FINISH_OFF:
+
+ if (error != EMAIL_ERROR_NONE) {
+ EM_SAFE_FREE(mime_entity_path);
+ return NULL;
+ } else {
+ return mime_entity_path;
+ }
+}
+
+INTERNAL_FUNC char *emcore_gmime_get_mime_entity(int fd)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ char *output_path = NULL;
+
+ GMimeStream *stream = NULL;
+ GMimeParser *parser = NULL;
+ GMimeObject *part = NULL;
+
+ stream = g_mime_stream_fs_new(fd);
+
+ parser = g_mime_parser_new_with_stream(stream);
+ if (stream) g_object_unref(stream);
+
+ part = g_mime_parser_construct_part(parser);
+ if (parser) g_object_unref(parser);
+ if (part == NULL) {
+ EM_DEBUG_EXCEPTION("Data is invalid");
+ return NULL;
+ }
+
+ output_path = emcore_gmime_get_mime_entity_signed_message(part);
+
+ if (part) g_object_unref(part);
+
+ EM_DEBUG_FUNC_END();
+ return output_path;
+}
diff --git a/email-core/email-core-imap-idle.c b/email-core/email-core-imap-idle.c
index 9443d58..7f5e4f2 100755
--- a/email-core/email-core-imap-idle.c
+++ b/email-core/email-core-imap-idle.c
@@ -47,6 +47,7 @@
#include "email-core-account.h"
#include "email-core-alarm.h"
#include "email-utilities.h"
+#include "email-core-container.h"
/*Definitions copied temporarily from ssl_unix.c */
#define SSLBUFLEN 8192
@@ -67,6 +68,7 @@ typedef struct _email_imap_idle_connection_info_t {
int mailbox_id;
MAILSTREAM *mail_stream;
int socket_fd;
+ char *multi_user_name;
} email_imap_idle_connection_info_t;
int imap_idle_pipe_fd[2];
@@ -134,7 +136,10 @@ static int emcore_clear_old_connections(int input_epoll_fd, GList **input_imap_i
}
/* Close connection */
- connection_info->mail_stream = mail_close(connection_info->mail_stream);
+ if (connection_info->mail_stream)
+ connection_info->mail_stream = mail_close(connection_info->mail_stream);
+
+ EM_SAFE_FREE(connection_info->multi_user_name);
EM_SAFE_FREE(connection_info);
index = g_list_next(index);
@@ -148,7 +153,7 @@ FINISH_OFF:
return err;
}
-static int emcore_imap_idle_insert_sync_event(int input_account_id, int input_mailbox_id, int *err_code)
+static int emcore_imap_idle_insert_sync_event(char *multi_user_name, int input_account_id, int input_mailbox_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -163,7 +168,7 @@ static int emcore_imap_idle_insert_sync_event(int input_account_id, int input_ma
goto FINISH_OFF;
}
- event_data = em_malloc(sizeof(email_event_t));
+ event_data = em_malloc(sizeof(email_event_t));
if (event_data == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -173,6 +178,7 @@ static int emcore_imap_idle_insert_sync_event(int input_account_id, int input_ma
event_data->type = EMAIL_EVENT_SYNC_HEADER;
event_data->event_param_data_5 = input_mailbox_id;
event_data->account_id = input_account_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, &handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
@@ -195,7 +201,7 @@ FINISH_OFF:
return ret;
}
-static int emcore_parse_imap_idle_response(int input_account_id, int input_mailbox_id, MAILSTREAM *input_mailstream, int input_socket_fd)
+static int emcore_parse_imap_idle_response(char *multi_user_name, int input_account_id, int input_mailbox_id, MAILSTREAM *input_mailstream, int input_socket_fd)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d] input_mailbox_id [%d] input_mailstream[%p] input_socket_fd[%d]", input_account_id, input_mailbox_id, input_mailstream, input_socket_fd);
int err = EMAIL_ERROR_NONE;
@@ -228,7 +234,7 @@ static int emcore_parse_imap_idle_response(int input_account_id, int input_mailb
}
else {
if (strstr(p, "EXIST") != NULL) {
- if (!emcore_imap_idle_insert_sync_event(input_account_id, input_mailbox_id, &err))
+ if (!emcore_imap_idle_insert_sync_event(multi_user_name, input_account_id, input_mailbox_id, &err))
EM_DEBUG_EXCEPTION_SEC("Syncing mailbox[%d] failed with err_code [%d]", input_mailbox_id, err);
}
else
@@ -256,7 +262,7 @@ FINISH_OFF:
}
/* connects to given mailbox. send idle and returns socket id */
-static int emcore_connect_and_idle_on_mailbox(GList **input_connection_list, email_account_t *input_account, email_mailbox_t *input_mailbox, MAILSTREAM **output_mailstream, int *output_socket_fd)
+static int emcore_connect_and_idle_on_mailbox(char *multi_user_name, GList **input_connection_list, email_account_t *input_account, email_mailbox_t *input_mailbox, MAILSTREAM **output_mailstream, int *output_socket_fd)
{
EM_DEBUG_FUNC_BEGIN("input_connection_list [%p] input_account [%p] input_mailbox[%p] output_mailstream [%p] output_socket_fd [%p]", input_connection_list, input_account, input_mailbox, output_mailstream, output_socket_fd);
void *mail_stream = NULL;
@@ -284,7 +290,7 @@ static int emcore_connect_and_idle_on_mailbox(GList **input_connection_list, ema
EM_DEBUG_EXCEPTION("emcore_get_empty_session failed...");
/* Open connection to mailbox */
- if (!emcore_connect_to_remote_mailbox(input_mailbox->account_id, input_mailbox->mailbox_id, (void **)&mail_stream, &err) || !mail_stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, input_mailbox->account_id, input_mailbox->mailbox_id, (void **)&mail_stream, &err) || !mail_stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -343,10 +349,11 @@ static int emcore_connect_and_idle_on_mailbox(GList **input_connection_list, ema
goto FINISH_OFF;
}
- connection_info->account_id = input_account->account_id;
- connection_info->mailbox_id = input_mailbox->mailbox_id;
- connection_info->mail_stream = mail_stream;
- connection_info->socket_fd = socket_fd;
+ connection_info->account_id = input_account->account_id;
+ connection_info->mailbox_id = input_mailbox->mailbox_id;
+ connection_info->mail_stream = mail_stream;
+ connection_info->socket_fd = socket_fd;
+ connection_info->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
imap_idle_connection_list = g_list_append(imap_idle_connection_list, (gpointer)connection_info);
@@ -378,7 +385,7 @@ static int emcore_imap_idle_cb(email_alarm_data_t *alarm_data, void *user_parame
return err;
}
-static int emcore_refresh_alarm_for_imap_idle()
+static int emcore_refresh_alarm_for_imap_idle(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
@@ -395,7 +402,7 @@ static int emcore_refresh_alarm_for_imap_idle()
emcore_delete_alram_data_by_reference_id(EMAIL_ALARM_CLASS_IMAP_IDLE, 0);
}
- if (!emcore_get_account_reference_list(&account_ref_list, &account_count, &err)) {
+ if ((err = emcore_get_account_reference_list(multi_user_name, &account_ref_list, &account_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -406,14 +413,14 @@ static int emcore_refresh_alarm_for_imap_idle()
}
}
- if(account_ref_list)
+ if (account_ref_list)
emcore_free_account_list(&account_ref_list, account_count, NULL);
if (auto_sync_account_count) {
time(&current_time);
trigger_at_time = current_time + (29 * 60);
- if ((err = emcore_add_alarm(trigger_at_time, EMAIL_ALARM_CLASS_IMAP_IDLE, 0, emcore_imap_idle_cb, NULL)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_IMAP_IDLE, 0, emcore_imap_idle_cb, NULL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
}
}
@@ -442,6 +449,8 @@ void* emcore_imap_idle_worker(void* thread_user_data)
email_mailbox_t inbox_mailbox = {0};
email_account_t *account_ref_list = NULL;
GList *imap_idle_connection_list = NULL;
+ GList *zone_name_list = NULL;
+ GList *node = NULL;
email_imap_idle_connection_info_t *connection_info = NULL;
EM_DEBUG_LOG("emcore_imap_idle_worker start ");
@@ -470,56 +479,124 @@ void* emcore_imap_idle_worker(void* thread_user_data)
EM_DEBUG_LOG("Enter imap idle loop");
while (1) {
if (refresh_connection_flag) {
+
EM_DEBUG_LOG("Clear old connections");
emcore_clear_old_connections(epoll_fd, &imap_idle_connection_list);
EM_DEBUG_LOG("Getting account list");
- if (!emcore_get_account_reference_list(&account_ref_list, &account_count, &err)) {
- EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
- break;
+ if ((err = emcore_get_zone_name_list(&zone_name_list)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_zone_name_list failed : err[%d]", err);
+ if (zone_name_list) g_list_free(zone_name_list);
+ continue;
}
- for (i = 0; i < account_count; i++) {
- if (account_ref_list[i].incoming_server_type != EMAIL_SERVER_TYPE_IMAP4 || (account_ref_list[i].check_interval != 0 && account_ref_list[i].peak_interval != 0)) {
- EM_DEBUG_LOG("account_id[%d] is not for auto sync", account_ref_list[i].account_id);
- continue;
- }
+ if (g_list_length(zone_name_list) <= 1) {
+ if ((err = emcore_get_account_reference_list(NULL, &account_ref_list, &account_count)) != EMAIL_ERROR_NONE)
+ EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
- /* TODO: peak schedule handling */
+ for (i = 0; i < account_count; i++) {
+ if (account_ref_list[i].incoming_server_type != EMAIL_SERVER_TYPE_IMAP4 || (account_ref_list[i].check_interval != 0 && account_ref_list[i].peak_interval != 0)) {
+ EM_DEBUG_LOG("account_id[%d] is not for auto sync", account_ref_list[i].account_id);
+ continue;
+ }
- memset(&inbox_mailbox, 0, sizeof(email_mailbox_t));
+ /* TODO: peak schedule handling */
- if (!emcore_get_mailbox_by_type(account_ref_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &inbox_mailbox, &err)) {
- EM_DEBUG_EXCEPTION("emcore_get_mailbox_by_type failed [%d]", err);
- continue;
- }
+ memset(&inbox_mailbox, 0, sizeof(email_mailbox_t));
+
+ if (!emcore_get_mailbox_by_type(NULL, account_ref_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &inbox_mailbox, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_mailbox_by_type failed [%d]", err);
+ continue;
+ }
- EM_DEBUG_LOG("Connect to IMAP server");
- err = emcore_connect_and_idle_on_mailbox(&imap_idle_connection_list, &(account_ref_list[i]), &inbox_mailbox, &mail_stream, &socket_fd);
+ EM_DEBUG_LOG("Connect to IMAP server");
+ err = emcore_connect_and_idle_on_mailbox(NULL, &imap_idle_connection_list, &(account_ref_list[i]), &inbox_mailbox, &mail_stream, &socket_fd);
- emcore_free_mailbox(&inbox_mailbox);
+ emcore_free_mailbox(&inbox_mailbox);
- if (err != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_connect_and_idle_on_mailbox failed [%d]", err);
- continue;
- }
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_connect_and_idle_on_mailbox failed [%d]", err);
+ continue;
+ }
- ev.events = EPOLLIN;
- ev.data.fd = socket_fd;
+ ev.events = EPOLLIN;
+ ev.data.fd = socket_fd;
- EM_DEBUG_LOG("Add listener for socket buffer");
- if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, socket_fd, &ev) == -1) {
- EM_DEBUG_EXCEPTION("epoll_ctl failed: %s[%d]", EM_STRERROR(errno_buf), errno);
+ EM_DEBUG_LOG("Add listener for socket buffer");
+ if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, socket_fd, &ev) == -1) {
+ EM_DEBUG_EXCEPTION("epoll_ctl failed: %s[%d]", EM_STRERROR(errno_buf), errno);
+ }
}
- }
- if(account_ref_list)
- emcore_free_account_list(&account_ref_list, account_count, NULL);
+ if(account_ref_list)
+ emcore_free_account_list(&account_ref_list, account_count, NULL);
+
+ EM_DEBUG_LOG(" Delete old an alarm and add an alarm to refresh connections every 29min");
+ emcore_refresh_alarm_for_imap_idle(NULL);
+
+ refresh_connection_flag = 0;
+ } else {
+ node = g_list_first(zone_name_list);
+
+ while (node != NULL) {
+ if (!node->data)
+ node = g_list_next(node);
- EM_DEBUG_LOG(" Delete old an alarm and add an alarm to refresh connections every 29min");
- emcore_refresh_alarm_for_imap_idle();
+ EM_DEBUG_LOG("Data name of node : [%s]", node->data);
+
+ if ((err = emcore_get_account_reference_list(node->data, &account_ref_list, &account_count)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
+ }
+
+ for (i = 0; i < account_count; i++) {
+ if (account_ref_list[i].incoming_server_type != EMAIL_SERVER_TYPE_IMAP4 || (account_ref_list[i].check_interval != 0 && account_ref_list[i].peak_interval != 0)) {
+ EM_DEBUG_LOG("account_id[%d] is not for auto sync", account_ref_list[i].account_id);
+ continue;
+ }
+
+ /* TODO: peak schedule handling */
+
+ memset(&inbox_mailbox, 0, sizeof(email_mailbox_t));
+
+ if (!emcore_get_mailbox_by_type(node->data, account_ref_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &inbox_mailbox, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_mailbox_by_type failed [%d]", err);
+ continue;
+ }
+
+ EM_DEBUG_LOG("Connect to IMAP server");
+ err = emcore_connect_and_idle_on_mailbox(node->data, &imap_idle_connection_list, &(account_ref_list[i]), &inbox_mailbox, &mail_stream, &socket_fd);
+
+ emcore_free_mailbox(&inbox_mailbox);
+
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_connect_and_idle_on_mailbox failed [%d]", err);
+ continue;
+ }
+
+ ev.events = EPOLLIN;
+ ev.data.fd = socket_fd;
+
+ EM_DEBUG_LOG("Add listener for socket buffer");
+ if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, socket_fd, &ev) == -1) {
+ EM_DEBUG_EXCEPTION("epoll_ctl failed: %s[%d]", EM_STRERROR(errno_buf), errno);
+ }
+ }
+
+ if(account_ref_list)
+ emcore_free_account_list(&account_ref_list, account_count, NULL);
+
+ EM_DEBUG_LOG(" Delete old an alarm and add an alarm to refresh connections every 29min");
+ emcore_refresh_alarm_for_imap_idle(node->data);
+
+ EM_SAFE_FREE(node->data);
+ node = g_list_next(node);
+ }
+
+ refresh_connection_flag = 0;
+ }
- refresh_connection_flag = 0;
+ if (zone_name_list)
+ g_list_free(zone_name_list);
}
EM_DEBUG_LOG("Waiting.......");
@@ -547,7 +624,11 @@ void* emcore_imap_idle_worker(void* thread_user_data)
continue;
}
- if ((err = emcore_parse_imap_idle_response(connection_info->account_id, connection_info->mailbox_id, connection_info->mail_stream, connection_info->socket_fd)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_parse_imap_idle_response(connection_info->multi_user_name,
+ connection_info->account_id,
+ connection_info->mailbox_id,
+ connection_info->mail_stream,
+ connection_info->socket_fd)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_parse_imap_idle_response failed. [%d] ", err);
refresh_connection_flag = 1;
// mail_stream = mail_close (mail_stream);
diff --git a/email-core/email-core-imap-mailbox.c b/email-core/email-core-imap-mailbox.c
index a9ecf2c..839d497 100755
--- a/email-core/email-core-imap-mailbox.c
+++ b/email-core/email-core-imap-mailbox.c
@@ -52,8 +52,8 @@
#include "email-debug-log.h"
-INTERNAL_FUNC int emcore_get_default_mail_slot_count(int input_account_id, int *output_count)
-{
+INTERNAL_FUNC int emcore_get_default_mail_slot_count(char *multi_user_name, int input_account_id, int *output_count)
+{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d] output_count[%p]", input_account_id, output_count);
int err = EMAIL_ERROR_NONE;
@@ -65,7 +65,7 @@ INTERNAL_FUNC int emcore_get_default_mail_slot_count(int input_account_id, int *
goto FINISH_OFF;
}
- account_ref = emcore_get_account_reference(input_account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, input_account_id, false);
if (account_ref)
default_mail_slot_count = account_ref->default_mail_slot_size;
@@ -84,7 +84,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_remove_overflowed_mails(emstorage_mailbox_tbl_t *intput_mailbox_tbl, int *err_code)
+INTERNAL_FUNC int emcore_remove_overflowed_mails(char *multi_user_name, emstorage_mailbox_tbl_t *intput_mailbox_tbl, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("intput_mailbox_tbl[%p], err_code[%p]", intput_mailbox_tbl, err_code);
@@ -100,7 +100,7 @@ INTERNAL_FUNC int emcore_remove_overflowed_mails(emstorage_mailbox_tbl_t *intput
goto FINISH_OFF;
}
- account_ref = emcore_get_account_reference(intput_mailbox_tbl->account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, intput_mailbox_tbl->account_id, false);
if (account_ref) {
if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
EM_DEBUG_LOG("ActiveSync Account didn't support mail slot");
@@ -109,7 +109,7 @@ INTERNAL_FUNC int emcore_remove_overflowed_mails(emstorage_mailbox_tbl_t *intput
}
}
- if (!emstorage_get_overflowed_mail_id_list(intput_mailbox_tbl->account_id, intput_mailbox_tbl->mailbox_id, intput_mailbox_tbl->mailbox_type, intput_mailbox_tbl->mail_slot_size, &mail_id_list, &mail_id_list_count, true, &err)) {
+ if (!emstorage_get_overflowed_mail_id_list(multi_user_name, intput_mailbox_tbl->account_id, intput_mailbox_tbl->mailbox_id, intput_mailbox_tbl->mail_slot_size, &mail_id_list, &mail_id_list_count, true, &err)) {
if (err == EMAIL_ERROR_MAIL_NOT_FOUND) {
EM_DEBUG_LOG_SEC("There are enough slot in intput_mailbox_tbl [%s]", intput_mailbox_tbl->mailbox_name);
err = EMAIL_ERROR_NONE;
@@ -121,7 +121,7 @@ INTERNAL_FUNC int emcore_remove_overflowed_mails(emstorage_mailbox_tbl_t *intput
}
if (mail_id_list) {
- if (!emcore_delete_mail(intput_mailbox_tbl->account_id, mail_id_list, mail_id_list_count, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_BY_OVERFLOW, false, &err)) {
+ if (!emcore_delete_mail(multi_user_name, intput_mailbox_tbl->account_id, mail_id_list, mail_id_list_count, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_BY_OVERFLOW, false, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -144,7 +144,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size, int *err_code)
+INTERNAL_FUNC int emcore_set_mail_slot_size(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id[%d], err_code[%p]", account_id, mailbox_id, err_code);
@@ -157,7 +157,7 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int
emstorage_mailbox_tbl_t *mailbox_tbl_list = NULL;
if (account_id > ALL_ACCOUNT) {
- account_ref = emcore_get_account_reference(account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, account_id, false);
if (account_ref && account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
EM_DEBUG_LOG("ActiveSync account didn't support mail slot");
ret = true;
@@ -168,7 +168,7 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int
goto FINISH_OFF;
}
if (mailbox_id == 0) {
- if ( (err = emstorage_set_field_of_accounts_with_integer_value(account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
+ if ( (err = emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_accounts_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
@@ -176,12 +176,12 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int
}
else {
if (mailbox_id == 0) {
- if ( !emstorage_get_account_list(&account_count, &account_tbl_list, false, false, &err)) {
+ if ( !emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_list, false, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
for ( i = 0; i < account_count; i++) {
- if ( (err = emstorage_set_field_of_accounts_with_integer_value(account_tbl_list[i].account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
+ if ( (err = emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_tbl_list[i].account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_accounts_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
@@ -189,8 +189,7 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int
}
}
-
- if (!emstorage_set_mail_slot_size(account_id, mailbox_id, new_slot_size, true, &err)) {
+ if (!emstorage_set_mail_slot_size(multi_user_name, account_id, mailbox_id, new_slot_size, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_mail_slot_size failed [%d]", err);
goto FINISH_OFF;
}
@@ -208,7 +207,7 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int
mailbox_tbl_list->mail_slot_size = new_slot_size;
}
else { /* read information from DB */
- if ((err = emstorage_get_mailbox_by_id(mailbox_id, &mailbox_tbl_list)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id, &mailbox_tbl_list)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -216,14 +215,14 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int
}
}
else {
- if (!emstorage_get_mailbox_list(account_id, EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
+ if (!emstorage_get_mailbox_list(multi_user_name, account_id, EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
goto FINISH_OFF;
}
}
for (i = 0; i < mailbox_count; i++) {
- if (!emcore_remove_overflowed_mails(mailbox_tbl_list + i, &err)) {
+ if (!emcore_remove_overflowed_mails(multi_user_name, mailbox_tbl_list + i, &err)) {
if (err == EMAIL_ERROR_MAIL_NOT_FOUND || err == EMAIL_ERROR_NOT_SUPPORTED)
err = EMAIL_ERROR_NONE;
else
@@ -252,7 +251,7 @@ FINISH_OFF:
return ret;
}
-static int emcore_get_mailbox_connection_path(int account_id, char *mailbox_name, char **path, int *err_code)
+static int emcore_get_mailbox_connection_path(char *multi_user_name, int account_id, char *mailbox_name, char **path, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id [%d], mailbox_name[%s], err_code[%p]", account_id, mailbox_name, err_code);
email_account_t *ref_account = NULL;
@@ -260,7 +259,7 @@ static int emcore_get_mailbox_connection_path(int account_id, char *mailbox_name
int ret = false;
int err = EMAIL_ERROR_NONE;
- ref_account = emcore_get_account_reference(account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed");
goto FINISH_OFF;
@@ -379,7 +378,7 @@ static void emcore_find_mailbox_diff_between_local_and_remote (email_internal_ma
if (remote_head) g_list_free(remote_head);
}
-INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, int event_handle, int *err_code)
+INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id, char *mailbox_name, int event_handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], handle[%d], err_code[%p]", account_id, mailbox_name, event_handle, err_code);
@@ -408,8 +407,8 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
goto FINISH_OFF;
}
-
- ref_account = emcore_get_account_reference(account_id);
+
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -425,7 +424,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
/* get mail server path */
/* mbox_path is not used. the below func might be unnecessary */
- if (!emcore_get_mailbox_connection_path(account_id, NULL, &mbox_path, &err) || !mbox_path) {
+ if (!emcore_get_mailbox_connection_path(multi_user_name, account_id, NULL, &mbox_path, &err) || !mbox_path) {
EM_DEBUG_EXCEPTION("emcore_get_mailbox_connection_path - %d", err);
goto FINISH_OFF;
}
@@ -434,7 +433,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
stream = NULL;
- if (!emcore_connect_to_remote_mailbox(account_id, 0, (void **)&tmp_stream, &err) || !tmp_stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, 0, (void **)&tmp_stream, &err) || !tmp_stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err);
if (err == EMAIL_ERROR_CONNECTION_BROKEN)
@@ -457,7 +456,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
}
/* get all mailboxes which is previously synced */
- if (!emstorage_get_mailbox_list (account_id, EMAIL_MAILBOX_FROM_SERVER, EMAIL_MAILBOX_SORT_BY_NAME_ASC,\
+ if (!emstorage_get_mailbox_list (multi_user_name, account_id, EMAIL_MAILBOX_FROM_SERVER, EMAIL_MAILBOX_SORT_BY_NAME_ASC,\
&local_mailbox_count, &local_mailbox_list, 1, &err)) {
if (err != EMAIL_ERROR_MAILBOX_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_list error [%d]", err);
@@ -517,10 +516,11 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
mailbox_tbl.modifiable_yn = 1;
mailbox_tbl.total_mail_count_on_server = 0;
- if (!emstorage_add_mailbox (&mailbox_tbl, true, &err)) {
+ if (!emstorage_add_mailbox (multi_user_name, &mailbox_tbl, true, &err)) {
EM_DEBUG_EXCEPTION ("emstorage_add_mailbox error [%d]", err);
goto FINISH_OFF;
}
+
if (mailbox_tbl.mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)
inbox_added = 1;
EM_DEBUG_LOG_SEC ("MAILBOX ADDED: mailbox_name [%s] alias [%s] mailbox_type [%d]", new_mailbox->mailbox_name,\
@@ -532,17 +532,19 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
p = local_box_only;
for (; p; p = g_list_next (p)) {
emstorage_mailbox_tbl_t *del_box = (emstorage_mailbox_tbl_t *) g_list_nth_data (p, 0);
- if (!emstorage_delete_mail_by_mailbox (del_box, 1, &err)) {
+
+ if (!emstorage_delete_mail_by_mailbox (multi_user_name, del_box, 1, &err)) {
EM_DEBUG_EXCEPTION ("emstorage_delete_mail_by_mailbox error [%d] account_id [%d] mailbox_name [%s]",\
err, del_box->account_id, del_box->mailbox_name);
}
- if (!emstorage_delete_mailbox (del_box->account_id, EMAIL_MAILBOX_FROM_SERVER, del_box->mailbox_id, 1, &err)) {
+
+ if (!emstorage_delete_mailbox (multi_user_name, del_box->account_id, EMAIL_MAILBOX_FROM_SERVER, del_box->mailbox_id, 1, &err)) {
EM_DEBUG_EXCEPTION ("emstorage_delete_mailbox error [%d] account_id [%d] mailbox_name [%s]",\
err, del_box->account_id, del_box->mailbox_name);
}
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
- if (!emstorage_delete_auto_download_activity_by_mailbox(del_box->account_id, del_box->mailbox_id, 1, &err))
+ if (!emstorage_delete_auto_download_activity_by_mailbox(multi_user_name, del_box->account_id, del_box->mailbox_id, 1, &err))
EM_DEBUG_EXCEPTION("emstorage_delete_auto_download_activity_by_mailbox failed");
#endif
@@ -555,7 +557,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
emstorage_mailbox_tbl_t mailbox_tbl;
emstorage_mailbox_tbl_t *result_mailbox_tbl = NULL;
- if(emstorage_get_mailbox_by_mailbox_type(account_id, counter, &result_mailbox_tbl, true, &err2)) {
+ if(emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, counter, &result_mailbox_tbl, true, &err2)) {
if(result_mailbox_tbl) {
emstorage_free_mailbox(&result_mailbox_tbl, 1, NULL);
continue;
@@ -605,14 +607,15 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox_name, i
break;
}
- if (!emstorage_add_mailbox(&mailbox_tbl, true, &err)) {
+ if (!emstorage_add_mailbox(multi_user_name, &mailbox_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mailbox failed - %d", err);
goto FINISH_OFF;
}
}
EM_SAFE_FREE(mailbox_name_for_mailbox_type);
}
- if (!emstorage_set_all_mailbox_modifiable_yn(account_id, 0, true, &err)) {
+
+ if (!emstorage_set_all_mailbox_modifiable_yn(multi_user_name, account_id, 0, true, &err)) {
EM_DEBUG_EXCEPTION(" >>>> emstorage_set_all_mailbox_modifiable_yn Failed [ %d ]", err);
goto FINISH_OFF;
}
@@ -662,7 +665,6 @@ FINISH_OFF:
if (err_code != NULL)
*err_code = err;
-
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
@@ -734,7 +736,7 @@ FINISH_OFF:
* succeed : 1
* fail : 0
*/
-INTERNAL_FUNC int emcore_create_imap_mailbox(email_mailbox_t *mailbox, int *err_code)
+INTERNAL_FUNC int emcore_create_imap_mailbox(char *multi_user_name, email_mailbox_t *mailbox, int *err_code)
{
MAILSTREAM *stream = NULL;
char *long_enc_path = NULL;
@@ -755,7 +757,7 @@ INTERNAL_FUNC int emcore_create_imap_mailbox(email_mailbox_t *mailbox, int *err_
/* connect mail server */
stream = NULL;
- if (!emcore_connect_to_remote_mailbox(mailbox->account_id, 0, (void **)&tmp_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mailbox->account_id, 0, (void **)&tmp_stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -763,7 +765,7 @@ INTERNAL_FUNC int emcore_create_imap_mailbox(email_mailbox_t *mailbox, int *err_
stream = (MAILSTREAM *) tmp_stream;
/* encode mailbox name by UTF7, and rename to full path (ex : {mail.test.com}child_mailbox) */
- if (!emcore_get_long_encoded_path(mailbox->account_id, mailbox->mailbox_name, '/', &long_enc_path, &err)) {
+ if (!emcore_get_long_encoded_path(multi_user_name, mailbox->account_id, mailbox->mailbox_name, '/', &long_enc_path, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed [%d]", err);
goto FINISH_OFF;
}
@@ -823,7 +825,7 @@ FINISH_OFF:
* succeed : 1
* fail : 0
*/
-INTERNAL_FUNC int emcore_delete_imap_mailbox(int input_mailbox_id, int *err_code)
+INTERNAL_FUNC int emcore_delete_imap_mailbox(char *multi_user_name, int input_mailbox_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -838,13 +840,12 @@ INTERNAL_FUNC int emcore_delete_imap_mailbox(int input_mailbox_id, int *err_code
if(!emcore_notify_network_event(NOTI_DELETE_MAILBOX_START, input_mailbox_id, 0, 0, 0))
EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_DELETE_MAILBOX_START] failed");
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox_tbl->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, mailbox_tbl->account_id, false);
if (!ref_account || ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
EM_DEBUG_EXCEPTION("Invalid account information");
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -852,7 +853,7 @@ INTERNAL_FUNC int emcore_delete_imap_mailbox(int input_mailbox_id, int *err_code
}
/* connect mail server */
- if (!emcore_connect_to_remote_mailbox(mailbox_tbl->account_id, 0, (void **)&tmp_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mailbox_tbl->account_id, 0, (void **)&tmp_stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -860,7 +861,7 @@ INTERNAL_FUNC int emcore_delete_imap_mailbox(int input_mailbox_id, int *err_code
stream = (MAILSTREAM *)tmp_stream;
/* encode mailbox name by UTF7, and rename to full path (ex : {mail.test.com}child_mailbox) */
- if (!emcore_get_long_encoded_path(mailbox_tbl->account_id, mailbox_tbl->mailbox_name, '/', &long_enc_path, &err)) {
+ if (!emcore_get_long_encoded_path(multi_user_name, mailbox_tbl->account_id, mailbox_tbl->mailbox_name, '/', &long_enc_path, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed [%d]", err);
goto FINISH_OFF;
}
@@ -905,7 +906,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(int input_account_id, int input_mailbox_id, char *input_old_mailbox_path, char *input_new_mailbox_path, int handle_to_be_published)
+INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(char *multi_user_name, int input_account_id, int input_mailbox_id, char *input_old_mailbox_path, char *input_new_mailbox_path, int handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_id [%d], input_old_mailbox_path [%p], input_new_mailbox_path [%p] handle_to_be_published[%d]", input_account_id, input_mailbox_id, input_old_mailbox_path, input_new_mailbox_path, handle_to_be_published);
MAILSTREAM *stream = NULL;
@@ -921,8 +922,7 @@ INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(int input_account_id, int
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(input_account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, input_account_id, false);
if (!ref_account || ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_ACCOUNT");
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -931,7 +931,7 @@ INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(int input_account_id, int
/* connect mail server */
stream = NULL;
- if (!emcore_connect_to_remote_mailbox(input_account_id, 0, (void **)&tmp_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, input_account_id, 0, (void **)&tmp_stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed. [%d]", err);
goto FINISH_OFF;
}
@@ -939,13 +939,13 @@ INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(int input_account_id, int
stream = (MAILSTREAM *)tmp_stream;
/* encode mailbox name by UTF7, and rename to full path (ex : {mail.test.com}child_mailbox) */
- if (!emcore_get_long_encoded_path(input_account_id, input_old_mailbox_path, '/', &long_enc_path_old, &err)) {
+ if (!emcore_get_long_encoded_path(multi_user_name, input_account_id, input_old_mailbox_path, '/', &long_enc_path_old, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed. [%d]", err);
goto FINISH_OFF;
}
/* encode mailbox name by UTF7, and rename to full path (ex : {mail.test.com}child_mailbox) */
- if (!emcore_get_long_encoded_path(input_account_id, input_new_mailbox_path, '/', &long_enc_path_new, &err)) {
+ if (!emcore_get_long_encoded_path(multi_user_name, input_account_id, input_new_mailbox_path, '/', &long_enc_path_new, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed. [%d]", err);
goto FINISH_OFF;
}
@@ -1022,13 +1022,12 @@ INTERNAL_FUNC int emcore_get_quota_root(int input_mailbox_id, email_quota_resour
email_account_t *ref_account = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox_tbl->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, mailbox_tbl->account_id, false);
if (!ref_account || ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
EM_DEBUG_EXCEPTION("Invalid account information");
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -1036,7 +1035,7 @@ INTERNAL_FUNC int emcore_get_quota_root(int input_mailbox_id, email_quota_resour
}
/* connect mail server */
- if (!emcore_connect_to_remote_mailbox(mailbox_tbl->account_id, 0, (void **)&stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mailbox_tbl->account_id, 0, (void **)&stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -1057,12 +1056,12 @@ INTERNAL_FUNC int emcore_get_quota(int input_mailbox_id, char *input_quota_root,
email_account_t *ref_account = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox_tbl->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, mailbox_tbl->account_id, false);
if (!ref_account || ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
EM_DEBUG_EXCEPTION("Invalid account information");
@@ -1071,7 +1070,7 @@ INTERNAL_FUNC int emcore_get_quota(int input_mailbox_id, char *input_quota_root,
}
/* connect mail server */
- if (!emcore_connect_to_remote_mailbox(mailbox_tbl->account_id, 0, (void **)&stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mailbox_tbl->account_id, 0, (void **)&stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
diff --git a/email-core/email-core-mail.c b/email-core/email-core-mail.c
index 20318f9..dbebf98 100755
--- a/email-core/email-core-mail.c
+++ b/email-core/email-core-mail.c
@@ -64,13 +64,12 @@
#include "email-core-account.h"
#include "email-core-signal.h"
#include "email-core-smtp.h"
+#include "email-core-container.h"
+#include "email-core-gmime.h"
#include "email-convert.h"
#include "email-debug-log.h"
-#ifdef __FEATURE_USE_GMIME__
-#include "email-core-gmime.h"
-#endif /* __FEATURE_USE_GMIME__ */
#define ST_SILENT (long) 0x2 /* don't return results */
@@ -78,6 +77,7 @@
static char g_new_server_uid[129];
static int g_copyuid_account_id = 0;
+static char *g_multi_user_name = NULL;
bool only_body_download = false;
@@ -93,7 +93,7 @@ int _imap4_last_notified_body_size = 0;
int _imap4_total_body_size = 0;
int _imap4_download_noti_interval_value = 0;
-static int emcore_delete_mails_from_pop3_server(email_account_t *input_account, int input_mail_ids[], int input_mail_id_count);
+static int emcore_delete_mails_from_pop3_server(char *multi_user_name, email_account_t *input_account, int input_mail_ids[], int input_mail_id_count);
static int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, int *downloded_size, int *total_body_size, int *err_code);
extern long pop3_send (MAILSTREAM *stream, char *command, char *args);
@@ -330,14 +330,21 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l
}
-
-
EM_DEBUG_LOG("Count of mails copied [%d]", count);
old_server_uid = em_malloc(count * sizeof(unsigned long));
+ if (old_server_uid == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed : EMAIL_ERROR_OUT_OF_MEMORY");
+ return;
+ }
+
new_server_uid = em_malloc(count * sizeof(unsigned long));
+ if (new_server_uid == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed : EMAIL_ERROR_OUT_OF_MEMORY");
+ EM_SAFE_FREE(old_server_uid);
+ return;
+ }
/* While loop below will collect all old server uid from sourceset into old_server_uid array */
-
while (sourceset) {
if (sourceset->first > 0) {
first_uid = sourceset->first;
@@ -388,7 +395,7 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l
}
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
- if (!emstorage_get_mailbox_by_name(g_copyuid_account_id, -1, mailbox, &mailbox_tbl, false, &err)) {
+ if (!emstorage_get_mailbox_by_name(g_multi_user_name, g_copyuid_account_id, -1, mailbox, &mailbox_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d", err);
}
#endif
@@ -407,17 +414,16 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l
EM_DEBUG_LOG("New Server Uid Char[%s]", new_server_uid_char);
- if (!emstorage_update_server_uid(old_server_uid_char, new_server_uid_char, &err)) {
+ if (!emstorage_update_server_uid(g_multi_user_name, old_server_uid_char, new_server_uid_char, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_server_uid failed...[%d]", err);
}
-
- if (!emstorage_update_read_mail_uid_by_server_uid(old_server_uid_char, new_server_uid_char, mailbox, &err)) {
+
+ if (!emstorage_update_read_mail_uid_by_server_uid(g_multi_user_name, old_server_uid_char, new_server_uid_char, mailbox, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_read_mail_uid_by_server_uid failed... [%d]", err);
}
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-
- if (false == emstorage_update_pbd_activity(old_server_uid_char, new_server_uid_char, mailbox, &err)) {
+ if (false == emstorage_update_pbd_activity(g_multi_user_name, old_server_uid_char, new_server_uid_char, mailbox, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_pbd_activity failed... [%d]", err);
}
@@ -425,7 +431,7 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
if (mailbox_tbl) {
- if (!emstorage_update_auto_download_activity(old_server_uid_char, new_server_uid_char, NULL, mailbox_tbl->mailbox_id, &err))
+ if (!emstorage_update_auto_download_activity(g_multi_user_name, old_server_uid_char, new_server_uid_char, NULL, mailbox_tbl->mailbox_id, &err))
EM_DEBUG_EXCEPTION("emstorage_update_auto_download_activity failed : [%d]", err);
}
#endif
@@ -435,14 +441,16 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
if (mailbox_tbl)
emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+
g_copyuid_account_id = 0;
+ EM_SAFE_FREE(g_multi_user_name);
#endif
EM_SAFE_FREE(old_server_uid);
EM_SAFE_FREE(new_server_uid);
}
-INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, int src_mailbox_id, int mail_ids[], int num, int dest_mailbox_id, int *error_code)
+INTERNAL_FUNC int emcore_move_mail_on_server_ex(char *multi_user_name, int account_id, int src_mailbox_id, int mail_ids[], int num, int dest_mailbox_id, int *error_code)
{
EM_DEBUG_FUNC_BEGIN();
MAILSTREAM *stream = NULL;
@@ -470,8 +478,8 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, int src_mailbox_
return false;
}
- ref_account = emcore_get_account_reference(account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
+
if (NULL == ref_account) {
EM_DEBUG_EXCEPTION(" emcore_get_account_reference failed[%d]", account_id);
@@ -484,8 +492,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, int src_mailbox_
goto FINISH_OFF;
}
-
- if (!emcore_connect_to_remote_mailbox(account_id, src_mailbox_id, (void **)&stream, &err_code)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, src_mailbox_id, (void **)&stream, &err_code)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed[%d]", err_code);
goto FINISH_OFF;
@@ -493,6 +500,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, int src_mailbox_
if (NULL != stream) {
g_copyuid_account_id = account_id;
+ g_multi_user_name = EM_SAFE_STRDUP(multi_user_name);
mail_parameters(stream, SET_COPYUID, emcore_mail_copyuid_ex);
EM_DEBUG_LOG("calling mail_copy_full FODLER MAIL COPY ");
/* [h.gahlaut] Break the set of mail_ids into comma separated strings of given length */
@@ -505,7 +513,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, int src_mailbox_
goto FINISH_OFF;
}
- if ( (err_code = emstorage_get_mailbox_by_id(dest_mailbox_id, &dest_mailbox)) != EMAIL_ERROR_NONE || !dest_mailbox) {
+ if ( (err_code = emstorage_get_mailbox_by_id(multi_user_name, dest_mailbox_id, &dest_mailbox)) != EMAIL_ERROR_NONE || !dest_mailbox) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err_code);
goto FINISH_OFF;
}
@@ -514,8 +522,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, int src_mailbox_
for (i = 0; i < string_count; ++i) {
/* Get the set of mail_ds and corresponding server_mail_ids sorted by server mail ids in ascending order */
-
- if (false == emstorage_get_id_set_from_mail_ids(string_list[i], &id_set, &id_set_count, &err_code)) {
+ if (false == emstorage_get_id_set_from_mail_ids(multi_user_name, string_list[i], &id_set, &id_set_count, &err_code)) {
EM_DEBUG_EXCEPTION("emstorage_get_id_set_from_mail_ids failed [%d]", err_code);
goto FINISH_OFF;
}
@@ -607,7 +614,7 @@ FINISH_OFF:
return ret;
}
-int emcore_delete_mails_from_imap4_server(int mail_ids[], int num, int from_server, int *err_code)
+int emcore_delete_mails_from_imap4_server(char *multi_user_name, int mail_ids[], int num, int from_server, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -635,7 +642,7 @@ int emcore_delete_mails_from_imap4_server(int mail_ids[], int num, int from_serv
}
for(i = 0; i < num; i++) {
- if (!emstorage_get_downloaded_mail(mail_ids[i], &mail_tbl_data, false, &err)) {
+ if (!emstorage_get_downloaded_mail(multi_user_name, mail_ids[i], &mail_tbl_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_downloaded_mail failed [%d]", err);
if (err == EMAIL_ERROR_MAIL_NOT_FOUND) { /* not server mail */
@@ -655,7 +662,7 @@ int emcore_delete_mails_from_imap4_server(int mail_ids[], int num, int from_serv
goto FINISH_OFF;
}
- if (!emcore_connect_to_remote_mailbox(mail_tbl_data->account_id, mail_tbl_data->mailbox_id , (void **)&stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mail_tbl_data->account_id, mail_tbl_data->mailbox_id , (void **)&stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -674,8 +681,7 @@ int emcore_delete_mails_from_imap4_server(int mail_ids[], int num, int from_serv
for (i = 0; i < string_count; ++i) {
/* Get the set of mail_ds and corresponding server_mail_ids sorted by server mail ids in ascending order */
-
- if (false == emstorage_get_id_set_from_mail_ids(string_list[i], &id_set, &id_set_count, &err)) {
+ if (false == emstorage_get_id_set_from_mail_ids(multi_user_name, string_list[i], &id_set, &id_set_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_id_set_from_mail_ids failed [%d]", err);
goto FINISH_OFF;
}
@@ -805,7 +811,7 @@ int emcore_delete_mails_from_imap4_server(int mail_ids[], int num, int from_serv
if (delete_success) {
for (index = 0 ; index < num; index++) {
- if (!emstorage_get_downloaded_mail(mail_ids[index], &mail[index], false, &err)) {
+ if (!emstorage_get_downloaded_mail(multi_user_name, mail_ids[index], &mail[index], false, &err)) {
EM_DEBUG_LOG("emstorage_get_uid_by_mail_id failed [%d]", err);
if (err == EMAIL_ERROR_MAIL_NOT_FOUND) {
@@ -817,7 +823,7 @@ int emcore_delete_mails_from_imap4_server(int mail_ids[], int num, int from_serv
if (mail[index]) {
/* Clear entry from mail_read_mail_uid_tbl */
if (mail[index]->server_mail_id != NULL) {
- if (!emstorage_remove_downloaded_mail(mail[index]->account_id, mail[index]->mailbox_name, mail[index]->server_mail_id, true, &err)) {
+ if (!emstorage_remove_downloaded_mail(multi_user_name, mail[index]->account_id, mail[index]->mailbox_name, mail[index]->server_mail_id, true, &err)) {
EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
}
}
@@ -1074,7 +1080,7 @@ FINISH_OFF:
return ret;
}
-int emcore_get_mail_contact_info_with_update(email_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code)
+int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("contact_info[%p], full_address[%s], mail_id[%d], err_code[%p]", contact_info, full_address, mail_id, err_code);
@@ -1175,8 +1181,8 @@ int emcore_get_mail_contact_info_with_update(email_mail_contact_info_t *contact_
is_searched = false;
EM_DEBUG_LOG(" >>>>> emcore_get_mail_contact_info - 10");
-
- err = emcore_get_mail_display_name (email_address,
+
+ err = emcore_get_mail_display_name (multi_user_name, email_address,
&contact_display_name_from_contact_info);
if ( err == EMAIL_ERROR_NONE) {
contact_display_name = contact_display_name_from_contact_info;
@@ -1372,7 +1378,7 @@ FINISH_OFF:
return ret;
}
-int emcore_sync_contact_info(int mail_id, int *err_code)
+int emcore_sync_contact_info(char *multi_user_name, int mail_id, int *err_code)
{
EM_PROFILE_BEGIN(emCoreMailContactSync);
EM_DEBUG_FUNC_BEGIN();
@@ -1394,54 +1400,59 @@ int emcore_sync_contact_info(int mail_id, int *err_code)
memset(&contact_info_cc, 0x00, sizeof(email_mail_contact_info_t));
memset(&contact_info_bcc, 0x00, sizeof(email_mail_contact_info_t));
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
-
goto FINISH_OFF;
}
if (mail->full_address_from != NULL) {
- if (!emcore_get_mail_contact_info_with_update(&contact_info_from, mail->full_address_from, mail_id, &err)) {
+ if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_from, mail->full_address_from, mail_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
}
}
if (mail->full_address_to != NULL) {
- if (!emcore_get_mail_contact_info_with_update(&contact_info_to, mail->full_address_to, mail_id, &err)) {
+ if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_to, mail->full_address_to, mail_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
}
}
if (mail->full_address_cc != NULL) {
- if (!emcore_get_mail_contact_info_with_update(&contact_info_cc, mail->full_address_cc, mail_id, &err)) {
+ if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_cc, mail->full_address_cc, mail_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
}
}
if (mail->full_address_bcc != NULL) {
- if (!emcore_get_mail_contact_info_with_update(&contact_info_bcc, mail->full_address_bcc, mail_id, &err)) {
+ if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_bcc, mail->full_address_bcc, mail_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
}
}
EM_SAFE_FREE(mail->email_address_sender);
mail->email_address_sender = contact_info_from.email_address;
-
+ contact_info_from.contact_name = NULL;
+ contact_info_from.email_address = NULL;
EM_SAFE_FREE(mail->email_address_recipient);
if (mail->full_address_to != NULL) {
mail->email_address_recipient = contact_info_to.email_address;
+ contact_info_to.contact_name = NULL;
+ contact_info_to.email_address = NULL;
}
else if (mail->full_address_cc != NULL) {
mail->email_address_recipient = contact_info_cc.email_address;
+ contact_info_cc.contact_name = NULL;
+ contact_info_cc.email_address = NULL;
}
else if (mail->full_address_bcc != NULL) {
mail->email_address_recipient = contact_info_bcc.email_address;
+ contact_info_bcc.contact_name = NULL;
+ contact_info_bcc.email_address = NULL;
}
/* Update DB */
- if (!emstorage_change_mail_field(mail_id, UPDATE_ALL_CONTACT_INFO, mail, false, &err)) {
+ if (!emstorage_change_mail_field(multi_user_name, mail_id, UPDATE_ALL_CONTACT_INFO, mail, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -1466,7 +1477,7 @@ FINISH_OFF:
/* 1. parsing : alias and address */
/* 2. sync with contact */
/* 3. make glist of address info */
-static int emcore_sync_address_info(email_address_type_t address_type, char *full_address, GList **address_info_list, int *err_code)
+static int emcore_sync_address_info(char *multi_user_name, email_address_type_t address_type, char *full_address, GList **address_info_list, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("address type[%d], address_info_list[%p], full_address[%p]", address_type, address_info_list, full_address);
@@ -1546,7 +1557,7 @@ static int emcore_sync_address_info(email_address_type_t address_type, char *ful
EM_DEBUG_LOG_SEC("Search a contact : address[%s]", email_address);
is_search = false;
- error = emcore_get_mail_display_name (email_address,
+ error = emcore_get_mail_display_name (multi_user_name, email_address,
&contact_display_name_from_contact_info);
if (error == EMAIL_ERROR_NONE) {
EM_DEBUG_LOG_SEC(">>> contact display name[%s]", contact_display_name_from_contact_info);
@@ -1632,7 +1643,7 @@ static gint address_compare(gconstpointer a, gconstpointer b)
return strcmp(recipients_list1->address, recipients_list2->address);
}
-INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char *full_address, int *err_code)
+INTERNAL_FUNC GList *emcore_get_recipients_list(char *multi_user_name, GList *old_recipients_list, char *full_address, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1702,7 +1713,7 @@ INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char
EM_DEBUG_LOG_SEC("Search a contact : address[%s]", email_address);
- err = emcore_get_mail_display_name(email_address, &display_name);
+ err = emcore_get_mail_display_name(multi_user_name, email_address, &display_name);
if ( err == EMAIL_ERROR_NONE) {
EM_DEBUG_LOG_SEC(">>> contact display name[%s]", display_name);
is_search = true;
@@ -1769,7 +1780,7 @@ FINISH_OFF:
return new_recipients_list;
}
-INTERNAL_FUNC int emcore_get_mail_address_info_list(int mail_id, email_address_info_list_t **address_info_list, int *err_code)
+INTERNAL_FUNC int emcore_get_mail_address_info_list(char *multi_user_name, int mail_id, email_address_info_list_t **address_info_list, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], address_info_list[%p]", mail_id, address_info_list);
@@ -1786,10 +1797,8 @@ INTERNAL_FUNC int emcore_get_mail_address_info_list(int mail_id, email_address_i
}
/* get mail from mail table */
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
-
-
goto FINISH_OFF;
}
@@ -1800,21 +1809,21 @@ INTERNAL_FUNC int emcore_get_mail_address_info_list(int mail_id, email_address_i
}
memset(p_address_info_list, 0x00, sizeof(email_address_info_list_t));
- if ((err = emcore_connect_contacts_service()) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_connect_contacts_service(multi_user_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_connect_contacts_service error : [%d]", err);
goto FINISH_OFF;
}
- if (mail->full_address_from && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_FROM, mail->full_address_from, &p_address_info_list->from, &err))
+ if (mail->full_address_from && emcore_sync_address_info(multi_user_name, EMAIL_ADDRESS_TYPE_FROM, mail->full_address_from, &p_address_info_list->from, &err))
failed = false;
- if (mail->full_address_to && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_TO, mail->full_address_to, &p_address_info_list->to, &err))
+ if (mail->full_address_to && emcore_sync_address_info(multi_user_name, EMAIL_ADDRESS_TYPE_TO, mail->full_address_to, &p_address_info_list->to, &err))
failed = false;
- if (mail->full_address_cc && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_CC, mail->full_address_cc, &p_address_info_list->cc, &err))
+ if (mail->full_address_cc && emcore_sync_address_info(multi_user_name, EMAIL_ADDRESS_TYPE_CC, mail->full_address_cc, &p_address_info_list->cc, &err))
failed = false;
- if (mail->full_address_bcc && emcore_sync_address_info(EMAIL_ADDRESS_TYPE_BCC, mail->full_address_bcc, &p_address_info_list->bcc, &err))
+ if (mail->full_address_bcc && emcore_sync_address_info(multi_user_name, EMAIL_ADDRESS_TYPE_BCC, mail->full_address_bcc, &p_address_info_list->bcc, &err))
failed = false;
- if ((err = emcore_disconnect_contacts_service()) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_disconnect_contacts_service(multi_user_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_disconnect_contacts_service failed : [%d]", err);
}
@@ -1845,7 +1854,7 @@ FINISH_OFF:
* succeed : EMAIL_ERROR_NONE
* fail : error code
*/
-INTERNAL_FUNC int emcore_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data)
+INTERNAL_FUNC int emcore_get_mail_data(char *multi_user_name, int input_mail_id, email_mail_data_t **output_mail_data)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], output_mail_data[%p]", input_mail_id, output_mail_data);
@@ -1862,7 +1871,7 @@ INTERNAL_FUNC int emcore_get_mail_data(int input_mail_id, email_mail_data_t **ou
SNPRINTF(conditional_clause_string, QUERY_SIZE, "WHERE mail_id = %d", input_mail_id);
- if(!emstorage_query_mail_tbl(conditional_clause_string, true, &result_mail_tbl, &result_mail_count, &error)) {
+ if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause_string, true, &result_mail_tbl, &result_mail_count, &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl falied [%d]", error);
goto FINISH_OFF;
}
@@ -1901,7 +1910,7 @@ int emcore_check_drm(emstorage_attachment_tbl_t *input_attachment_tb_data)
* succeed : 1
* fail : 0
*/
-INTERNAL_FUNC int emcore_get_attachment_info(int attachment_id, email_attachment_data_t **attachment, int *err_code)
+INTERNAL_FUNC int emcore_get_attachment_info(char *multi_user_name, int attachment_id, email_attachment_data_t **attachment, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], err_code[%p]", attachment_id, attachment, err_code);
@@ -1917,9 +1926,8 @@ INTERNAL_FUNC int emcore_get_attachment_info(int attachment_id, email_attachment
emstorage_attachment_tbl_t *attachment_tbl = NULL;
/* get attachment from attachment tbl */
- if (!emstorage_get_attachment(attachment_id, &attachment_tbl, true, &err) || !attachment_tbl) {
+ if (!emstorage_get_attachment(multi_user_name, attachment_id, &attachment_tbl, true, &err) || !attachment_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -1962,7 +1970,7 @@ FINISH_OFF:
* succeed : EMAIL_ERROR_NONE
* fail : error code
*/
-INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
+INTERNAL_FUNC int emcore_get_attachment_data_list(char *multi_user_name, int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], output_attachment_data[%p], output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count);
@@ -1978,9 +1986,8 @@ INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, email_attac
email_attachment_data_t *temp_attachment_data = NULL;
/* get attachment from attachment tbl */
- if ( (err = emstorage_get_attachment_list(input_mail_id, true, &attachment_tbl_list, &attachment_tbl_count)) != EMAIL_ERROR_NONE ){
+ if ( (err = emstorage_get_attachment_list(multi_user_name, input_mail_id, true, &attachment_tbl_list, &attachment_tbl_count)) != EMAIL_ERROR_NONE ){
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -2023,262 +2030,7 @@ FINISH_OFF:
return err;
}
-
-INTERNAL_FUNC int emcore_download_attachment (int account_id, int mail_id, int nth,
- int cancellable, int event_handle, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], nth[%d], err_code[%p]", account_id, mail_id, nth, err_code);
-
- int err = EMAIL_ERROR_NONE;
-
- if (mail_id < 1) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
-
- if (err_code != NULL)
- *err_code = err;
-
- emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, 0, nth, err);
- return false;
- }
-
- int ret = false;
- MAILSTREAM *stream = NULL;
- BODY *mbody = NULL;
- emstorage_mail_tbl_t *mail = NULL;
- emstorage_attachment_tbl_t *attachment = NULL;
- struct attachment_info *ai = NULL;
- struct _m_content_info *cnt_info = NULL;
- void *tmp_stream = NULL;
- char *server_uid = NULL, buf[1024];
- int msg_no = 0;
- emstorage_attachment_tbl_t *attachment_list = NULL;
- int current_attachment_no = 0;
- int attachment_count_to_be_downloaded = 0; /* how many attachments should be downloaded */
- int i = 0;
- int server_mbox_id = 0;
- int decoded_attachment_size = 0;
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- only_body_download = false;
-
- /* get mail from mail table. */
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!mail->server_mail_status) {
- EM_DEBUG_EXCEPTION("not synchronous mail...");
- err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
- goto FINISH_OFF;
- }
-
- if (nth == 0) { /* download all attachments, nth starts from 1, not zero */
- /* get attachment list from db */
- attachment_count_to_be_downloaded = EMAIL_ATTACHMENT_MAX_COUNT;
- if ( (err = emstorage_get_attachment_list(mail_id, true, &attachment_list, &attachment_count_to_be_downloaded)) != EMAIL_ERROR_NONE ){
- EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
- goto FINISH_OFF;
- }
- }
- else { /* download only nth attachment */
- attachment_count_to_be_downloaded = 1;
- if (!emstorage_get_attachment_nth(mail_id, nth, &attachment_list, true, &err) || !attachment_list) {
- EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
-
- goto FINISH_OFF;
- }
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- account_id = mail->account_id;
- server_uid = EM_SAFE_STRDUP(mail->server_mail_id);
- server_mbox_id = mail->mailbox_id;
-
- if (attachment_count_to_be_downloaded == 1 && attachment_list) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, attachment_list[0].attachment_name, nth, 0))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
- }
-
- /* open mail server. */
- if (!emcore_connect_to_remote_mailbox(account_id, server_mbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
- EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
- if(err == EMAIL_ERROR_NO_SUCH_HOST)
- err = EMAIL_ERROR_CONNECTION_FAILURE;
- goto FINISH_OFF;
- }
-
- stream = (MAILSTREAM *)tmp_stream;
-
- for (i = 0; i < attachment_count_to_be_downloaded; i++) {
- EM_DEBUG_LOG(" >>>>>> Attachment Downloading [%d / %d] start", i + 1, attachment_count_to_be_downloaded);
-
- attachment = attachment_list + i;
- if (nth == 0) /* download all attachments, nth starts from 1, not zero */
- current_attachment_no = i + 1; /* attachment no */
- else /* download only nth attachment */
- current_attachment_no = nth; /* attachment no */
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- /*free cnt_info before reusing*/
- if (cnt_info) {
- emcore_free_content_info(cnt_info);
- EM_SAFE_FREE(cnt_info);
- }
-
- if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) {
- EM_DEBUG_EXCEPTION("malloc failed...");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- cnt_info->grab_type = GRAB_TYPE_ATTACHMENT; /* attachment */
- cnt_info->file_no = current_attachment_no; /* attachment no */
-
-#ifdef CHANGE_HTML_BODY_TO_ATTACHMENT
- /* text/html be changed to attachment, this isn't real attachment in RFC822. */
- if (html_changed)
- cnt_info->file_no--;
-#endif
-
- /* set sparep(member of BODY) memory free function. */
- mail_parameters(stream, SET_FREEBODYSPAREP, emcore_free_body_sparep);
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- msg_no = server_uid? atoi(server_uid): 0;
-
- /* get body structure. */
- /* don't free mbody because mbody is freed in closing mail_stream. */
- if ((!stream) || emcore_get_body_structure(stream, msg_no, &mbody, &err) < 0) {
- EM_DEBUG_EXCEPTION("emcore_get_body_structure failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- /* set body fetch section. */
- if (emcore_set_fetch_body_section(mbody, false, NULL, NULL, &err) < 0) {
- EM_DEBUG_EXCEPTION("emcore_set_fetch_body_section failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* download attachment. */
- _imap4_received_body_size = 0;
- _imap4_last_notified_body_size = 0;
- _imap4_total_body_size = 0; /* This will be assigned in imap_mail_write_body_to_file() */
- _imap4_download_noti_interval_value = 0; /* This will be assigned in imap_mail_write_body_to_file() */
-
- EM_DEBUG_LOG("cnt_info->file_no[%d], current_attachment_no[%d]", cnt_info->file_no, current_attachment_no);
- if (emcore_get_body(stream, account_id, mail_id, msg_no, mbody, NULL, cnt_info, &err) < 0) {
- EM_DEBUG_EXCEPTION("emcore_get_body failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- /* select target attachment information. */
- for (ai = cnt_info->file ; ai; ai = ai->next) {
- EM_DEBUG_LOG_SEC("[in loop] save[%s] name[%s] no[%d]", ai->save, ai->name, cnt_info->file_no);
-
- if (ai->type == INLINE_ATTACHMENT)
- continue;
-
- if (--cnt_info->file_no == 0)
- break;
- }
- EM_DEBUG_LOG("selected cnt_info->file_no = %d, ai = %p", cnt_info->file_no, ai);
-
- if (cnt_info->file_no == 0 && ai) {
- /* rename temporary file to real file. */
- if (!emstorage_create_dir(account_id, mail_id, current_attachment_no, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_get_save_name(account_id, mail_id, current_attachment_no, ai->name, buf, sizeof(buf), &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_move_file(ai->save, buf, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
- err = EMAIL_ERROR_INVALID_ATTACHMENT_SAVE_NAME;
- goto FINISH_OFF;
- }
-
- EM_SAFE_FREE(ai->save);
-
- emcore_get_file_size(buf, &decoded_attachment_size, NULL);
- EM_DEBUG_LOG("decoded_attachment_size [%d]", decoded_attachment_size);
- attachment->attachment_size = decoded_attachment_size;
- attachment->attachment_path = EM_SAFE_STRDUP(buf);
- attachment->content_id = EM_SAFE_STRDUP(ai->content_id);
- attachment->attachment_save_status = 1;
-
- /* update attachment information. */
- if (!emstorage_change_attachment_field(mail_id, UPDATE_SAVENAME, attachment, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
- /* delete created file. */
- remove(buf);
-
- goto FINISH_OFF;
- }
- }
- else {
- EM_DEBUG_EXCEPTION("invalid attachment sequence...");
- err = EMAIL_ERROR_INVALID_ATTACHMENT;
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG(" >>>>>> Attachment Downloading [%d / %d] completed", i+1, attachment_count_to_be_downloaded);
- }
-
- ret = true;
-
-FINISH_OFF:
-
- if (ret == true)
- emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FINISH, mail_id, NULL, nth, 0);
- else {
- if (err != EMAIL_ERROR_CANCELLED)
- emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, nth, err);
- }
-
- EM_SAFE_FREE(server_uid);
-
- if (stream) {
- stream = mail_close (stream);
- }
-
- if (attachment_list)
- emstorage_free_attachment(&attachment_list, attachment_count_to_be_downloaded, NULL);
- if (cnt_info) {
- emcore_free_content_info(cnt_info);
- EM_SAFE_FREE(cnt_info);
- }
-
- if (mail)
- emstorage_free_mail(&mail, 1, NULL);
-
- if (err_code != NULL)
- *err_code = err;
-
- EM_DEBUG_FUNC_END();
- return ret;
-}
-
-INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
+INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int mail_id, int nth,
int cancellable, int event_handle, int auto_download, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], nth[%d], err_code[%p]", mail_id, nth, err_code);
@@ -2308,7 +2060,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
struct _m_content_info *cnt_info = NULL;
void *tmp_stream = NULL;
char *server_uid = NULL;
- char buf[1024];
+ char move_buf[512], path_buf[512];
int msg_no = 0;
int account_id = 0;
@@ -2325,7 +2077,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
/* get mail from mail table. */
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -2337,16 +2089,15 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
}
if (nth == 0) { /* download all attachments, nth starts from 1, not zero */
- if ((err = emstorage_get_attachment_list(mail_id, true, &attachment_list, &attachment_count)) != EMAIL_ERROR_NONE ) {
+ if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &attachment_list, &attachment_count)) != EMAIL_ERROR_NONE ) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
goto FINISH_OFF;
}
}
else { /* download only nth attachment */
attachment_count = 1;
- if (!emstorage_get_attachment_nth(mail_id, nth, &attachment_list, true, &err) || !attachment_list) {
+ if (!emstorage_get_attachment_nth(multi_user_name, mail_id, nth, &attachment_list, true, &err) || !attachment_list) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
-
goto FINISH_OFF;
}
}
@@ -2367,7 +2118,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
/* open mail server. */
if (!auto_download) {
- if (!emcore_connect_to_remote_mailbox(account_id, server_mbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, server_mbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
if(err == EMAIL_ERROR_NO_SUCH_HOST)
err = EMAIL_ERROR_CONNECTION_FAILURE;
@@ -2378,7 +2129,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
}
else {
MAILSTREAM **mstream = NULL;
- mstream = emcore_get_recv_stream (account_id, server_mbox_id, &err);
+ mstream = emcore_get_recv_stream (multi_user_name, account_id, server_mbox_id, &err);
if (!mstream) {
EM_DEBUG_EXCEPTION("emcore_get_recv_stream failed [%d]", err);
@@ -2481,34 +2232,37 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
}
/* rename temporary file to real file. */
- if (!emstorage_create_dir(account_id, mail_id, current_attachment_no, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, current_attachment_no, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(account_id, mail_id, current_attachment_no, ai->name, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, current_attachment_no, ai->name, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(ai->save, buf, false, &err)) {
+ if (!emstorage_move_file(ai->save, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
err = EMAIL_ERROR_INVALID_ATTACHMENT_SAVE_NAME;
goto FINISH_OFF;
}
- emcore_get_file_size(buf, &decoded_attachment_size, NULL);
+ emcore_get_file_size(move_buf, &decoded_attachment_size, NULL);
EM_DEBUG_LOG("decoded_attachment_size [%d]", decoded_attachment_size);
attachment->attachment_size = decoded_attachment_size;
- attachment->attachment_path = EM_SAFE_STRDUP(buf);
+ attachment->attachment_path = EM_SAFE_STRDUP(path_buf);
attachment->content_id = EM_SAFE_STRDUP(ai->content_id);
attachment->attachment_save_status = 1;
/* update attachment information. */
- if (!emstorage_change_attachment_field(mail_id, UPDATE_SAVENAME, attachment, true, &err)) {
+ if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, attachment, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
/* delete created file. */
- g_remove(buf);
+ g_remove(move_buf);
goto FINISH_OFF;
}
@@ -2570,7 +2324,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
emstorage_mail_tbl_t *mail = NULL;
emstorage_attachment_tbl_t *attachment = NULL;
void *tmp_stream = NULL;
- char *s_uid = NULL, *server_mbox = NULL, buf[512];
+ char *s_uid = NULL, *server_mbox = NULL, move_buf[512], path_buf[512];
emstorage_attachment_tbl_t *attachment_list = NULL;
int current_attachment_no = 0;
int attachment_count_to_be_downloaded = 0; /* how many attachments should be downloaded */
@@ -2590,8 +2344,10 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
email_file_list *pFileList = NULL;
#endif /* SUPPORT_EXTERNAL_MEMORY */
int decoded_attachment_size = 0;
+
+ memset(move_buf, 0x00, 512);
+ memset(path_buf, 0x00, 512);
- memset(buf, 0x00, 512);
/* CID FIX 31230 */
if (mail_id < 1 || !nth) {
EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d], nth[%p]", account_id, mail_id, nth);
@@ -2619,18 +2375,15 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
/* download all attachments, nth starts from 1, not zero */
/* get attachment list from db */
attachment_count_to_be_downloaded = EMAIL_ATTACHMENT_MAX_COUNT;
- if ( (err = emstorage_get_attachment_list(mail_id, true, &attachment_list, &attachment_count_to_be_downloaded)) != EMAIL_ERROR_NONE || !attachment_list){
+ if ( (err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &attachment_list, &attachment_count_to_be_downloaded)) != EMAIL_ERROR_NONE || !attachment_list){
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
-
goto FINISH_OFF;
}
}
else { /* download only nth attachment */
attachment_count_to_be_downloaded = 1;
- if (!emstorage_get_attachment_nth(mail_id, attachment_no, &attachment_list, true, &err) || !attachment_list) {
+ if (!emstorage_get_attachment_nth(multi_user_name, mail_id, attachment_no, &attachment_list, true, &err) || !attachment_list) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
-
-
goto FINISH_OFF;
}
}
@@ -2639,10 +2392,8 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
/* get mail from mail table. */
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
-
-
goto FINISH_OFF;
}
@@ -2657,7 +2408,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
/* open mail server. */
- if (!emcore_connect_to_remote_mailbox(account_id, server_mbox, (void **)&tmp_stream, &err) || !tmp_stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, server_mbox, (void **)&tmp_stream, &err) || !tmp_stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
status = EMAIL_DOWNLOAD_CONNECTION_FAIL;
@@ -2727,31 +2478,29 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
}
#endif /* SUPPORT_EXTERNAL_MEMORY */
- if (!emstorage_create_dir(account_id, mail_id, attachment_no, &err)) {
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_no, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(account_id, mail_id, attachment_no, attachment->name, buf, &err)) {
+ if (!emstorage_get_save_name(account_id, mail_id, attachment_no, attachment->name, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(savefile, buf, false, &err)) {
+ if (!emstorage_move_file(savefile, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
-
goto FINISH_OFF;
}
- emcore_get_file_size(buf, &decoded_attachment_size, NULL);
+ emcore_get_file_size(move_buf, &decoded_attachment_size, NULL);
EM_DEBUG_LOG("decoded_attachment_size [%d]", decoded_attachment_size);
attachment->attachment_size = decoded_attachment_size;
- attachment->attachment_path = EM_SAFE_STRDUP(buf);
+ attachment->attachment_path = EM_SAFE_STRDUP(path_buf);
attachment->attachment_save_status = 1;
/* update attachment information. */
- if (!emstorage_change_attachment_field(mail_id, UPDATE_SAVENAME, attachment, true, &err)) {
+ if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, attachment, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -2792,710 +2541,16 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
}
#endif
-/*
-Three thread can call this function :
- event worker thread,
- partial body thread,
- thread_func_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT
- CANCEL should be revised, later
-*/
-INTERNAL_FUNC int emcore_download_body_multi_sections_bulk ( void *mail_stream,
- int account_id,
- int mail_id,
- int verbose,
- int with_attach,
- int limited_size,
- int event_handle,
- int cancellable,
- int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("mail_stream[%p], account_id[%d], mail_id[%d], verbose[%d], with_attach[%d], event_handle [%d]",
- mail_stream, account_id, mail_id, verbose, with_attach, event_handle);
-
- int ret = false;
- int err = EMAIL_ERROR_NONE;
- int pop3_body_size = 0;
- int pop3_downloaded_size = 0;
- int p_with_attach = with_attach;
- MAILSTREAM *stream = NULL;
- BODY *mbody = NULL;
- PARTLIST *section_list = NULL;
- email_internal_mailbox_t mailbox = {0};
- emstorage_mail_tbl_t *mail = NULL;
- emstorage_attachment_tbl_t attachment = {0};
- email_account_t *ref_account = NULL;
- struct attachment_info *ai = NULL;
- struct _m_content_info *cnt_info = NULL;
- char *s_uid = NULL;
- char buf[512] = {0};
- int msgno = 0, attachment_num = 1, local_attachment_count = 0, local_inline_content_count = 0;
- int iActualSize = 0;
- char html_body[MAX_PATH] = {0};
- emcore_uid_list *uid_list = NULL;
-#ifdef CHANGE_HTML_BODY_TO_ATTACHMENT
- int html_changed = 0;
-#endif
-
- if (mail_id < 1) {
- EM_DEBUG_EXCEPTION("mail_stream[%p], account_id[%d], mail_id[%d], verbose[%d], with_attach[%d]",
- mail_stream, account_id, mail_id, verbose, with_attach);
- err = EMAIL_ERROR_INVALID_PARAM;
- if (err_code != NULL)
- *err_code = err;
-
- emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, event_handle, err);
- return false;
- }
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- only_body_download = true;
-
- /* looking for mail by mail_id in DB*/
- if (!emstorage_get_mail_by_id (mail_id, &mail, true, &err) || !mail) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* if mail is downloaded */
- if (mail->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) {
- /* after entering viewer, the mail has been just downloaded */
- if (!emcore_notify_network_event (NOTI_DOWNLOAD_BODY_START,
- mail_id,
- "dummy-file", /* ?? */
- mail->mail_size, /*_pop3_total_body_size*/
- 0))
- EM_DEBUG_EXCEPTION ("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] error >>>> ");
- else
- EM_DEBUG_LOG("NOTI_DOWNLOAD_BODY_START notified (%d / %d)",
- 0, mail->mail_size);
-
- err = EMAIL_ERROR_NONE; //EMAIL_ERROR_MAIL_IS_ALREADY_DOWNLOADED;
- ret = true;
- goto FINISH_OFF;
- }
-
- s_uid = EM_SAFE_STRDUP(mail->server_mail_id);
- attachment.account_id = mail->account_id;
- attachment.mail_id = mail->mail_id;
- attachment.mailbox_id = mail->mailbox_id;
- attachment.attachment_save_status = 0;
-
- if (!(ref_account = emcore_get_account_reference(account_id))) {
- EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
- err = EMAIL_ERROR_INVALID_ACCOUNT;
- goto FINISH_OFF;
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- /* open mail server. */
- if (!mail_stream) {
-#if 0
- MAILSTREAM *tmp_stream = NULL;
- if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
- EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
- goto FINISH_OFF;
- }
-
- stream = (MAILSTREAM *)tmp_stream;
-#endif
- MAILSTREAM **mstream = NULL;
- mstream = emcore_get_recv_stream (account_id, mail->mailbox_id, &err);
- if (!mstream) {
- EM_DEBUG_EXCEPTION("emcore_get_recv_stream failed [%d]", err);
- goto FINISH_OFF;
- }
- stream = (MAILSTREAM *)*mstream;
- }
- else
- stream = (MAILSTREAM *)mail_stream;
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
- /* POP3 */
- /* in POP3 case, both text and attachment are downloaded in this call. */
- cnt_info->grab_type = GRAB_TYPE_TEXT | GRAB_TYPE_ATTACHMENT;
-
- mailbox.account_id = account_id;
-
- /* download all uids from server. */
- if (!emcore_download_uid_all (stream, &mailbox, &uid_list, NULL, NULL, 0, EM_CORE_GET_UIDS_FOR_NO_DELETE, &err)) {
- EM_DEBUG_EXCEPTION("emcore_download_uid_all failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* get mesg number to be related to last download mail from uid list file */
- if (!emcore_get_msgno(uid_list, s_uid, &msgno, &err)) {
- EM_DEBUG_EXCEPTION("emcore_get_msgno failed [%d]", err);
- err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
- goto FINISH_OFF;
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- _pop3_received_body_size = 0;
- _pop3_total_body_size = 0;
- _pop3_last_notified_body_size = 0;
- _pop3_receiving_mail_id = mail_id;
-
- /* send read mail commnad. */
- if (!emcore_mail_cmd_read_mail_pop3(stream, msgno, limited_size, &pop3_downloaded_size, &pop3_body_size, &err)) {
- EM_DEBUG_EXCEPTION("emcore_mail_cmd_read_mail_pop3 failed [%d]", err);
- goto FINISH_OFF;
- }
-
- _pop3_total_body_size = pop3_body_size;
-
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, "dummy-file", _pop3_total_body_size, 0))
- EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] failed >>>> ");
- else
- EM_DEBUG_LOG("NOTI_DOWNLOAD_BODY_START notified (%d / %d)", 0, _pop3_total_body_size);
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- /* save message into tempfile */
- /* parsing mime from stream. */
-#ifdef __FEATURE_USE_GMIME__
- char sock_buf[1024] = {0, };
- int fd = 0;
- char *tmp_path = emcore_mime_get_save_file_name(&err);
- EM_DEBUG_LOG ("tmp_path[%s]", tmp_path);
- err = em_open(tmp_path, O_WRONLY | O_CREAT, 0644, &fd);
- if (err != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("open error [%d]: holder is a filename that will be saved.", err);
- }
-
- while(emcore_mime_get_line_from_sock((void *)stream, sock_buf, 1024, &err)) {
- if (write(fd, sock_buf, EM_SAFE_STRLEN(sock_buf)) != EM_SAFE_STRLEN(sock_buf)) {
- EM_DEBUG_EXCEPTION("write failed");
- }
-
- if (cancellable) {
- int type = 0;
- if (!emcore_check_event_thread_status(&type, event_handle)) {
- EM_DEBUG_LOG ("CANCELED EVENT: type [%d]", type);
- err = EMAIL_ERROR_CANCELLED;
- EM_SAFE_CLOSE (fd);
- g_remove(tmp_path);
- goto FINISH_OFF;
- }
- }
- }
- EM_SAFE_CLOSE (fd);
-
- emcore_gmime_pop3_parse_mime(tmp_path, cnt_info, &err);
-
- g_remove(tmp_path);
-#else
- if (!emcore_parse_mime(stream, 0, cnt_info, &err)) {
- EM_DEBUG_EXCEPTION("emcore_parse_mime failed [%d]", err);
- goto FINISH_OFF;
- }
-#endif /* __FEATURE_USE_GMIME__ */
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- }
- else { /* in IMAP case, both text and attachment list are downloaded in this call. */
- /* This flag is just for downloading mailbox.(sync header), don't be used when retrieve body. */
- if (p_with_attach > 0)
- cnt_info->grab_type = GRAB_TYPE_TEXT | GRAB_TYPE_ATTACHMENT;
- else
- cnt_info->grab_type = GRAB_TYPE_TEXT;
-
- int uid = s_uid? atoi(s_uid):0; /*prevent 39118*/
-
- /* set sparep(member of BODY) memory free function */
- mail_parameters(stream, SET_FREEBODYSPAREP, emcore_free_body_sparep);
-
- /* get body strucutre. */
- /* don't free mbody because mbody is freed in closing mail_stream. */
- if (emcore_get_body_structure(stream, uid, &mbody, &err) < 0 || (mbody == NULL)) {
- EM_DEBUG_EXCEPTION("emcore_get_body_structure failed [%d]", err);
- err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
- goto FINISH_OFF;
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- if (mbody->type == TYPEMULTIPART) {
- EM_DEBUG_LOG(">>> check multipart body size to download : only_body_download[%d]", only_body_download);
- PART *part_child = mbody->nested.part;
- int counter = 0;
-
- char filename[MAX_PATH+1] = {0, };
- int is_attachment = 0;
- while (part_child) {
- BODY *body = &(part_child->body);
- if (only_body_download == true) {
- if (((body->id) && EM_SAFE_STRLEN(body->id) > 1) || (body->location))
- is_attachment = 0;
- else if (body->disposition.type) { /* "attachment" or "inline" or etc... */
- PARAMETER *param = body->disposition.parameter;
-
- while (param) {
- EM_DEBUG_LOG("param->attribute [%s], param->value [%s]", param->attribute, param->value);
-
- if (!strcasecmp(param->attribute, "filename")) { /* attribute is "filename" */
- strncpy(filename, param->value, MAX_PATH);
- EM_DEBUG_LOG_SEC(">>>>> FILENAME [%s] ", filename);
- break;
- }
- param = param->next;
- }
-
- is_attachment = 1;
-
- if (!*filename) {
- /* it may be report msg */
- if (body->disposition.type[0] == 'i' || body->disposition.type[0] == 'I')
- is_attachment = 0;
- }
- }
-
- if (is_attachment == 0) {
- EM_DEBUG_LOG("%d : body->size.bytes[%ld]", counter+1, body->size.bytes);
- multi_part_body_size = multi_part_body_size + body->size.bytes;
- }
- }
- else {
- /* download all */
- EM_DEBUG_LOG("%d : body->size.bytes[%ld]", counter+1, body->size.bytes);
- multi_part_body_size = multi_part_body_size + body->size.bytes;
- }
- part_child = part_child->next;
- counter++;
- }
- }
-
- /* set body fetch section. */
- if (emcore_set_fetch_body_section(mbody, true, NULL, &iActualSize, &err) < 0) {
- EM_DEBUG_EXCEPTION("emcore_set_fetch_body_section failed [%d]", err);
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG("iActualSize [%d]", iActualSize);
- multi_part_body_size = iActualSize;
-
- _imap4_received_body_size = 0;
- _imap4_last_notified_body_size = 0;
-
- if (multi_part_body_size > 0) { /* download multiparts */
- _imap4_total_body_size = multi_part_body_size;
- _imap4_download_noti_interval_value = DOWNLOAD_NOTI_INTERVAL_PERCENT * multi_part_body_size / 100;
- }
- else { /* download only one body part */
- _imap4_total_body_size = 0; /* This will be assigned in imap_mail_write_body_to_file() */
- _imap4_download_noti_interval_value = 0; /* This will be assigned in imap_mail_write_body_to_file() */
- }
-
- /* save message into tempfile */
- /* download body text and get attachment list. */
- if (emcore_get_body_part_list_full(stream, uid, account_id, mail_id, mbody, cnt_info, &err, section_list, event_handle) < 0) {
- EM_DEBUG_EXCEPTION("emcore_get_body_part_list_full failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
- }
-
- if (cnt_info->text.plain) {
- char *charset_plain_text = NULL;
- EM_DEBUG_LOG_SEC("cnt_info->text.plain [%s]", cnt_info->text.plain);
-
- char *file_content = NULL;
- int content_size = 0;
-
- if (emcore_get_content_from_file(cnt_info->text.plain, &file_content, &content_size) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_get_content_from_file failed");
- }
-
- if (file_content && content_size > 0) {
- char escape = 0x1b;
- char detector[25] = {0,};
- snprintf(detector, sizeof(detector), "%c$B", escape);
- if (g_strrstr(cnt_info->text.plain_charset, "UTF-8") && g_strrstr(file_content, detector)) {
- cnt_info->text.plain_charset = "ISO-2022-JP";
- }
- }
-
- EM_SAFE_FREE(file_content);
-
- if (cnt_info->text.plain_charset)
- charset_plain_text = cnt_info->text.plain_charset;
- else {
- if (mail->default_charset) {
- charset_plain_text = mail->default_charset;
- } else {
- charset_plain_text = "UTF-8";
- }
- }
- EM_DEBUG_LOG("PLAIN DEFAULT CHARSET : %s", charset_plain_text);
-
- if (!emstorage_create_dir(account_id, mail_id, 0, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_get_save_name(account_id, mail_id, 0, charset_plain_text, buf, sizeof(buf), &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_move_file(cnt_info->text.plain, buf, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
- goto FINISH_OFF;
- }
-
- EM_SAFE_FREE(mail->file_path_plain);
- mail->file_path_plain = EM_SAFE_STRDUP(buf);
- EM_DEBUG_LOG_SEC("mail->file_path_plain [%s]", mail->file_path_plain);
- }
-
- if (cnt_info->text.html) {
- if (!emstorage_create_dir(account_id, mail_id, 0, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (cnt_info->text.html_charset != NULL) {
- memcpy(html_body, cnt_info->text.html_charset, EM_SAFE_STRLEN(cnt_info->text.html_charset));
- strcat(html_body, HTML_EXTENSION_STRING);
- }
- else if (cnt_info->text.plain_charset != NULL) {
- memcpy(html_body, cnt_info->text.plain_charset, EM_SAFE_STRLEN(cnt_info->text.plain_charset));
- strcat(html_body, HTML_EXTENSION_STRING);
- }
- else {
- memcpy(html_body, "UTF-8.htm", strlen("UTF-8.htm"));
- }
- if (!emstorage_get_save_name(account_id, mail_id, 0, html_body, buf, sizeof(buf), &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_move_file(cnt_info->text.html, buf, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
- goto FINISH_OFF;
- }
- EM_SAFE_FREE(mail->file_path_html);
- mail->file_path_html = EM_SAFE_STRDUP(buf);
- }
-
- if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 && limited_size != NO_LIMITATION &&
- limited_size < pop3_body_size) {
- mail->body_download_status = (mail->body_download_status & ~0x00000003) | EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED;
- }
- else {
- mail->body_download_status = (mail->body_download_status & ~0x00000003) | EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED;
- p_with_attach = true;
- }
-
- /* Update local_preview_text */
- if ((err = emcore_get_preview_text_from_file (mail->file_path_plain, mail->file_path_html,
- MAX_PREVIEW_TEXT_LENGTH, &mail->preview_text)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file error [%d]", err);
- }
-
-#ifdef CHANGE_HTML_BODY_TO_ATTACHMENT
- if (html_changed) mail->flag2 = 1;
-#endif
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- for (ai = cnt_info->file; ai; ai = ai->next, attachment_num++) {
-
- if (ai->type == 1)
- local_inline_content_count++;
- else
- local_attachment_count++;
-
- if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && only_body_download && ai->type != INLINE_ATTACHMENT)
- continue;
-
- attachment.attachment_id = attachment_num;
- attachment.attachment_size = ai->size;
- attachment.attachment_path = ai->save;
- attachment.content_id = ai->content_id;
- attachment.attachment_name = ai->name;
- attachment.attachment_drm_type = ai->drm;
- attachment.attachment_inline_content_status = ai->type == 1;
- attachment.attachment_mime_type = ai->attachment_mime_type;
-
- if (p_with_attach)
- attachment.attachment_save_status = EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED;
- else
- attachment.attachment_save_status = (ai->type == 1) ? EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED:EMAIL_BODY_DOWNLOAD_STATUS_NONE;
-
-#ifdef __ATTACHMENT_OPTI__
- attachment.encoding = ai->encoding;
- attachment.section = ai->section;
-#endif
- EM_DEBUG_LOG("attachment.attachment_id[%d]", attachment.attachment_id);
- EM_DEBUG_LOG("attachment.attachment_size[%d]", attachment.attachment_size);
- EM_DEBUG_LOG_SEC("attachment.attachment_path[%s]", attachment.attachment_path);
- EM_DEBUG_LOG("attachment.content_id[%s]", attachment.content_id);
- EM_DEBUG_LOG_SEC("attachment.attachment_name[%s]", attachment.attachment_name);
- EM_DEBUG_LOG("attachment.attachment_drm_type[%d]", attachment.attachment_drm_type);
- EM_DEBUG_LOG("attachment.attachment_save_status[%d]", attachment.attachment_save_status);
- EM_DEBUG_LOG("attachment.attachment_inline_content_status[%d]", attachment.attachment_inline_content_status);
-
- if (ai->save) {
- /* in POP3 case, rename temporary file to real file. */
- if (ai->type == 1) { /* it is inline content */
- if (!emstorage_create_dir(account_id, mail_id, 0, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- goto FINISH_OFF;
- }
- if (!emstorage_get_save_name(account_id, mail_id, 0, attachment.attachment_name, buf, sizeof(buf), &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- goto FINISH_OFF;
- }
- }
- else {
- if (!emstorage_create_dir(account_id, mail_id, attachment_num, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_get_save_name(account_id, mail_id, attachment_num, attachment.attachment_name, buf, sizeof(buf), &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- goto FINISH_OFF;
- }
- }
-
- if (!emstorage_move_file(ai->save, buf, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
-
- /* delete all created files. */
- if (!emstorage_get_save_name(account_id, mail_id, 0, NULL, buf, sizeof(buf),NULL)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed...");
- /* goto FINISH_OFF; */
- }
-
- if (!emstorage_delete_dir(buf, NULL)) {
- EM_DEBUG_EXCEPTION("emstorage_delete_dir failed...");
- /* goto FINISH_OFF; */
- }
-
-
- goto FINISH_OFF;
- }
-
- EM_SAFE_FREE(ai->save);
- ai->save = EM_SAFE_STRDUP(buf);
-
- attachment.attachment_path = ai->save;
-
- }
-
-#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
- /* Information : Attachment info already saved if partial body is dowloaded. */
- if (ai->type) {
- emstorage_attachment_tbl_t *attch_info = NULL;
- /* Get attachment details */
- if (!emstorage_get_attachment_nth(mail_id, attachment.attachment_id, &attch_info, true, &err) || !attch_info) {
- EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
- if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND) { /* save only attachment file. */
- if (!emstorage_add_attachment(&attachment, 0, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
- if (attch_info)
- emstorage_free_attachment(&attch_info, 1, NULL);
- /* delete all created files. */
- if (!emstorage_get_save_name(account_id, mail_id, 0, NULL, buf, sizeof(buf), &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_delete_dir(buf, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* ROLLBACK TRANSACTION; */
- emstorage_rollback_transaction(NULL, NULL, NULL);
-
-
- goto FINISH_OFF;
- }
- }
- }
- else {
- EM_DEBUG_LOG("Attachment info already exists...!");
- /* Update attachment size */
- EM_DEBUG_LOG("attachment_size [%d], ai->size [%d]", attch_info->attachment_size, ai->size);
- attch_info->attachment_size = ai->size;
- attch_info->attachment_save_status = attachment.attachment_save_status;
- if (!emstorage_update_attachment(attch_info, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_update_attachment failed [%d]", err);
- emstorage_free_attachment(&attch_info, 1, NULL); /*prevent 17956*/
- goto FINISH_OFF;
- }
- }
-
- if (attch_info)
- emstorage_free_attachment(&attch_info, 1, NULL);
- }
-
-#else
-
- if (ai->type) {
- mail->attachment_yn = 1;
- /* save only attachment file. */
- if (!emstorage_add_attachment(&attachment, 0, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
- if (bIsAdd_to_mmc) {
- if (attachment.attachment) {
- }
- }
- else {
- /* delete all created files. */
- if (!emstorage_get_save_name(account_id, mail_id, 0, NULL, buf, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_delete_dir(buf, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* ROLLBACK TRANSACTION; */
- emstorage_rollback_transaction(NULL, NULL, NULL);
- goto FINISH_OFF;
- }
- }
- }
-#endif /* End of #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__ */
-
- }
-
- mail->attachment_count = local_attachment_count;
- mail->inline_content_count = local_inline_content_count;
-
- /* change mail's information. */
- if (!emstorage_change_mail_field(mail_id, APPEND_BODY, mail, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
-
- goto FINISH_OFF;
- }
-
-#ifdef __FEATURE_BODY_SEARCH__
- /* strip html content and save into mail_text_tbl */
- char *stripped_text = NULL;
- if (!emcore_strip_mail_body_from_file(mail, &stripped_text, &err) || stripped_text == NULL) {
- EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
- }
-
- emstorage_mail_text_tbl_t *mail_text;
- if (!emstorage_get_mail_text_by_id(mail_id, &mail_text, true, &err) || !mail_text) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_text_by_id failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
- EM_SAFE_FREE(stripped_text);
- goto FINISH_OFF;
- }
-
- EM_SAFE_FREE(mail_text->body_text);
- mail_text->body_text = stripped_text;
-
- if (!emstorage_change_mail_text_field(mail_id, mail_text, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_mail_text_field failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
- emstorage_free_mail_text(&mail_text, 1, NULL); /*prevent 17957*/
- goto FINISH_OFF;
- }
-
- if (mail_text)
- emstorage_free_mail_text(&mail_text, 1, NULL);
-#endif
-
- EM_DEBUG_LOG("cnt_info->text.plain [%s], cnt_info->text.html [%s]", cnt_info->text.plain, cnt_info->text.html);
-
- /* in pop3 mail case, the mail is deleted from server after being downloaded. */
- if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
-#ifdef DELETE_AFTER_DOWNLOADING
- char delmsg[24];
-
- SNPRINTF(delmsg, sizeof(delmsg), "%d", msg_no);
-
- if (!ref_account->keep_mails_on_pop_server_after_download) {
- if (!emcore_delete_mails_from_pop3_server(&mbox, delmsg, &err))
- EM_DEBUG_EXCEPTION("emcore_delete_mails_from_pop3_server failed [%d]", err);
- }
-#endif
-
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- ret = true;
-
-FINISH_OFF:
-
- if (ref_account) {
- emcore_free_account(ref_account);
- EM_SAFE_FREE(ref_account);
- }
-
-#if 0
- /* note that local stream should be freed here*/
- if (mail_stream == NULL && stream != NULL) {
- stream = mail_close (stream);
- }
-#endif
-
- multi_part_body_size = 0;
- _pop3_received_body_size = 0;
- _pop3_last_notified_body_size = 0;
- _pop3_total_body_size = 0;
- _pop3_receiving_mail_id = 0;
-
- _imap4_received_body_size = 0;
- _imap4_last_notified_body_size = 0;
- _imap4_total_body_size = 0;
- _imap4_download_noti_interval_value = 0;
-
- if (cnt_info) {
- emcore_free_content_info(cnt_info);
- EM_SAFE_FREE(cnt_info);
- }
- if (mail)
- emstorage_free_mail(&mail, 1, NULL);
- EM_SAFE_FREE(s_uid);
-
- multi_part_body_size = 0;
-
- if (ret == true)
- emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FINISH, mail_id, NULL, event_handle, 0);
- else
- emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, event_handle, err);
-
- if (err_code != NULL)
- *err_code = err;
-
- return ret;
-}
-
-INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
- int account_id, int mail_id, int with_attach, int limited_size,
- int event_handle, int cancellable, int auto_download, int *err_code)
+INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
+ void *mail_stream,
+ int account_id,
+ int mail_id,
+ int with_attach,
+ int limited_size,
+ int event_handle,
+ int cancellable,
+ int auto_download,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_stream[%p], account_id[%d], mail_id[%d], "
"with_attach[%d], event_handle [%d]", mail_stream, account_id, mail_id,
@@ -3518,7 +2573,8 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
struct attachment_info *ai = NULL;
char *s_uid = NULL;
- char buf[512] = {0};
+ char move_buf[512] = {0};
+ char path_buf[512] = {0};
int msgno = 0;
int attachment_num = 1;
@@ -3548,7 +2604,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
/* looking for mail by mail_id in DB*/
- if (!emstorage_get_mail_by_id (mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id (multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -3573,7 +2629,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
s_uid = EM_SAFE_STRDUP(mail->server_mail_id);
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -3586,7 +2642,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
if (!mail_stream) {
#if 0
MAILSTREAM *tmp_stream = NULL;
- if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mail->mailbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -3594,7 +2650,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
#endif
MAILSTREAM **mstream = NULL;
- mstream = emcore_get_recv_stream (account_id, mail->mailbox_id, &err);
+ mstream = emcore_get_recv_stream (multi_user_name, account_id, mail->mailbox_id, &err);
if (!mstream) {
EM_DEBUG_EXCEPTION("emcore_get_recv_stream failed [%d]", err);
@@ -3628,7 +2684,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
mailbox.account_id = account_id;
/* download all uids from server. */
- if (!emcore_download_uid_all (stream, &mailbox, &uid_list, NULL, NULL, 0, EM_CORE_GET_UIDS_FOR_NO_DELETE, &err)) {
+ if (!emcore_download_uid_all (multi_user_name, stream, &mailbox, &uid_list, NULL, NULL, 0, EM_CORE_GET_UIDS_FOR_NO_DELETE, &err)) {
EM_DEBUG_EXCEPTION("emcore_download_uid_all failed [%d]", err);
goto FINISH_OFF;
}
@@ -3676,7 +2732,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
goto FINISH_OFF;
}
- while(emcore_mime_get_line_from_sock((void *)stream, sock_buf, 1024, &err)) {
+ while (emcore_mime_get_line_from_sock((void *)stream, sock_buf, 1024, &err)) {
if (write(fd, sock_buf, EM_SAFE_STRLEN(sock_buf)) != EM_SAFE_STRLEN(sock_buf)) {
EM_DEBUG_EXCEPTION("write failed");
}
@@ -3755,7 +2811,8 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
/* FETCH sections and set content to message */
if (!emcore_gmime_fetch_imap_body_sections(stream, uid, mail_id,
- cnt_info, message1, event_handle, auto_download, &err)) {
+ cnt_info, message1, event_handle,
+ auto_download, &err)) {
EM_DEBUG_EXCEPTION("emcore_gmime_get_imap_sections failed");
goto FINISH_OFF;
}
@@ -3763,6 +2820,10 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
/* decoding contents */
g_mime_message_foreach(message1, emcore_gmime_imap_parse_full_foreach_cb, (gpointer)cnt_info);
+ /* Get mime entity */
+ if (cnt_info->content_type == 1)
+ g_mime_message_foreach(message1, emcore_gmime_get_mime_entity_cb, (gpointer)cnt_info);
+
/* free resources */
if (message1) {
g_object_unref(message1);
@@ -3806,29 +2867,37 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
}
EM_DEBUG_LOG("PLAIN DEFAULT CHARSET : %s", charset_plain_text);
- if (!emstorage_create_dir(account_id, mail_id, 0, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(account_id, mail_id, 0, charset_plain_text, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0,
+ charset_plain_text, move_buf, path_buf,
+ sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(cnt_info->text.plain, buf, false, &err)) {
+ if (!emstorage_move_file(cnt_info->text.plain, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
EM_SAFE_FREE(mail->file_path_plain);
- mail->file_path_plain = EM_SAFE_STRDUP(buf);
+ mail->file_path_plain = EM_SAFE_STRDUP(path_buf);
EM_DEBUG_LOG_SEC("mail->file_path_plain [%s]", mail->file_path_plain);
}
/* text/html */
if (cnt_info->text.html) {
- if (!emstorage_create_dir(account_id, mail_id, 0, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
@@ -3845,23 +2914,47 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
memcpy(html_body, "UTF-8.htm", strlen("UTF-8.htm"));
}
- if (!emstorage_get_save_name(account_id, mail_id, 0, html_body, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, html_body, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(cnt_info->text.html, buf, false, &err)) {
+ if (!emstorage_move_file(cnt_info->text.html, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
EM_SAFE_FREE(mail->file_path_html);
- mail->file_path_html = EM_SAFE_STRDUP(buf);
+ mail->file_path_html = EM_SAFE_STRDUP(path_buf);
+ }
+
+ /* mime_entity */
+ if (cnt_info->text.mime_entity) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id,
+ 0, "mime_entity", move_buf, path_buf,
+ sizeof(path_buf), &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (!emstorage_move_file(cnt_info->text.mime_entity, move_buf, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ EM_SAFE_FREE(mail->file_path_mime_entity);
+ mail->file_path_mime_entity = EM_SAFE_STRDUP(path_buf);
}
/* Update local_preview_text */
- if ((err = emcore_get_preview_text_from_file (mail->file_path_plain,
- mail->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &mail->preview_text)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_get_preview_text_from_file (multi_user_name,
+ mail->file_path_plain,
+ mail->file_path_html,
+ MAX_PREVIEW_TEXT_LENGTH,
+ &mail->preview_text)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file error [%d]", err);
}
@@ -3879,9 +2972,14 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
int attachment_num_from_cnt_info;
int inline_attachment_num_from_cnt_info;
- if ((err = emcore_update_attachment_except_inline(cnt_info, mail->account_id,
- mail->mail_id, mail->mailbox_id, &total_attachment_size,
- &attachment_num_from_cnt_info, &inline_attachment_num_from_cnt_info)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_update_attachment_except_inline(multi_user_name,
+ cnt_info,
+ mail->account_id,
+ mail->mail_id,
+ mail->mailbox_id,
+ &total_attachment_size,
+ &attachment_num_from_cnt_info,
+ &inline_attachment_num_from_cnt_info)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_update_attachment_except_inline failed : [%d]", err);
goto FINISH_OFF;
}
@@ -3894,6 +2992,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
if (b_with_attach == 0) {
attachment_num++;
+ if (ai->save) g_remove(ai->save);
ai = ai->next;
continue;
}
@@ -3923,26 +3022,29 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
continue;
}
- if (!emstorage_create_dir(account_id, mail_id, attachment_num, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_num, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(account_id, mail_id, attachment_num, attachment.attachment_name, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, attachment_num, attachment.attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(ai->save, buf, false, &err)) {
+ if (!emstorage_move_file(ai->save, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
/* delete all created files. */
- if (!emstorage_get_save_name(account_id, mail_id, 0, NULL, buf, sizeof(buf), NULL)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), NULL)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed...");
/* goto FINISH_OFF; */
}
- if (!emstorage_delete_dir(buf, NULL)) {
+ if (!emstorage_delete_dir(move_buf, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_delete_dir failed...");
/* goto FINISH_OFF; */
}
@@ -3951,33 +3053,33 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
}
EM_SAFE_FREE(ai->save);
- ai->save = EM_SAFE_STRDUP(buf);
+ ai->save = EM_SAFE_STRDUP(path_buf);
attachment.attachment_path = ai->save;
/* Get attachment details */
- if (!emstorage_get_attachment_nth(mail_id, attachment.attachment_id, &attch_info, true, &err) || !attch_info) {
+ if (!emstorage_get_attachment_nth(multi_user_name, mail_id, attachment.attachment_id, &attch_info, true, &err) || !attch_info) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND) { /* save only attachment file. */
- if (!emstorage_add_attachment(&attachment, 0, false, &err)) {
+ if (!emstorage_add_attachment(multi_user_name, &attachment, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
if (attch_info)
emstorage_free_attachment(&attch_info, 1, NULL);
/* delete all created files. */
- if (!emstorage_get_save_name(account_id, mail_id, 0, NULL, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_delete_dir(buf, &err)) {
+ if (!emstorage_delete_dir(move_buf, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err);
goto FINISH_OFF;
}
/* ROLLBACK TRANSACTION; */
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
@@ -4001,7 +3103,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
attch_info->attachment_inline_content_status = 0;
attch_info->attachment_mime_type = EM_SAFE_STRDUP(attachment.attachment_mime_type);
- if (!emstorage_update_attachment(attch_info, true, &err)) {
+ if (!emstorage_update_attachment(multi_user_name, attch_info, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_attachment failed [%d]", err);
emstorage_free_attachment(&attch_info, 1, NULL); /*prevent 17956*/
goto FINISH_OFF;
@@ -4045,25 +3147,29 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
continue;
}
- if (!emstorage_create_dir(account_id, mail_id, 0, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(account_id, mail_id, 0, attachment.attachment_name, buf, sizeof(buf), &err)) {
+
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, attachment.attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(ai->save, buf, false, &err)) {
+ if (!emstorage_move_file(ai->save, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
/* delete all created files. */
- if (!emstorage_get_save_name(account_id, mail_id, 0, NULL, buf, sizeof(buf), NULL)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), NULL)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed...");
/* goto FINISH_OFF; */
}
- if (!emstorage_delete_dir(buf, NULL)) {
+ if (!emstorage_delete_dir(move_buf, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_delete_dir failed...");
/* goto FINISH_OFF; */
}
@@ -4072,34 +3178,33 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
}
EM_SAFE_FREE(ai->save);
- ai->save = EM_SAFE_STRDUP(buf);
+ ai->save = EM_SAFE_STRDUP(path_buf);
attachment.attachment_path = ai->save;
/* Get attachment details */
- if (!emstorage_get_attachment_nth(mail_id, attachment.attachment_id, &attch_info, true, &err) || !attch_info) {
+ if (!emstorage_get_attachment_nth(multi_user_name, mail_id, attachment.attachment_id, &attch_info, true, &err) || !attch_info) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND) { /* save only attachment file. */
- if (!emstorage_add_attachment(&attachment, 0, false, &err)) {
+ if (!emstorage_add_attachment(multi_user_name, &attachment, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
if (attch_info)
emstorage_free_attachment(&attch_info, 1, NULL);
/* delete all created files. */
- if (!emstorage_get_save_name(account_id, mail_id, 0, NULL, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_delete_dir(buf, &err)) {
+ if (!emstorage_delete_dir(move_buf, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err);
goto FINISH_OFF;
}
/* ROLLBACK TRANSACTION; */
- emstorage_rollback_transaction(NULL, NULL, NULL);
-
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
@@ -4122,7 +3227,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
attch_info->attachment_inline_content_status = 1;
attch_info->attachment_mime_type = EM_SAFE_STRDUP(attachment.attachment_mime_type);
- if (!emstorage_update_attachment(attch_info, true, &err)) {
+ if (!emstorage_update_attachment(multi_user_name, attch_info, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_attachment failed [%d]", err);
emstorage_free_attachment(&attch_info, 1, NULL); /*prevent 17956*/
goto FINISH_OFF;
@@ -4140,24 +3245,23 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
mail->inline_content_count = local_inline_content_count;
/* change mail's information. */
- if (!emstorage_change_mail_field(mail_id, APPEND_BODY, mail, false, &err)) {
+ if (!emstorage_change_mail_field(multi_user_name, mail_id, APPEND_BODY, mail, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
-
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
goto FINISH_OFF;
}
#ifdef __FEATURE_BODY_SEARCH__
/* strip html content and save into mail_text_tbl */
char *stripped_text = NULL;
- if (!emcore_strip_mail_body_from_file(mail, &stripped_text, &err) || stripped_text == NULL) {
+ if (!emcore_strip_mail_body_from_file(multi_user_name, mail, &stripped_text, &err) || stripped_text == NULL) {
EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
}
emstorage_mail_text_tbl_t *mail_text;
- if (!emstorage_get_mail_text_by_id(mail_id, &mail_text, true, &err) || !mail_text) {
+ if (!emstorage_get_mail_text_by_id(multi_user_name, mail_id, &mail_text, true, &err) || !mail_text) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_text_by_id failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
EM_SAFE_FREE(stripped_text);
goto FINISH_OFF;
}
@@ -4165,9 +3269,9 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
EM_SAFE_FREE(mail_text->body_text);
mail_text->body_text = stripped_text;
- if (!emstorage_change_mail_text_field(mail_id, mail_text, false, &err)) {
+ if (!emstorage_change_mail_text_field(multi_user_name, mail_id, mail_text, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_text_field failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL); /* ROLLBACK TRANSACTION; */
emstorage_free_mail_text(&mail_text, 1, NULL); /*prevent 17957*/
goto FINISH_OFF;
}
@@ -4186,7 +3290,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
SNPRINTF(delmsg, sizeof(delmsg), "%d", msg_no);
if (!ref_account->keep_mails_on_pop_server_after_download) {
- if (!emcore_delete_mails_from_pop3_server(&mbox, delmsg, &err))
+ if (!emcore_delete_mails_from_pop3_server(multi_user_name, &mbox, delmsg, &err))
EM_DEBUG_EXCEPTION("emcore_delete_mails_from_pop3_server failed [%d]", err);
}
#endif
@@ -4201,7 +3305,7 @@ FINISH_OFF:
if (ref_account) {
emcore_free_account(ref_account);
- EM_SAFE_FREE(ref_account);
+ free(ref_account);
}
#if 0
@@ -4220,7 +3324,7 @@ FINISH_OFF:
if (cnt_info) {
emcore_free_content_info(cnt_info);
- EM_SAFE_FREE(cnt_info);
+ free(cnt_info);
}
if (mail)
@@ -4268,12 +3372,12 @@ void emcore_mail_copyuid(MAILSTREAM *stream, char *mailbox,
sprintf(g_new_server_uid, "%ld", destset->first);
EM_DEBUG_LOG(">>>>> new_server_uid =%s", g_new_server_uid);
- if (!emstorage_update_server_uid(old_server_uid, g_new_server_uid, NULL)) {
+ if (!emstorage_update_server_uid(NULL, old_server_uid, g_new_server_uid, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_update_server_uid falied...");
}
}
-static int emcore_delete_mails_from_remote_server(int input_account_id, int input_mail_ids[], int input_mail_id_count, int input_delete_option)
+static int emcore_delete_mails_from_remote_server(char *multi_user_name, int input_account_id, int input_mail_ids[], int input_mail_id_count, int input_delete_option)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d], input_mail_ids[%p], input_mail_id_count[%d], input_delete_option [%d]", input_account_id, input_mail_ids, input_mail_id_count, input_delete_option);
@@ -4286,7 +3390,7 @@ static int emcore_delete_mails_from_remote_server(int input_account_id, int inpu
int bulk_flag = false;
#endif
- if (!(account = emcore_get_account_reference(input_account_id))) {
+ if (!(account = emcore_get_account_reference(multi_user_name, input_account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -4319,7 +3423,7 @@ static int emcore_delete_mails_from_remote_server(int input_account_id, int inpu
EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [ NOTI_DELETE_MAIL_START ] >>>> ");
if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
- if (!bulk_flag && !emcore_delete_mails_from_imap4_server(input_mail_ids, input_mail_id_count, input_delete_option, &err)) {
+ if (!bulk_flag && !emcore_delete_mails_from_imap4_server(multi_user_name, input_mail_ids, input_mail_id_count, input_delete_option, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mails_from_imap4_server failed [%d]", err);
if (err == EMAIL_ERROR_IMAP4_STORE_FAILURE)
err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
@@ -4330,7 +3434,7 @@ static int emcore_delete_mails_from_remote_server(int input_account_id, int inpu
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
for(i = 0; i < input_mail_id_count; i++) {
- if (!emcore_delete_auto_download_activity(input_account_id, input_mail_ids[i], 0, &err)) {
+ if (!emcore_delete_auto_download_activity(multi_user_name, input_account_id, input_mail_ids[i], 0, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_auto_download_activity failed [%d]", err);
}
}
@@ -4338,14 +3442,14 @@ static int emcore_delete_mails_from_remote_server(int input_account_id, int inpu
}
}
else if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
- if (!emcore_delete_mails_from_pop3_server(account, input_mail_ids, input_mail_id_count)) {
+ if (!emcore_delete_mails_from_pop3_server(multi_user_name, account, input_mail_ids, input_mail_id_count)) {
EM_DEBUG_EXCEPTION("emcore_delete_mails_from_pop3_server falied [%d]", err);
goto FINISH_OFF;
}
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
else {
for(i = 0; i < input_mail_id_count; i++) {
- if (!emcore_delete_auto_download_activity(input_account_id, input_mail_ids[i], 0, &err)) {
+ if (!emcore_delete_auto_download_activity(multi_user_name, input_account_id, input_mail_ids[i], 0, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_auto_download_activity failed [%d]", err);
}
}
@@ -4375,7 +3479,7 @@ static int emcore_delete_mails_from_remote_server(int input_account_id, int inpu
}
/* Fix for issue - Sometimes mail move and immediately followed by mail delete is not reflected on server */
- if (!emstorage_remove_downloaded_mail(input_account_id, mail->server_mailbox_name, mail->server_mail_id, true, &err)) {
+ if (!emstorage_remove_downloaded_mail(multi_user_name, input_account_id, mail->server_mailbox_name, mail->server_mail_id, true, &err)) {
EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
}
}
@@ -4405,7 +3509,7 @@ FINISH_OFF:
return err;
}
-int emcore_delete_mail(int account_id, int mail_ids[], int num, int from_server, int noti_param_1, int noti_param_2, int *err_code)
+int emcore_delete_mail(char *multi_user_name, int account_id, int mail_ids[], int num, int from_server, int noti_param_1, int noti_param_2, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_ids[%p], num[%d], from_server[%d], noti_param_1 [%d], noti_param_2 [%d], err_code[%p]", account_id, mail_ids, num, from_server, noti_param_1, noti_param_2, err_code);
@@ -4419,7 +3523,7 @@ int emcore_delete_mail(int account_id, int mail_ids[], int num, int from_server,
goto FINISH_OFF;
}
- if (!(account = emcore_get_account_reference(account_id))) {
+ if (!(account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -4429,11 +3533,11 @@ int emcore_delete_mail(int account_id, int mail_ids[], int num, int from_server,
/* FINISH_OFF_IF_CANCELED; */
if (from_server == EMAIL_DELETE_LOCALLY) /* Delete mails from local storage*/ {
- emcore_delete_mails_from_local_storage(account_id, mail_ids, num, noti_param_1, noti_param_2, err_code);
- emcore_display_unread_in_badge(NULL);
+ emcore_delete_mails_from_local_storage(multi_user_name, account_id, mail_ids, num, noti_param_1, noti_param_2, err_code);
+ emcore_display_unread_in_badge(multi_user_name);
}
else { /* Delete mails from server*/
- emcore_delete_mails_from_remote_server(account_id, mail_ids, num, from_server);
+ emcore_delete_mails_from_remote_server(multi_user_name, account_id, mail_ids, num, from_server);
}
@@ -4441,7 +3545,7 @@ int emcore_delete_mail(int account_id, int mail_ids[], int num, int from_server,
FINISH_OFF:
if (from_server)
- emcore_show_user_message(account_id, EMAIL_ACTION_DELETE_MAIL, ret == true ? 0 : err);
+ emcore_show_user_message(multi_user_name, account_id, EMAIL_ACTION_DELETE_MAIL, ret == true ? 0 : err);
if (account) {
emcore_free_account(account);
@@ -4501,22 +3605,23 @@ INTERNAL_FUNC void emcore_send_signal_for_del_account (int signal)
pthread_mutex_unlock (&mu_del_account);
}
-int emcore_delete_all_mails_of_acount(int input_account_id)
+int emcore_delete_all_mails_of_acount(char *multi_user_name, int input_account_id)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d]");
int err = EMAIL_ERROR_NONE;
- char *buf = NULL;
+ char* move_buf = NULL;
+ char path_buf[512] = {0};
/* emstorage_delete_mail_by_account is available only locally */
- if (!emstorage_delete_mail_by_account(input_account_id, false, &err)) {
+ if (!emstorage_delete_mail_by_account(multi_user_name, input_account_id, false, &err)) {
if(err != EMAIL_ERROR_MAIL_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emstorage_delete_mail_by_account failed [%d]", err);
goto FINISH_OFF;
}
}
- if (!emstorage_delete_attachment_all_on_db(input_account_id, NULL, false, &err)) {
+ if (!emstorage_delete_attachment_all_on_db(multi_user_name, input_account_id, NULL, false, &err)) {
if(err != EMAIL_ERROR_MAIL_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err);
goto FINISH_OFF;
@@ -4524,37 +3629,43 @@ int emcore_delete_all_mails_of_acount(int input_account_id)
}
/* delete mail contents from filesystem */
- buf = em_malloc(512);
- if (!buf) {
+ move_buf = em_malloc (512);
+ if (!move_buf) {
EM_DEBUG_EXCEPTION("em_malloc failed");
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(input_account_id, 0, 0, NULL, buf, 512, &err)) {
+ if (!emstorage_get_save_name(multi_user_name, input_account_id, 0, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
if (!del_thd)
- del_thd = em_thread_create(del_exit, NULL);
+ del_thd = em_thread_create (del_exit, NULL);
- em_thread_run(del_thd, del_dir, free_buf, buf);
+ em_thread_run (del_thd, del_dir, free_buf, move_buf);
/* delete meeting request */
- if (!emstorage_delete_meeting_request(input_account_id, 0, 0, false, &err)) {
+ if (!emstorage_delete_meeting_request(multi_user_name, input_account_id, 0, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
-
+
EM_DEBUG_FUNC_END("err [%d]",err);
return err;
}
-INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(int input_account_id, int input_mailbox_id, int input_from_server, int *err_code)
+INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(char *multi_user_name,
+ int input_account_id,
+ int input_mailbox_id,
+ int input_mailbox_type,
+ int input_from_server,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("input_account_id[%d] input_mailbox_id[%d] input_from_server[%d] err_code[%p]", input_account_id, input_mailbox_id, input_from_server, err_code);
+ EM_DEBUG_FUNC_BEGIN("input_account_id[%d] input_mailbox_id[%d] input_from_server[%d] err_code[%p]",
+ input_account_id, input_mailbox_id, input_from_server, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
@@ -4562,22 +3673,49 @@ INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(int input_account_id, int i
int mail_id_count = 0;
char conditional_clause[QUERY_SIZE] = { 0, };
- if (!input_mailbox_id) {
+ if (input_mailbox_id <= 0 && input_mailbox_type <= 0) {
err = EMAIL_ERROR_INVALID_PARAM;
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
goto FINISH_OFF;
}
/* Delete all mails in specific mailbox */
+ SNPRINTF(conditional_clause, QUERY_SIZE, " where ");
+
+ if (input_mailbox_id <= 0 && input_mailbox_type > 0) {
+ SNPRINTF(conditional_clause + strlen(conditional_clause),
+ QUERY_SIZE - strlen(conditional_clause),
+ "mailbox_type = %d ", input_mailbox_type);
+ } else if (input_mailbox_id > 0 && input_mailbox_type <= 0) {
+ SNPRINTF(conditional_clause + strlen(conditional_clause),
+ QUERY_SIZE - strlen(conditional_clause),
+ "mailbox_id = %d ", input_mailbox_id);
+ } else {
+ SNPRINTF(conditional_clause + strlen(conditional_clause),
+ QUERY_SIZE - strlen(conditional_clause),
+ "mailbox_type = %d and mailbox_id = %d ",
+ input_mailbox_type, input_mailbox_id);
+ }
- SNPRINTF(conditional_clause, QUERY_SIZE, " where mailbox_id = %d ", input_mailbox_id);
+ EM_DEBUG_LOG("command : [%s]", conditional_clause);
- emstorage_query_mail_id_list(conditional_clause, false, &mail_id_array, &mail_id_count);
+ err = emstorage_query_mail_id_list(multi_user_name, conditional_clause, false, &mail_id_array, &mail_id_count);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_query_mail_id_list failed : [%d]", err);
+ goto FINISH_OFF;
+ }
EM_DEBUG_LOG("emstorage_query_mail_id_list returns [%d]", mail_id_count);
if (mail_id_count > 0) {
- if (!emcore_delete_mail(input_account_id, mail_id_array, mail_id_count, input_from_server, EMAIL_DELETED_BY_COMMAND, false, &err)) {
+ if (!emcore_delete_mail(multi_user_name,
+ input_account_id,
+ mail_id_array,
+ mail_id_count,
+ input_from_server,
+ EMAIL_DELETED_BY_COMMAND,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -4586,6 +3724,7 @@ INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(int input_account_id, int i
ret = true;
FINISH_OFF:
+
EM_SAFE_FREE(mail_id_array);
if (err_code != NULL)
@@ -4595,21 +3734,23 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *mail_ids, int num, int noti_param_1, int noti_param_2, int *err_code)
+INTERNAL_FUNC int emcore_delete_mails_from_local_storage(char *multi_user_name, int account_id, int *mail_ids, int num, int noti_param_1, int noti_param_2, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_ids[%p], num [%d], noti_param_1 [%d], noti_param_2 [%d], err_code[%p]", account_id, mail_ids, num, noti_param_1, noti_param_2, num, err_code);
int ret = false, err = EMAIL_ERROR_NONE, i;
emstorage_mail_tbl_t *result_mail_list = NULL;
- char mail_id_string[10], *noti_param_string = NULL, buf[512] = {0, };
+ char mail_id_string[10], *noti_param_string = NULL;
+ char move_buf[512] = {0, };
+ char path_buf[512] = {0,};
/* Getting mail list by using select mail_id [in] */
- if(!emstorage_get_mail_field_by_multiple_mail_id(mail_ids, num, RETRIEVE_SUMMARY, &result_mail_list, true, &err) || !result_mail_list) {
+ if(!emstorage_get_mail_field_by_multiple_mail_id(multi_user_name, mail_ids, num, RETRIEVE_SUMMARY, &result_mail_list, true, &err) || !result_mail_list) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_multiple_mail_id failed [%d]", err);
goto FINISH_OFF;
}
/* Deleting mails by using select mail_id [in] */
- if(!emstorage_delete_multiple_mails(mail_ids, num, true, &err)) {
+ if(!emstorage_delete_multiple_mails(multi_user_name, mail_ids, num, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_multiple_mails failed [%d]", err);
goto FINISH_OFF;
}
@@ -4636,7 +3777,17 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *ma
/* Updating Thread informations */
for(i = 0; i < num; i++) {
if (result_mail_list[i].thread_id != 0) {
- if (!emstorage_update_latest_thread_mail(account_id, result_mail_list[i].mailbox_id, result_mail_list[i].thread_id, NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ result_mail_list[i].mailbox_id,
+ result_mail_list[i].mailbox_type,
+ result_mail_list[i].thread_id,
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -4649,7 +3800,7 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *ma
for(i = 0; i < num; i++) {
/* Deleting attachments */
- if (!emstorage_delete_all_attachments_of_mail(result_mail_list[i].mail_id, false, &err)) {
+ if (!emstorage_delete_all_attachments_of_mail(multi_user_name, result_mail_list[i].mail_id, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_all_attachments_of_mail failed [%d]", err);
if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND)
err = EMAIL_ERROR_NONE;
@@ -4657,17 +3808,17 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *ma
/* Deleting Directories */
/* delete mail contents from filesystem */
- if (!emstorage_get_save_name(account_id, result_mail_list[i].mail_id, 0, NULL, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, result_mail_list[i].mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_delete_dir(buf, &err)) {
+ if (!emstorage_delete_dir(move_buf, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err);
}
/* Deleting Meeting Request */
- if (!emstorage_delete_meeting_request(account_id, result_mail_list[i].mail_id, 0, false, &err)) {
+ if (!emstorage_delete_meeting_request(multi_user_name, account_id, result_mail_list[i].mail_id, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_meeting_request failed [%d]", err);
if (err != EMAIL_ERROR_CONTACT_NOT_FOUND) {
goto FINISH_OFF;
@@ -4675,7 +3826,7 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *ma
}
/* Deleting mail_read_mail_uid_tbl */
- if (!emstorage_remove_downloaded_mail(account_id, result_mail_list[i].server_mailbox_name, result_mail_list[i].server_mail_id, true, &err)) {
+ if (!emstorage_remove_downloaded_mail(multi_user_name, account_id, result_mail_list[i].server_mailbox_name, result_mail_list[i].server_mail_id, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_remove_downloaded_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -4683,7 +3834,7 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *ma
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
for(i = 0; i < num; i++) {
- if (!emcore_delete_auto_download_activity(account_id, mail_ids[i], 0, &err)) {
+ if (!emcore_delete_auto_download_activity(multi_user_name, account_id, mail_ids[i], 0, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_auto_download_activity failed [%d]", err);
}
}
@@ -4710,7 +3861,7 @@ FINISH_OFF:
return ret;
}
-static int emcore_delete_mails_from_pop3_server(email_account_t *input_account, int input_mail_ids[], int input_mail_id_count)
+static int emcore_delete_mails_from_pop3_server(char *multi_user_name, email_account_t *input_account, int input_mail_ids[], int input_mail_id_count)
{
EM_DEBUG_FUNC_BEGIN("input_account[%p], input_mail_ids[%p], input_mail_id_count[%d]", input_account, input_mail_ids, input_mail_id_count);
@@ -4734,9 +3885,8 @@ static int emcore_delete_mails_from_pop3_server(email_account_t *input_account,
mail_id = input_mail_ids[i];
- if (!emstorage_get_downloaded_mail(mail_id, &mail_tbl_data, false, &err) || !mail_tbl_data) {
+ if (!emstorage_get_downloaded_mail(multi_user_name, mail_id, &mail_tbl_data, false, &err) || !mail_tbl_data) {
EM_DEBUG_EXCEPTION("emstorage_get_downloaded_mail failed [%d]", err);
-
if (err == EMAIL_ERROR_MAIL_NOT_FOUND) { /* not server mail */
continue;
}
@@ -4745,7 +3895,7 @@ static int emcore_delete_mails_from_pop3_server(email_account_t *input_account,
}
if (stream == NULL) {
- if (!emcore_connect_to_remote_mailbox(input_account->account_id, 0, (void **)&stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, input_account->account_id, 0, (void **)&stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -4776,7 +3926,7 @@ static int emcore_delete_mails_from_pop3_server(email_account_t *input_account,
goto FINISH_OFF;
}
- if (!emstorage_remove_downloaded_mail(input_account->account_id, mail_tbl_data->server_mailbox_name, mail_tbl_data->server_mail_id, true, &err))
+ if (!emstorage_remove_downloaded_mail(multi_user_name, input_account->account_id, mail_tbl_data->server_mailbox_name, mail_tbl_data->server_mail_id, true, &err))
EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
NOT_FOUND_ON_SERVER :
@@ -4863,7 +4013,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(int input_mailbox_id)
+INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(char *multi_user_name, int input_mailbox_id)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d]", input_mailbox_id);
int err = EMAIL_ERROR_NONE;
@@ -4880,7 +4030,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(int in
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -4908,19 +4058,19 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(int in
filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD;
filter_list[2].list_filter_item.rule.key_value.integer_type_value = 1;
- if ( (err = emstorage_write_conditional_clause_for_getting_mail_list(filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if ( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
- if ((err = emstorage_query_mail_id_list(conditional_clause_string, true, &result_mail_id_list, &result_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_query_mail_id_list(multi_user_name, conditional_clause_string, true, &result_mail_id_list, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_id_list [%d]", err);
goto FINISH_OFF;
}
- if (!emcore_delete_mails_from_local_storage(mailbox_tbl->account_id, result_mail_id_list, result_count, 1, EMAIL_DELETED_BY_COMMAND, &err)) {
+ if (!emcore_delete_mails_from_local_storage(multi_user_name, mailbox_tbl->account_id, result_mail_id_list, result_count, 1, EMAIL_DELETED_BY_COMMAND, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mails_from_local_storage [%d]", err);
goto FINISH_OFF;
}
@@ -4940,7 +4090,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(int input_account_id, int input_mailbox_id)
+INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(char *multi_user_name, int input_account_id, int input_mailbox_id)
{
int err = EMAIL_ERROR_NONE;
char *conditional_clause_string = NULL;
@@ -4978,19 +4128,19 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(int in
filter_list[2].list_filter_item.rule.target_attribute = EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD;
filter_list[2].list_filter_item.rule.key_value.integer_type_value = 1;
- if ( (err = emstorage_write_conditional_clause_for_getting_mail_list(filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if ( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
- if ((err = emstorage_query_mail_id_list(conditional_clause_string, true, &result_mail_id_list, &result_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_query_mail_id_list(multi_user_name, conditional_clause_string, true, &result_mail_id_list, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_id_list [%d]", err);
goto FINISH_OFF;
}
- if (!emcore_delete_mail(input_account_id, result_mail_id_list, result_count, EMAIL_DELETE_FROM_SERVER, 1, EMAIL_DELETED_BY_COMMAND, &err)) {
+ if (!emcore_delete_mail(multi_user_name, input_account_id, result_mail_id_list, result_count, EMAIL_DELETE_FROM_SERVER, 1, EMAIL_DELETED_BY_COMMAND, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mail [%d]", err);
goto FINISH_OFF;
}
@@ -5018,7 +4168,7 @@ FINISH_OFF:
* succeed : 1
* fail : 0
*/
-INTERNAL_FUNC int emcore_add_attachment(int mail_id, email_attachment_data_t *attachment, int *err_code)
+INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, email_attachment_data_t *attachment, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment[%p], err_code[%p]", mail_id, attachment, err_code);
@@ -5034,10 +4184,8 @@ INTERNAL_FUNC int emcore_add_attachment(int mail_id, email_attachment_data_t *at
int attachment_id = 0;
int before_tr_begin = 0;
-
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
+ if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err);
-
goto FINISH_OFF2;
}
@@ -5059,80 +4207,77 @@ INTERNAL_FUNC int emcore_add_attachment(int mail_id, email_attachment_data_t *at
attachment_tbl.content_id = attachment->content_id;
/* BEGIN TRANSACTION; */
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
}
- if (!emstorage_add_attachment(&attachment_tbl, 0, false, &err)) {
+ if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
-
goto FINISH_OFF;
}
attachment->attachment_id = attachment_tbl.attachment_id;
if (attachment->attachment_path) {
- char buf[512];
+ char move_buf[512] = {0};
+ char path_buf[512] = {0};
if (!attachment->inline_content_status) {
- if (!emstorage_create_dir(account_id, mail_id, attachment_tbl.attachment_id, &err)) {
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_tbl.attachment_id, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
attachment_id = attachment_tbl.attachment_id;
}
- if (!emstorage_get_save_name(account_id, mail_id, attachment_id, attachment->attachment_name, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, attachment_id, attachment->attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- attachment_tbl.attachment_path = buf;
- if (!emstorage_change_attachment_field(mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
+ attachment_tbl.attachment_path = path_buf;
+ if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_change_mail_field(mail_id, APPEND_BODY, mail_table_data, false, &err)) {
+ if (!emstorage_change_mail_field(multi_user_name, mail_id, APPEND_BODY, mail_table_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
-
goto FINISH_OFF;
}
if (attachment->save_status) {
- if (!emstorage_move_file(attachment->attachment_path, buf, false, &err)) {
+ if (!emstorage_move_file(attachment->attachment_path, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
-
goto FINISH_OFF;
}
}
/* Here only filename is being updated. Since first add is being done there will not be any old files.
So no need to check for old files in this update case */
- if (!emstorage_change_attachment_field(mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
+ if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
-
goto FINISH_OFF;
}
EM_SAFE_FREE(attachment->attachment_path);
- attachment->attachment_path = EM_SAFE_STRDUP(buf);
+ attachment->attachment_path = EM_SAFE_STRDUP(path_buf);
}
ret = true;
FINISH_OFF:
if (ret == true) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
ret = false;
}
}
else { /* ROLLBACK TRANSACTION; */
- if (!before_tr_begin && emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (!before_tr_begin && emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
@@ -5142,12 +4287,13 @@ FINISH_OFF2:
if (err_code)
*err_code = err;
+
EM_DEBUG_FUNC_END("err [%d]", err);
return ret;
}
-INTERNAL_FUNC int emcore_add_attachment_data(int input_mail_id, email_attachment_data_t *input_attachment_data)
+INTERNAL_FUNC int emcore_add_attachment_data(char *multi_user_name, int input_mail_id, email_attachment_data_t *input_attachment_data)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], input_attachment_data[%p]", input_mail_id, input_attachment_data);
@@ -5155,7 +4301,9 @@ INTERNAL_FUNC int emcore_add_attachment_data(int input_mail_id, email_attachment
int attachment_id = 0;
int ret = false;
int before_tr_begin = 0;
- char buf[512] = { 0, };
+ char move_buf[512] = { 0, };
+ char path_buf[512] = { 0, };
+
emstorage_mail_tbl_t *mail_table_data = NULL;
emstorage_attachment_tbl_t attachment_tbl = { 0 };
@@ -5164,7 +4312,7 @@ INTERNAL_FUNC int emcore_add_attachment_data(int input_mail_id, email_attachment
return EMAIL_ERROR_INVALID_PARAM;
}
- if (!emstorage_get_mail_field_by_id(input_mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
+ if (!emstorage_get_mail_field_by_id(multi_user_name, input_mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
@@ -5183,13 +4331,13 @@ INTERNAL_FUNC int emcore_add_attachment_data(int input_mail_id, email_attachment
attachment_tbl.content_id = input_attachment_data->content_id;
/* BEGIN TRANSACTION; */
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
}
- if (!emstorage_add_attachment(&attachment_tbl, 0, false, &err)) {
+ if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
goto FINISH_OFF;
}
@@ -5198,34 +4346,32 @@ INTERNAL_FUNC int emcore_add_attachment_data(int input_mail_id, email_attachment
if (input_attachment_data->attachment_path) {
if (!input_attachment_data->inline_content_status) {
- if (!emstorage_create_dir(mail_table_data->account_id, input_mail_id, attachment_tbl.attachment_id, &err)) {
+ if (!emstorage_create_dir(multi_user_name, mail_table_data->account_id, input_mail_id, attachment_tbl.attachment_id, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
attachment_id = attachment_tbl.attachment_id;
}
- if (!emstorage_get_save_name(mail_table_data->account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, mail_table_data->account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- attachment_tbl.attachment_path = buf;
+ attachment_tbl.attachment_path = path_buf;
- if (!emstorage_change_attachment_field(input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
+ if (!emstorage_change_attachment_field(multi_user_name, input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
-
goto FINISH_OFF;
}
- if (!emstorage_change_mail_field(input_mail_id, APPEND_BODY, mail_table_data, false, &err)) {
+ if (!emstorage_change_mail_field(multi_user_name, input_mail_id, APPEND_BODY, mail_table_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
-
goto FINISH_OFF;
}
if (input_attachment_data->save_status) {
- if (!emstorage_copy_file(input_attachment_data->attachment_path, buf, false, &err)) {
+ if (!emstorage_copy_file(input_attachment_data->attachment_path, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
@@ -5233,25 +4379,24 @@ INTERNAL_FUNC int emcore_add_attachment_data(int input_mail_id, email_attachment
/* Here only filename is being updated. Since first add is being done there will not be any old files.
So no need to check for old files in this update case */
- if (!emstorage_change_attachment_field(input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
+ if (!emstorage_change_attachment_field(multi_user_name, input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
-
goto FINISH_OFF;
}
EM_SAFE_FREE(input_attachment_data->attachment_path);
- input_attachment_data->attachment_path = EM_SAFE_STRDUP(buf);
+ input_attachment_data->attachment_path = EM_SAFE_STRDUP(path_buf);
}
ret = true;
FINISH_OFF:
if (ret) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
}
} else { /* ROLLBACK TRANSACTION; */
- if (!before_tr_begin && emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (!before_tr_begin && emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
@@ -5274,7 +4419,7 @@ FINISH_OFF:
* succeed : 1
* fail : 0
*/
-int emcore_delete_mail_attachment(int attachment_id, int *err_code)
+int emcore_delete_mail_attachment(char *multi_user_name, int attachment_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_id[%d], err_code[%p]", attachment_id, err_code);
@@ -5290,21 +4435,20 @@ int emcore_delete_mail_attachment(int attachment_id, int *err_code)
char attachment_folder_path[MAX_PATH] = {0, };
emstorage_attachment_tbl_t *attachment_tbl = NULL;
- if (!emstorage_get_attachment(attachment_id, &attachment_tbl, true, &error)) {
+ if (!emstorage_get_attachment(multi_user_name, attachment_id, &attachment_tbl, true, &error)) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment failed");
return false;
}
/* BEGIN TRANSACTION; */
- if(!emstorage_begin_transaction(NULL, NULL, &error)) {
+ if(!emstorage_begin_transaction(multi_user_name, NULL, NULL, &error)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", error);
goto FINISH_OFF;
}
- if (!emstorage_delete_attachment_on_db(attachment_id, false, &error)) {
+ if (!emstorage_delete_attachment_on_db(multi_user_name, attachment_id, false, &error)) {
EM_DEBUG_EXCEPTION("emstorage_delete_attachment_on_db failed [%d]", error);
-
- if (emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
error = EMAIL_ERROR_DB_FAILURE;
ret = false;
@@ -5323,7 +4467,7 @@ int emcore_delete_mail_attachment(int attachment_id, int *err_code)
}
}
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
error = EMAIL_ERROR_DB_FAILURE;
ret = false;
}
@@ -5339,13 +4483,14 @@ FINISH_OFF:
return ret;
}
-static int emcore_mail_update_attachment_data(int input_mail_id, email_attachment_data_t *input_attachment_data)
+static int emcore_mail_update_attachment_data(char *multi_user_name, int input_mail_id, email_attachment_data_t *input_attachment_data)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], input_attachment_data[%p]", input_mail_id, input_attachment_data);
int err = EMAIL_ERROR_NONE;
int attachment_id = 0;
- char buf[512] = { 0 , };
+ char move_buf[512] = { 0 , };
+ char path_buf[512] = {0,};
emstorage_attachment_tbl_t *existing_attachment_info = NULL;
emstorage_attachment_tbl_t attachment_tbl = { 0 };
@@ -5355,9 +4500,8 @@ static int emcore_mail_update_attachment_data(int input_mail_id, email_attachmen
goto FINISH_OFF;
}
- if (!emstorage_get_attachment(input_attachment_data->attachment_id, &existing_attachment_info, 1, &err)) {
+ if (!emstorage_get_attachment(multi_user_name, input_attachment_data->attachment_id, &existing_attachment_info, 1, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -5375,25 +4519,24 @@ static int emcore_mail_update_attachment_data(int input_mail_id, email_attachmen
attachment_tbl.content_id = input_attachment_data->content_id;
if (!input_attachment_data->inline_content_status) {
- if (!emstorage_create_dir(attachment_tbl.account_id, input_mail_id, attachment_tbl.attachment_id, &err)) {
+ if (!emstorage_create_dir(multi_user_name, attachment_tbl.account_id, input_mail_id, attachment_tbl.attachment_id, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
attachment_id = attachment_tbl.attachment_id;
}
-
- if (!emstorage_get_save_name(attachment_tbl.account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, buf, sizeof(buf), &err)) {
+
+ if (!emstorage_get_save_name(multi_user_name, attachment_tbl.account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- attachment_tbl.attachment_path = buf;
+ attachment_tbl.attachment_path = path_buf;
EM_DEBUG_LOG_SEC("downloaded [%d], savename [%s], attachment_path [%s]", input_attachment_data->save_status, input_attachment_data->attachment_path, existing_attachment_info->attachment_path);
if (input_attachment_data->save_status && EM_SAFE_STRCMP(input_attachment_data->attachment_path, existing_attachment_info->attachment_path) != 0) {
- if (!emstorage_move_file(input_attachment_data->attachment_path, buf, false ,&err)) {
+ if (!emstorage_move_file(input_attachment_data->attachment_path, move_buf, false ,&err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
-
goto FINISH_OFF;
}
}
@@ -5401,23 +4544,23 @@ static int emcore_mail_update_attachment_data(int input_mail_id, email_attachmen
EM_DEBUG_LOG("no need to move");
EM_SAFE_FREE(input_attachment_data->attachment_path);
- input_attachment_data->attachment_path = EM_SAFE_STRDUP(buf);
+ input_attachment_data->attachment_path = EM_SAFE_STRDUP(path_buf);
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_update_attachment(&attachment_tbl, false, &err)) {
+ if (!emstorage_update_attachment(multi_user_name, &attachment_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_attachment failed [%d]", err);
}
if (err == EMAIL_ERROR_NONE) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
}
} else { /* ROLLBACK TRANSACTION; */
- if (emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
@@ -5430,7 +4573,7 @@ FINISH_OFF:
}
-static int emcore_mail_compare_filename_of_attachment_data(int input_mail_id, int input_attachment_a_id, email_attachment_data_t *input_attachment_b_data, int *result)
+static int emcore_mail_compare_filename_of_attachment_data(char *multi_user_name, int input_mail_id, int input_attachment_a_id, email_attachment_data_t *input_attachment_b_data, int *result)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], input_attachment_a_id[%d], input_attachment_b_data[%p], result[%p]", input_mail_id, input_attachment_a_id, input_attachment_b_data, result);
@@ -5457,7 +4600,7 @@ static int emcore_mail_compare_filename_of_attachment_data(int input_mail_id, in
linkpath[st_buf.st_size] = '\0';
EM_DEBUG_LOG("symbolic link path : [%s]", linkpath);
- if (emstorage_get_attachment_by_attachment_path(linkpath, &attachment_a_tbl, false, &err)) {
+ if (emstorage_get_attachment_by_attachment_path(multi_user_name, linkpath, &attachment_a_tbl, false, &err)) {
if (attachment_a_tbl->mail_id == input_mail_id) {
input_attachment_b_data->attachment_id = attachment_a_tbl->attachment_id;
*result = 2;
@@ -5470,7 +4613,7 @@ static int emcore_mail_compare_filename_of_attachment_data(int input_mail_id, in
}
}
- if (!emstorage_get_attachment(input_attachment_a_id, &attachment_a_tbl, 1, &err)) {
+ if (!emstorage_get_attachment(multi_user_name, input_attachment_a_id, &attachment_a_tbl, 1, &err)) {
if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND)
EM_DEBUG_LOG ("no attachment found");
else
@@ -5511,7 +4654,7 @@ FINISH_OFF:
* succeed : 1
* fail : 0
*/
-INTERNAL_FUNC int emcore_mail_copy(int mail_id, email_mailbox_t *dst_mailbox, int *err_code)
+INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mailbox_t *dst_mailbox, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], dst_mailbox[%p], err_code[%p]", mail_id, dst_mailbox, err_code);
@@ -5520,62 +4663,76 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, email_mailbox_t *dst_mailbox, in
int i;
emstorage_mail_tbl_t *mail = NULL;
emstorage_attachment_tbl_t *atch_list = NULL;
- char buf[512];
int count = EMAIL_ATTACHMENT_MAX_COUNT;
char *mailbox_name = NULL;
char *stripped_text = NULL;
+ char *prefix_path = NULL;
+ char virtual_path[512];
+ char real_path[512];
+ char real_file_path[512];
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
- if ( (err = emstorage_get_attachment_list(mail_id, true, &atch_list, &count)) != EMAIL_ERROR_NONE ){
+ if ( (err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &atch_list, &count)) != EMAIL_ERROR_NONE ){
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
-
goto FINISH_OFF;
}
/* get increased uid. */
- if (!emstorage_increase_mail_id(&mail->mail_id, true, &err)) {
+ if (!emstorage_increase_mail_id(multi_user_name, &mail->mail_id, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_increase_mail_id failed [%d]", err);
-
goto FINISH_OFF;
}
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
/* copy mail body(text) file */
if (mail->file_path_plain) {
- if (!emstorage_create_dir(dst_mailbox->account_id, mail->mail_id, 0, &err)) {
+ if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
-
goto FINISH_OFF;
}
gchar *filename = g_path_get_basename(mail->file_path_plain);
- if (!emstorage_get_save_name(dst_mailbox->account_id, mail->mail_id, 0, filename, buf, sizeof(buf), &err)) {
+ memset(virtual_path, 0x00, sizeof(virtual_path));
+ memset(real_path, 0x00, sizeof(virtual_path));
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_plain);
+
+ if (!emstorage_get_save_name(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, filename, real_path, virtual_path, sizeof(virtual_path), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
g_free(filename);
-
goto FINISH_OFF;
}
g_free(filename);
- if (!emstorage_copy_file(mail->file_path_plain, buf, false, &err)) {
+ if (!emstorage_copy_file(real_file_path, real_path, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
-
goto FINISH_OFF;
}
EM_SAFE_FREE(mail->file_path_plain);
- mail->file_path_plain = EM_SAFE_STRDUP(buf);
+ mail->file_path_plain = EM_SAFE_STRDUP(virtual_path);
}
/* copy mail body(html) file */
if (mail->file_path_html) {
- if (!emstorage_create_dir(dst_mailbox->account_id, mail->mail_id, 0, &err)) {
+ if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
@@ -5583,27 +4740,39 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, email_mailbox_t *dst_mailbox, in
gchar *filename = g_path_get_basename(mail->file_path_html);
- if (!emstorage_get_save_name(dst_mailbox->account_id, mail->mail_id, 0, filename, buf, sizeof(buf), &err)) {
+ memset(virtual_path, 0x00, sizeof(virtual_path));
+ memset(real_path, 0x00, sizeof(virtual_path));
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_html);
+
+ if (!emstorage_get_save_name(multi_user_name,
+ dst_mailbox->account_id,
+ mail->mail_id,
+ 0,
+ filename,
+ real_path,
+ virtual_path,
+ sizeof(virtual_path),
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
g_free(filename);
-
goto FINISH_OFF;
}
g_free(filename);
- if (!emstorage_copy_file(mail->file_path_html, buf, false, &err)) {
+ if (!emstorage_copy_file(real_file_path, real_path, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
-
goto FINISH_OFF;
}
EM_SAFE_FREE(mail->file_path_html); /*valgrind*/
- mail->file_path_html = EM_SAFE_STRDUP(buf);
+ mail->file_path_html = EM_SAFE_STRDUP(virtual_path);
}
/* BEGIN TRANSACTION; */
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
goto FINISH_OFF;
}
@@ -5614,27 +4783,33 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, email_mailbox_t *dst_mailbox, in
mail->mailbox_id = dst_mailbox->mailbox_id;
mail->mailbox_type = dst_mailbox->mailbox_type;
- if (!emstorage_add_mail(mail, 0, false, &err)) {
+ if (!emstorage_add_mail(multi_user_name, mail, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]", err);
if (mail->file_path_plain) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_plain);
+
if (!emstorage_delete_file(mail->file_path_plain, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
+
if (mail->file_path_html) {
- if (!emstorage_delete_file(mail->file_path_html, &err)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_html);
+
+ if (!emstorage_delete_file(real_file_path, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
/* ROLLBACK TRANSACTION; */
- emstorage_rollback_transaction(NULL, NULL, NULL);
-
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
@@ -5642,33 +4817,45 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, email_mailbox_t *dst_mailbox, in
/* copy attachment file */
for (i = 0; i<count; i++) {
if (atch_list[i].attachment_path) {
- if (!emstorage_create_dir(dst_mailbox->account_id, mail->mail_id, i+1, &err)) {
+ if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, i+1, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
break;
}
- if (!emstorage_get_save_name(dst_mailbox->account_id, mail->mail_id, i+1, atch_list[i].attachment_name, buf, sizeof(buf), &err)) {
+ memset(virtual_path, 0x00, sizeof(virtual_path));
+ memset(real_path, 0x00, sizeof(virtual_path));
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, atch_list[i].attachment_path);
+
+ if (!emstorage_get_save_name(multi_user_name,
+ dst_mailbox->account_id,
+ mail->mail_id,
+ i+1,
+ atch_list[i].attachment_name,
+ real_path,
+ virtual_path,
+ sizeof(virtual_path),
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
break;
}
- if (!emstorage_copy_file(atch_list[i].attachment_path, buf, false, &err)) {
+ if (!emstorage_copy_file(real_file_path, real_path, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
break;
}
EM_SAFE_FREE(atch_list[i].attachment_path);
-
- atch_list[i].attachment_path = EM_SAFE_STRDUP(buf);
+ atch_list[i].attachment_path = EM_SAFE_STRDUP(virtual_path);
}
atch_list[i].account_id = dst_mailbox->account_id;
atch_list[i].mail_id = mail->mail_id;
atch_list[i].mailbox_id = mail->mailbox_id;
- if (!emstorage_add_attachment(&atch_list[i], 0, false, &err)) {
+ if (!emstorage_add_attachment(multi_user_name, &atch_list[i], 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
-
break;
}
}
@@ -5677,51 +4864,60 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, email_mailbox_t *dst_mailbox, in
if (i && i != count) {
for (;i >= 0; i--) {
if (atch_list[i].attachment_path) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, atch_list[i].attachment_path);
- if (!emstorage_delete_file(atch_list[i].attachment_path, &err)) {
+ if (!emstorage_delete_file(real_file_path, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
}
if (mail->file_path_plain) {
- if (!emstorage_delete_file(mail->file_path_plain, &err)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_plain);
+
+ if (!emstorage_delete_file(real_file_path, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
- if (mail->file_path_html) {
- if (!emstorage_delete_file(mail->file_path_html, &err)) {
+
+ if (mail->file_path_html) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_html);
+
+ if (!emstorage_delete_file(real_file_path, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
/* ROLLBACK TRANSACTION; */
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
#ifdef __FEATURE_BODY_SEARCH__
/* Insert mail_text to DB */
emstorage_mailbox_tbl_t *output_mailbox;
- if (!emcore_strip_mail_body_from_file(mail, &stripped_text, &err) || stripped_text == NULL) {
+ if (!emcore_strip_mail_body_from_file(multi_user_name, mail, &stripped_text, &err) || stripped_text == NULL) {
EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
}
- if (emstorage_get_mailbox_by_id(dst_mailbox->mailbox_id, &output_mailbox) != EMAIL_ERROR_NONE) {
+ if (emstorage_get_mailbox_by_id(multi_user_name, dst_mailbox->mailbox_id, &output_mailbox) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed");
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
- if (!emcore_add_mail_text(output_mailbox, mail, stripped_text, &err)) {
+ if (!emcore_add_mail_text(multi_user_name, output_mailbox, mail, stripped_text, &err)) {
EM_DEBUG_EXCEPTION("emcore_add_mail_text failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
@@ -5730,20 +4926,20 @@ INTERNAL_FUNC int emcore_mail_copy(int mail_id, email_mailbox_t *dst_mailbox, in
#endif
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
- if (emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_name_by_mailbox_type(dst_mailbox->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
+ if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, dst_mailbox->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
if (!strcmp(dst_mailbox->mailbox_name, mailbox_name) && !(mail->flags_seen_field))
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
ret = true;
@@ -5758,6 +4954,7 @@ FINISH_OFF:
EM_SAFE_FREE(stripped_text);
#endif
EM_SAFE_FREE(mailbox_name);
+ EM_SAFE_FREE(prefix_path);
if (err_code != NULL)
*err_code = err;
@@ -5775,7 +4972,7 @@ FINISH_OFF:
* succeed : 1
* fail : 0
*/
-INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int mail_ids_count, int dst_mailbox_id, int noti_param_1, int noti_param_2 ,int *err_code)
+INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int mail_ids_count, int dst_mailbox_id, int noti_param_1, int noti_param_2 ,int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_ids[%p], mail_ids_count[%d], dst_mailbox_id[%d], noti_param [%d], err_code[%p]", mail_ids, mail_ids_count, dst_mailbox_id, noti_param_1, err_code);
@@ -5796,13 +4993,13 @@ INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int mail_ids_count, int dst_m
int find_striped_subject = 0;
char stripped_subject[4086];
- if ( dst_mailbox_id <= 0 && mail_ids_count < 1) {
+ if (dst_mailbox_id <= 0 && mail_ids_count < 1) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- if (!emstorage_get_mail_field_by_multiple_mail_id(mail_ids, mail_ids_count, RETRIEVE_SUMMARY, &mail_list, true, &err) || !mail_list) {
+ if (!emstorage_get_mail_field_by_multiple_mail_id(multi_user_name, mail_ids, mail_ids_count, RETRIEVE_SUMMARY, &mail_list, true, &err) || !mail_list) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_multiple_mail_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -5818,18 +5015,19 @@ INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int mail_ids_count, int dst_m
for (i = 0; i < mail_ids_count; i++) {
/* Get the thread_id before move */
- if (emstorage_get_thread_id_from_mailbox(account_id, dst_mailbox_id, mail_list[i].subject, &dest_prev_thread_id, &dest_prev_thread_item_count) != EMAIL_ERROR_NONE)
+ if (emstorage_get_thread_id_from_mailbox(multi_user_name, account_id, dst_mailbox_id, mail_list[i].subject, &dest_prev_thread_id, &dest_prev_thread_item_count) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG("emstorage_get_thread_id_of_thread_mails is failed.");
+
dest_prev_thread_id_list[i] = dest_prev_thread_id;
}
- if(!emstorage_move_multiple_mails_on_db(account_id, dst_mailbox_id, mail_ids, mail_ids_count, true, &err)) {
+ if(!emstorage_move_multiple_mails_on_db(multi_user_name, account_id, dst_mailbox_id, mail_ids, mail_ids_count, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_multiple_mails_on_db failed [%d]", err);
goto FINISH_OFF;
}
-
+
for (i = 0; i < mail_ids_count; i++) {
- if (mail_list[i].subject == NULL)
+ if (mail_list[i].subject == NULL)
continue;
if (dest_prev_thread_id_list[i] == -1) {
if (em_find_pos_stripped_subject_for_thread_view(mail_list[i].subject, stripped_subject, sizeof(stripped_subject)) != EMAIL_ERROR_NONE) {
@@ -5856,7 +5054,7 @@ INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int mail_ids_count, int dst_m
}
}
- if (!emstorage_update_thread_id_of_mail(account_id, dst_mailbox_id, mail_ids[i], dest_prev_thread_id_list[i], 0, false, &err)) {
+ if (!emstorage_update_thread_id_of_mail(multi_user_name, account_id, dst_mailbox_id, mail_ids[i], dest_prev_thread_id_list[i], 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -5895,29 +5093,59 @@ INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int mail_ids_count, int dst_m
p_lastest_mail_id = -1;
/* Get the information of moved mail */
- if (!emstorage_get_mail_by_id(mail_ids[i], &p_mail_data, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_ids[i], &p_mail_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed : [%d]", err);
goto FINISH_OFF;
}
- /* Get the thread_id of moved mail */
- if (emstorage_get_thread_id_of_thread_mails(p_mail_data, &p_thread_id, &p_lastest_mail_id, &p_thread_item_count) != EMAIL_ERROR_NONE)
+ /* Get the thread_id of moved mail */
+ if (emstorage_get_thread_id_of_thread_mails(multi_user_name, p_mail_data, &p_thread_id, &p_lastest_mail_id, &p_thread_item_count) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG("emstorage_get_thread_id_of_thread_mails is failed.");
/* Original mailbox replace thread id */
- if (!emstorage_update_latest_thread_mail(account_id, mail_list[i].mailbox_id, mail_list[i].thread_id, NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ mail_list[i].mailbox_id,
+ mail_list[i].mailbox_type,
+ mail_list[i].thread_id,
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
/* Destination mailbox replace thread id */
if (p_thread_id == -1) {
- if (!emstorage_update_latest_thread_mail(account_id, p_mail_data->mailbox_id, p_mail_data->mail_id, NULL, p_mail_data->mail_id, 1, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ p_mail_data->mailbox_id,
+ p_mail_data->mailbox_type,
+ p_mail_data->mail_id,
+ NULL,
+ p_mail_data->mail_id,
+ 1,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
} else {
- if (!emstorage_update_latest_thread_mail(account_id, p_mail_data->mailbox_id, dest_prev_thread_id_list[i], NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ account_id,
+ p_mail_data->mailbox_id,
+ p_mail_data->mailbox_type,
+ dest_prev_thread_id_list[i],
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_MOVE_OR_DELETE,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -5928,7 +5156,7 @@ INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int mail_ids_count, int dst_m
if (!emcore_notify_storage_event(NOTI_MAIL_MOVE_FINISH, account_id, noti_param_1, parameter_string, noti_param_2))
EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [NOTI_MAIL_MOVE_FINISH] >>>> ");
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
ret = true;
@@ -5951,7 +5179,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, int src_mailbox_id, int mail_ids[], int num, char *dest_mailbox, int *error_code)
+INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_id, int src_mailbox_id, int mail_ids[], int num, char *dest_mailbox, int *error_code)
{
EM_DEBUG_FUNC_BEGIN();
MAILSTREAM *stream = NULL;
@@ -5963,8 +5191,8 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, int src_mailbox_id,
int i = 0;
mail_id = mail_ids[0];
-
- ref_account = emcore_get_account_reference(account_id);
+
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : get account reference[%d]", account_id);
*error_code = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -5982,7 +5210,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, int src_mailbox_id,
for (i = 0; i < num; i++) {
mail_id = mail_ids[i];
- if (!emstorage_get_mail_by_id(mail_id, &mail, false, &err_code) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, false, &err_code) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_uid_by_mail_id : emstorage_get_downloaded_mail failed [%d]", err_code);
mail = NULL;
if (err_code == EMAIL_ERROR_MAIL_NOT_FOUND) { /* not server mail */
@@ -5997,7 +5225,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, int src_mailbox_id,
goto FINISH_OFF;
}
- if (!emcore_connect_to_remote_mailbox(account_id, src_mailbox_id, (void **)&stream, &err_code)) /* faizan.h@samsung.com mail_move_fix_07042009 */ {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, src_mailbox_id, (void **)&stream, &err_code)) /* faizan.h@samsung.com mail_move_fix_07042009 */ {
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : Mailbox open[%d]", err_code);
ret = 0;
@@ -6025,7 +5253,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, int src_mailbox_id,
goto FINISH_OFF;
}
- if (!emstorage_update_read_mail_uid(mail_id, g_new_server_uid, mail->server_mailbox_name, &err_code)) {
+ if (!emstorage_update_read_mail_uid(multi_user_name, mail_id, g_new_server_uid, mail->server_mailbox_name, &err_code)) {
EM_DEBUG_EXCEPTION("emstorage_update_read_mail_uid failed [%d]", err_code);
goto FINISH_OFF;
}
@@ -6096,7 +5324,7 @@ FINISH_OFF:
return err_code;
}
-static int emcore_copy_mail_to_another_account_on_local_storeage(int input_mail_id, emstorage_mailbox_tbl_t *input_source_mailbox, emstorage_mailbox_tbl_t *input_target_mailbox, int input_task_id, int *output_mail_id)
+static int emcore_copy_mail_to_another_account_on_local_storeage(char *multi_user_name, int input_mail_id, emstorage_mailbox_tbl_t *input_source_mailbox, emstorage_mailbox_tbl_t *input_target_mailbox, int input_task_id, int *output_mail_id)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d] input_source_mailbox[%p] input_target_mailbox[%p] input_task_id [%d] output_mail_id[%p]", input_mail_id, input_source_mailbox, input_target_mailbox, input_task_id, output_mail_id);
@@ -6111,7 +5339,7 @@ static int emcore_copy_mail_to_another_account_on_local_storeage(int input_mail_
goto FINISH_OFF;
}
- if((err = emcore_get_mail_data(input_mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_get_mail_data(multi_user_name, input_mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
err = EMAIL_ERROR_MAIL_NOT_FOUND;
goto FINISH_OFF;
@@ -6120,30 +5348,23 @@ static int emcore_copy_mail_to_another_account_on_local_storeage(int input_mail_
/* Check download status */
if(!(mail_data->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED)) {
/* If not downloaded, download fully */
-#ifdef __FEATURE_USE_GMIME__
- if (!emcore_gmime_download_body_sections(NULL, input_source_mailbox->account_id,
- input_mail_id, (mail_data->attachment_count > 0)?1:0, NO_LIMITATION, input_task_id, 0, 0, &err)) {
- EM_DEBUG_EXCEPTION("emcore_gmime_download_body_sections failed - %d", err);
- goto FINISH_OFF;
- }
-#else
- if (!emcore_download_body_multi_sections_bulk(NULL,
+ if (!emcore_gmime_download_body_sections(multi_user_name,
+ NULL,
input_source_mailbox->account_id,
- input_mail_id,
- 0,
- (mail_data->attachment_count > 0)?1:0,
- NO_LIMITATION,
- input_task_id,
- 0, /*0: thread excluding event thread */
+ input_mail_id,
+ (mail_data->attachment_count > 0)?1:0,
+ NO_LIMITATION,
+ input_task_id,
+ 0,
+ 0,
&err)) {
- EM_DEBUG_EXCEPTION("emcore_download_body_multi_sections_bulk failed [%d]", err);
+ EM_DEBUG_EXCEPTION("emcore_gmime_download_body_sections failed - %d", err);
goto FINISH_OFF;
}
-#endif
}
/* Get attachments */
- if((err = emcore_get_attachment_data_list(input_mail_id, &attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_get_attachment_data_list(multi_user_name, input_mail_id, &attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -6155,7 +5376,7 @@ static int emcore_copy_mail_to_another_account_on_local_storeage(int input_mail_
mail_data->thread_id = 0;
mail_data->thread_item_count = 0;
- if((err = emcore_add_mail(mail_data, attachment_data, attachment_count, NULL, false, true)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_add_mail(multi_user_name, mail_data, attachment_data, attachment_count, NULL, false, true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -6175,7 +5396,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_move_mail_to_another_account(int input_mail_id, int input_source_mailbox_id, int input_target_mailbox_id, int input_task_id)
+INTERNAL_FUNC int emcore_move_mail_to_another_account(char *multi_user_name, int input_mail_id, int input_source_mailbox_id, int input_target_mailbox_id, int input_task_id)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d] input_source_mailbox_id[%d] input_target_mailbox_id[%d] result_mail_id[%p] input_task_id [%d]", input_mail_id, input_source_mailbox_id, input_target_mailbox_id, input_task_id);
int err = EMAIL_ERROR_NONE;
@@ -6186,12 +5407,12 @@ INTERNAL_FUNC int emcore_move_mail_to_another_account(int input_mail_id, int inp
email_account_t *source_account_ref = NULL;
email_account_t *target_account_ref = NULL;
- if((err = emstorage_get_mailbox_by_id(input_source_mailbox_id, &source_mailbox)) != EMAIL_ERROR_NONE) {
+ if((err = emstorage_get_mailbox_by_id(multi_user_name, input_source_mailbox_id, &source_mailbox)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed for source_mailbox [%d]", err);
goto FINISH_OFF;
}
- if((err = emstorage_get_mailbox_by_id(input_target_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE) {
+ if((err = emstorage_get_mailbox_by_id(multi_user_name, input_target_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed for target_mailbox [%d]", err);
goto FINISH_OFF;
}
@@ -6202,7 +5423,7 @@ INTERNAL_FUNC int emcore_move_mail_to_another_account(int input_mail_id, int inp
/* EAS -> X impossible */
/* X -> EAS impossible */
- source_account_ref = emcore_get_account_reference(source_mailbox->account_id);
+ source_account_ref = emcore_get_account_reference(multi_user_name, source_mailbox->account_id, false);
if(source_account_ref == NULL || source_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
EM_DEBUG_EXCEPTION("Invalid account");
@@ -6210,7 +5431,7 @@ INTERNAL_FUNC int emcore_move_mail_to_another_account(int input_mail_id, int inp
goto FINISH_OFF;
}
- target_account_ref = emcore_get_account_reference(target_mailbox->account_id);
+ target_account_ref = emcore_get_account_reference(multi_user_name, target_mailbox->account_id, false);
if(target_account_ref == NULL || target_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
EM_DEBUG_EXCEPTION("Invalid account");
@@ -6219,33 +5440,33 @@ INTERNAL_FUNC int emcore_move_mail_to_another_account(int input_mail_id, int inp
}
- if((err = emcore_copy_mail_to_another_account_on_local_storeage(input_mail_id, source_mailbox, target_mailbox, input_task_id, &moved_mail_id)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_copy_mail_to_another_account_on_local_storeage(multi_user_name, input_mail_id, source_mailbox, target_mailbox, input_task_id, &moved_mail_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_copy_mail_to_another_account_on_local_storeage failed [%d]", err);
goto FINISH_OFF;
}
- if(!emcore_set_flags_field(source_mailbox->account_id, &input_mail_id, 1, EMAIL_FLAGS_DELETED_FIELD, 1 , &err)) {
+ if(!emcore_set_flags_field(multi_user_name, source_mailbox->account_id, &input_mail_id, 1, EMAIL_FLAGS_DELETED_FIELD, 1 , &err)) {
EM_DEBUG_EXCEPTION("emcore_set_flags_field failed [%d]", err);
goto FINISH_OFF;
}
if(target_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
- if((err = emcore_sync_mail_from_client_to_server(moved_mail_id)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_sync_mail_from_client_to_server(multi_user_name, moved_mail_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_sync_mail_from_client_to_server failed [%d]", err);
/* if append is failed, restore source mail and delete copied mail. */
- if(!emcore_set_flags_field(source_mailbox->account_id, &input_mail_id, 1, EMAIL_FLAGS_DELETED_FIELD, 0 , &err)) {
+ if(!emcore_set_flags_field(multi_user_name, source_mailbox->account_id, &input_mail_id, 1, EMAIL_FLAGS_DELETED_FIELD, 0 , &err)) {
EM_DEBUG_EXCEPTION("emcore_set_flags_field failed [%d]", err);
goto FINISH_OFF;
}
- if(!emcore_delete_mail(target_mailbox->account_id, &moved_mail_id, 1, false, 0, 0, &err_for_delete_mail))
+ if(!emcore_delete_mail(multi_user_name, target_mailbox->account_id, &moved_mail_id, 1, false, 0, 0, &err_for_delete_mail))
EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err_for_delete_mail);
goto FINISH_OFF;
}
}
- if(!emcore_delete_mail(source_mailbox->account_id, &input_mail_id, 1, true, 0, 0, &err)) {
+ if(!emcore_delete_mail(multi_user_name, source_mailbox->account_id, &input_mail_id, 1, true, 0, 0, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -6272,9 +5493,12 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_save_mail_file(int account_id, int mail_id, int attachment_id, char *src_file_path, char *file_name, char *full_path, int max_path_len, int *err_code)
+INTERNAL_FUNC int emcore_save_mail_file(char *multi_user_name, int account_id, int mail_id, int attachment_id,
+ char *src_file_path, char *file_name, char *full_path, char *virtual_path,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], attachment_id[%d] , file_name[%p] , full_path[%p] , err_code[%p]", account_id, mail_id, attachment_id, file_name, full_path, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], attachment_id[%d], file_name[%p], full_path[%p], err_code[%p]",
+ account_id, mail_id, attachment_id, file_name, full_path, err_code);
int err = EMAIL_ERROR_NONE;
@@ -6284,12 +5508,20 @@ INTERNAL_FUNC int emcore_save_mail_file(int account_id, int mail_id, int attachm
goto FINISH_OFF;
}
- if (!emstorage_create_dir(account_id, mail_id, attachment_id, &err)) {
+ if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_id, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
-
- if (!emstorage_get_save_name(account_id, mail_id, attachment_id, file_name, full_path, max_path_len, &err)) {
+
+ if (!emstorage_get_save_name(multi_user_name,
+ account_id,
+ mail_id,
+ attachment_id,
+ file_name,
+ full_path,
+ virtual_path,
+ MAX_PATH,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
@@ -6304,15 +5536,24 @@ INTERNAL_FUNC int emcore_save_mail_file(int account_id, int mail_id, int attachm
FINISH_OFF:
if (err_code)
*err_code = err;
+
return 1;
}
/* description : update mail information */
-INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas)
+INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data_list,
+ int input_attachment_count,
+ email_meeting_request_t* input_meeting_request,
+ int input_from_eas)
{
- EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count[%d], input_meeting_request[%p], input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
+ EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count[%d], "
+ "input_meeting_request[%p], input_from_eas[%d]",
+ input_mail_data, input_attachment_data_list, input_attachment_count,
+ input_meeting_request, input_from_eas);
char filename_buf[1024] = {0, };
+ char virtual_path[1024] = {0, };
char mailbox_id_param_string[10] = {0, };
char *body_text_file_name = NULL;
int i = 0;
@@ -6324,35 +5565,56 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
int ori_attachment_count = 0;
int *temp_attachment_id_array = NULL;
email_attachment_data_t *ori_attachment_data_list = NULL;
+ char *prefix_path = NULL;
+ char real_file_path[MAX_PATH] = {0};
-
- if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) || (!input_attachment_count &&input_attachment_data_list)) {
+ if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) ||
+ (!input_attachment_count &&input_attachment_data_list)) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF2;
}
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", err);
+ goto FINISH_OFF2;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
if(input_from_eas == 0) {
if (input_mail_data->file_path_plain) {
- if (stat(input_mail_data->file_path_plain, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_plain);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_plain, stat(\"%s\") failed...", input_mail_data->file_path_plain);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF2;
}
}
-
+
if (input_mail_data->file_path_html) {
- if (stat(input_mail_data->file_path_html, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_html);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_html, stat(\"%s\") failed...", input_mail_data->file_path_html);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF2;
}
}
-
+
if (input_attachment_count && input_attachment_data_list) {
for (i = 0; i < input_attachment_count; i++) {
if (input_attachment_data_list[i].save_status) {
- if (!input_attachment_data_list[i].attachment_path || stat(input_attachment_data_list[i].attachment_path, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_attachment_data_list[i].attachment_path);
+
+ if (!input_attachment_data_list[i].attachment_path || stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_attachment_data_list[i].attachment_path);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF2;
@@ -6363,25 +5625,35 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
}
if(input_mail_data->mail_size == 0) {
- emcore_calc_mail_size(input_mail_data, input_attachment_data_list, input_attachment_count, &(input_mail_data->mail_size));
+ emcore_calc_mail_size(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, &(input_mail_data->mail_size));
}
- if (input_mail_data->file_path_plain) { /* Save plain text body. */
+ if (input_mail_data->file_path_plain) {
+ /* Save plain text body. */
if ( (err = em_get_file_name_from_file_path(input_mail_data->file_path_plain, &body_text_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
err = EMAIL_ERROR_INVALID_FILE_PATH;
goto FINISH_OFF2;
}
- if (!emcore_save_mail_file(input_mail_data->account_id, input_mail_data->mail_id, 0, input_mail_data->file_path_plain, body_text_file_name, filename_buf, sizeof(filename_buf), &err)) {
+ if (!emcore_save_mail_file(multi_user_name,
+ input_mail_data->account_id,
+ input_mail_data->mail_id,
+ 0,
+ input_mail_data->file_path_plain,
+ body_text_file_name,
+ filename_buf,
+ virtual_path,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_save_mail_file failed [%d]", err);
goto FINISH_OFF2;
}
EM_SAFE_FREE(input_mail_data->file_path_plain);
- input_mail_data->file_path_plain = EM_SAFE_STRDUP(filename_buf);
+ input_mail_data->file_path_plain = EM_SAFE_STRDUP(virtual_path);
}
- if (input_mail_data->file_path_html) { /* Save HTML text body. */
+ if (input_mail_data->file_path_html) {
+ /* Save HTML text body. */
EM_SAFE_FREE(body_text_file_name);
if ( (err = em_get_file_name_from_file_path(input_mail_data->file_path_html, &body_text_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
@@ -6389,21 +5661,38 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
goto FINISH_OFF2;
}
- if (!emcore_save_mail_file(input_mail_data->account_id, input_mail_data->mail_id, 0, input_mail_data->file_path_html, body_text_file_name, filename_buf, sizeof(filename_buf), &err)) {
+ if (!emcore_save_mail_file(multi_user_name,
+ input_mail_data->account_id,
+ input_mail_data->mail_id,
+ 0,
+ input_mail_data->file_path_html,
+ body_text_file_name,
+ filename_buf,
+ virtual_path,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_save_mail_file failed [%d]", err);
goto FINISH_OFF2;
}
EM_SAFE_FREE(input_mail_data->file_path_html);
- input_mail_data->file_path_html = EM_SAFE_STRDUP(filename_buf);
- }
-
- if (input_mail_data->file_path_mime_entity) { /* Save mime entity. */
- if (!emcore_save_mail_file(input_mail_data->account_id, input_mail_data->mail_id, 0, input_mail_data->file_path_mime_entity, "mime_entity", filename_buf, sizeof(filename_buf), &err)) {
+ input_mail_data->file_path_html = EM_SAFE_STRDUP(virtual_path);
+ }
+
+ if (input_mail_data->file_path_mime_entity) {
+ /* Save mime entity. */
+ if (!emcore_save_mail_file(multi_user_name,
+ input_mail_data->account_id,
+ input_mail_data->mail_id,
+ 0,
+ input_mail_data->file_path_mime_entity,
+ "mime_entity",
+ filename_buf,
+ virtual_path,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_save_mail_file failed [%d]", err);
goto FINISH_OFF2;
}
EM_SAFE_FREE(input_mail_data->file_path_mime_entity);
- input_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(filename_buf);
+ input_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(virtual_path);
}
if (input_attachment_data_list && input_attachment_count) {
@@ -6411,8 +5700,8 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
int j = 0;
int compare_result = 1;
email_attachment_data_t *temp_attachment_data = NULL;
-
- if ((err = emcore_get_attachment_data_list(input_mail_data->mail_id, &ori_attachment_data_list, &ori_attachment_count)) != EMAIL_ERROR_NONE) {
+
+ if ((err = emcore_get_attachment_data_list(multi_user_name, input_mail_data->mail_id, &ori_attachment_data_list, &ori_attachment_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed : [%d]", err);
}
@@ -6425,7 +5714,7 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
for(i = 0; i < input_attachment_count; i++) {
temp_attachment_data = input_attachment_data_list + i;
- if ( (err = emcore_mail_compare_filename_of_attachment_data(input_mail_data->mail_id, \
+ if ( (err = emcore_mail_compare_filename_of_attachment_data(multi_user_name, input_mail_data->mail_id, \
temp_attachment_data->attachment_id, temp_attachment_data, &compare_result)) != EMAIL_ERROR_NONE) {
if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND)
EM_DEBUG_LOG ("no attachment found");
@@ -6436,7 +5725,7 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
switch (compare_result) {
case 0 :
EM_DEBUG_LOG("file name and attachment id are same, update exising attachment");
- if (!emcore_mail_update_attachment_data(input_mail_data->mail_id, temp_attachment_data)) {
+ if (!emcore_mail_update_attachment_data(multi_user_name, input_mail_data->mail_id, temp_attachment_data)) {
EM_DEBUG_EXCEPTION("emcore_mail_update_attachment_data failed [%d]", err);
goto FINISH_OFF2;
}
@@ -6444,7 +5733,7 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
break;
case 1 :
EM_DEBUG_LOG("save names are different");
- if ( (err = emcore_add_attachment_data(input_mail_data->mail_id, temp_attachment_data)) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_add_attachment_data(multi_user_name, input_mail_data->mail_id, temp_attachment_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_attachment failed [%d]", err);
goto FINISH_OFF2;
}
@@ -6468,7 +5757,7 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
compare_result = 0;
for (j = 0; j < input_attachment_count; j++) {
- if (!emstorage_get_attachment(temp_attachment_id_array[j], &temp_attachment_tbl_t, false, &err)) {
+ if (!emstorage_get_attachment(multi_user_name, temp_attachment_id_array[j], &temp_attachment_tbl_t, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment failed : [%d]", err);
continue;
}
@@ -6487,12 +5776,12 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
switch (compare_result) {
case 0 : /* Delete the attachment on db and file */
- if (!emcore_delete_mail_attachment(temp_attachment_data->attachment_id, &err)) {
+ if (!emcore_delete_mail_attachment(multi_user_name, temp_attachment_data->attachment_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mail_attachment failed [%d]", err);
}
break;
case 2 : /* Delete the attachment on db */
- if (!emstorage_delete_attachment_on_db(temp_attachment_data->attachment_id, true, &err)) {
+ if (!emstorage_delete_attachment_on_db(multi_user_name, temp_attachment_data->attachment_id, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_attachment_on_db failed : [%d]", err);
}
break;
@@ -6514,7 +5803,11 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
EM_DEBUG_LOG("preview_text[%p]", input_mail_data->preview_text);
if (input_mail_data->preview_text == NULL) {
- if ( (err =emcore_get_preview_text_from_file(input_mail_data->file_path_plain, input_mail_data->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &(input_mail_data->preview_text))) != EMAIL_ERROR_NONE) {
+ if ( (err =emcore_get_preview_text_from_file(multi_user_name,
+ input_mail_data->file_path_plain,
+ input_mail_data->file_path_html,
+ MAX_PREVIEW_TEXT_LENGTH,
+ &(input_mail_data->preview_text))) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file failed[%d]", err);
if (err != EMAIL_ERROR_EMPTY_FILE)
goto FINISH_OFF2;
@@ -6527,12 +5820,12 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
}
/* BEGIN TRANSACTION; */
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
goto FINISH_OFF2;
}
- if (!emstorage_change_mail_field(input_mail_data->mail_id, UPDATE_MAIL, converted_mail_tbl_data, false, &err)) {
+ if (!emstorage_change_mail_field(multi_user_name, input_mail_data->mail_id, UPDATE_MAIL, converted_mail_tbl_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
goto FINISH_OFF;
}
@@ -6540,12 +5833,13 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
#ifdef __FEATURE_BODY_SEARCH__
/* strip html content and save into mail_text_tbl */
char *stripped_text = NULL;
- if (!emcore_strip_mail_body_from_file(converted_mail_tbl_data, &stripped_text, &err) || stripped_text == NULL) {
+ if (!emcore_strip_mail_body_from_file(multi_user_name, converted_mail_tbl_data, &stripped_text, &err) || stripped_text == NULL) {
EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
}
emstorage_mail_text_tbl_t *mail_text;
- if (!emstorage_get_mail_text_by_id(input_mail_data->mail_id, &mail_text, true, &err) || !mail_text) {
+
+ if (!emstorage_get_mail_text_by_id(multi_user_name, input_mail_data->mail_id, &mail_text, true, &err) || !mail_text) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_text_by_id failed [%d]", err);
EM_SAFE_FREE(stripped_text);
goto FINISH_OFF;
@@ -6554,7 +5848,7 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
EM_SAFE_FREE(mail_text->body_text);
mail_text->body_text = stripped_text;
- if (!emstorage_change_mail_text_field(input_mail_data->mail_id, mail_text, false, &err)) {
+ if (!emstorage_change_mail_text_field(multi_user_name, input_mail_data->mail_id, mail_text, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_text_field failed [%d]", err);
emstorage_free_mail_text(&mail_text, 1, NULL); /*prevent 17955*/
goto FINISH_OFF;
@@ -6568,31 +5862,31 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
|| input_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
|| input_mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
/* check where there is a meeting request in DB */
- if (!emstorage_get_meeting_request(input_mail_data->mail_id, &meeting_req, false, &err) && err != EMAIL_ERROR_DATA_NOT_FOUND) {
+ if (!emstorage_get_meeting_request(multi_user_name, input_mail_data->mail_id, &meeting_req, false, &err) && err != EMAIL_ERROR_DATA_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emstorage_get_meeting_request failed [%d]", err);
goto FINISH_OFF;
}
+
if (err == EMAIL_ERROR_DATA_NOT_FOUND) { /* insert */
emstorage_mail_tbl_t *original_mail = NULL;
- if (!emstorage_get_mail_by_id(input_mail_data->mail_id, &original_mail, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, input_mail_data->mail_id, &original_mail, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
- if (original_mail) {
- if (!emstorage_add_meeting_request(input_mail_data->account_id, original_mail->mailbox_id, input_meeting_request, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_add_meeting_request failed [%d]", err);
- emstorage_free_mail(&original_mail, 1, NULL);
- goto FINISH_OFF;
+ if (original_mail) {
+ if (!emstorage_add_meeting_request(multi_user_name, input_mail_data->account_id, original_mail->mailbox_id, input_meeting_request, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_add_meeting_request failed [%d]", err);
+ emstorage_free_mail(&original_mail, 1, NULL);
+ goto FINISH_OFF;
+ }
+ emstorage_free_mail(&original_mail, 1, NULL);
}
- emstorage_free_mail(&original_mail, 1, NULL);
- }
}
else { /* update */
- if (!emstorage_update_meeting_request(input_meeting_request, false, &err)) {
+ if (!emstorage_update_meeting_request(multi_user_name, input_meeting_request, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_meeting_request failed [%d]", err);
-
goto FINISH_OFF;
}
}
@@ -6601,22 +5895,18 @@ INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_a
FINISH_OFF:
if (err == EMAIL_ERROR_NONE) {
/* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
}
SNPRINTF(mailbox_id_param_string, 10, "%d", input_mail_data->mailbox_id);
- if (!emcore_notify_storage_event(NOTI_MAIL_UPDATE,
- input_mail_data->account_id,
- input_mail_data->mail_id,
- mailbox_id_param_string,
- (input_mail_data->meeting_request_status != EMAIL_MAIL_TYPE_NORMAL) ? UPDATE_MEETING : UPDATE_MAIL))
+ if (!emcore_notify_storage_event(NOTI_MAIL_UPDATE, input_mail_data->account_id, input_mail_data->mail_id, mailbox_id_param_string, input_mail_data->meeting_request_status?UPDATE_MEETING:UPDATE_MAIL))
EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [NOTI_MAIL_UPDATE] ");
}
else {
/* ROLLBACK TRANSACTION; */
- if (emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
@@ -6624,6 +5914,7 @@ FINISH_OFF2:
EM_SAFE_FREE(body_text_file_name);
EM_SAFE_FREE(temp_attachment_id_array);
+ EM_SAFE_FREE(prefix_path);
if (ori_attachment_data_list)
emcore_free_attachment_data(&ori_attachment_data_list, ori_attachment_count, NULL);
@@ -6641,7 +5932,7 @@ FINISH_OFF2:
}
-INTERNAL_FUNC int emcore_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code)
+INTERNAL_FUNC int emcore_set_flags_field(char *multi_user_name, int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_ids[%p], num [%d], field_type [%d], value[%d], err_code[%p]", account_id, mail_ids, num, field_type, value, err_code);
@@ -6657,13 +5948,13 @@ INTERNAL_FUNC int emcore_set_flags_field(int account_id, int mail_ids[], int num
goto FINISH_OFF;
}
- if (!emstorage_set_field_of_mails_with_integer_value(account_id, mail_ids, num, field_type_name[field_type], value, true, &err)) {
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, mail_ids, num, field_type_name[field_type], value, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
- if(field_type == EMAIL_FLAGS_SEEN_FIELD)
- emcore_display_unread_in_badge(NULL);
+ if (field_type == EMAIL_FLAGS_SEEN_FIELD)
+ emcore_display_unread_in_badge(multi_user_name);
ret = true;
@@ -6803,7 +6094,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int event_handle, int *err_code)
+INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_id, int event_handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%p], err_code[%p]", mail_id, err_code);
@@ -6827,15 +6118,14 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int event_handle, in
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
-
goto FINISH_OFF;
}
account_id = mail->account_id;
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -6844,7 +6134,7 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int event_handle, in
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
/* open mail server. */
- if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -6930,7 +6220,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int event_handle, int *err_code)
+INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int mail_ids[], int num, int event_handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_ids[%p], err_code[%p]", mail_ids[0], err_code);
@@ -6958,22 +6248,21 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int
mail_id = mail_ids[0];
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
-
goto FINISH_OFF;
}
account_id = mail->account_id;
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
/* open mail server. */
- if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -6987,9 +6276,8 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int
FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
- if (!emstorage_get_mail_by_id(mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -7133,7 +6421,7 @@ INTERNAL_FUNC int emcore_free_attachment_data(email_attachment_data_t **attachme
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-INTERNAL_FUNC int emcore_delete_pbd_activity(int account_id, int mail_id, int activity_id, int *err_code)
+INTERNAL_FUNC int emcore_delete_pbd_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], err_code[%p]", account_id, mail_id, err_code);
@@ -7148,13 +6436,13 @@ INTERNAL_FUNC int emcore_delete_pbd_activity(int account_id, int mail_id, int ac
int err = EMAIL_ERROR_NONE;
int before_tr_begin = 0;
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
}
- if (!emstorage_delete_pbd_activity(account_id, mail_id, activity_id, false, &err)) {
+ if (!emstorage_delete_pbd_activity(multi_user_name, account_id, mail_id, activity_id, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_pbd_activity failed [%d]", err);
goto FINISH_OFF;
}
@@ -7163,12 +6451,12 @@ INTERNAL_FUNC int emcore_delete_pbd_activity(int account_id, int mail_id, int ac
FINISH_OFF:
if (ret == true) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
ret = false;
}
} else { /* ROLLBACK TRANSACTION; */
- if (!before_tr_begin && emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (!before_tr_begin && emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
@@ -7193,13 +6481,13 @@ INTERNAL_FUNC int emcore_insert_pbd_activity(email_event_partial_body_thd *local
int err = EMAIL_ERROR_NONE;
int before_tr_begin = 0;
- if (!emstorage_begin_transaction(NULL, NULL, &err)) {
+ if (!emstorage_begin_transaction(local_activity->multi_user_name, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", err);
before_tr_begin = 1;
goto FINISH_OFF;
}
- if (!emstorage_add_pbd_activity(local_activity, activity_id, false, &err)) {
+ if (!emstorage_add_pbd_activity(local_activity->multi_user_name, local_activity, activity_id, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_pbd_activity failed [%d]", err);
goto FINISH_OFF;
}
@@ -7208,17 +6496,18 @@ INTERNAL_FUNC int emcore_insert_pbd_activity(email_event_partial_body_thd *local
FINISH_OFF:
if (ret == true) { /* COMMIT TRANSACTION; */
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {
+ if (emstorage_commit_transaction(local_activity->multi_user_name, NULL, NULL, NULL) == false) {
err = EMAIL_ERROR_DB_FAILURE;
ret = false;
}
} else { /* ROLLBACK TRANSACTION; */
- if (!before_tr_begin && emstorage_rollback_transaction(NULL, NULL, NULL) == false)
+ if (!before_tr_begin && emstorage_rollback_transaction(local_activity->multi_user_name, NULL, NULL, NULL) == false)
err = EMAIL_ERROR_DB_FAILURE;
}
if (err_code != NULL)
*err_code = err;
+
EM_DEBUG_FUNC_END();
return ret;
}
@@ -7229,7 +6518,7 @@ FINISH_OFF:
/* API to set or unset a field of flags on server in single IMAP request to server */
-INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code)
+INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_ids [%p], num [%d], field_type [%d], value [%d], err_code [%p]", mail_ids, num, field_type, value, err_code);
@@ -7266,16 +6555,14 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e
mail_id = mail_ids[0];
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_FLAG, &mail, true, &err) || !mail) /*To DO : This is a existing bug. on mail deletion before this call it will fail always */ {
+ if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_FLAG, &mail, true, &err) || !mail) /*To DO : This is a existing bug. on mail deletion before this call it will fail always */ {
EM_DEBUG_LOG("emstorage_get_mail_by_id failed [%d]", err);
-
goto FINISH_OFF;
}
account_id = mail[0].account_id;
- temp_account = emcore_get_account_reference(account_id);
-
+ temp_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!temp_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -7287,8 +6574,8 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e
err = EMAIL_ERROR_NOT_SUPPORTED;
goto FINISH_OFF;
}
-
- if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) {
+
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mail->mailbox_id, (void **)&stream, &err) || !stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -7312,8 +6599,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e
for (i = 0; i < string_count; ++i) {
/* Get the set of mail_ds and corresponding server_mail_ids sorted by server mail ids in ascending order */
-
- if (false == emstorage_get_id_set_from_mail_ids(string_list[i], &id_set, &id_set_count, &err)) {
+ if (false == emstorage_get_id_set_from_mail_ids(multi_user_name, string_list[i], &id_set, &id_set_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_id_set_from_mail_ids failed [%d]", err);
goto FINISH_OFF;
}
@@ -7403,6 +6689,8 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, e
FINISH_OFF:
+ EM_SAFE_FREE(id_set);
+
#ifdef __FEATURE_LOCAL_ACTIVITY__
if (ret) {
emstorage_activity_tbl_t new_activity;
@@ -7439,12 +6727,13 @@ FINISH_OFF:
if (err_code != NULL)
*err_code = err;
+
EM_DEBUG_FUNC_END();
return ret;
}
#endif
-static int emcore_mail_move_by_filter_rule(int account_id, int mailbox_id, int mailbox_type, emstorage_rule_tbl_t *filter_info)
+static int emcore_mail_move_by_filter_rule(char *multi_user_name, int account_id, int mailbox_id, int mailbox_type, emstorage_rule_tbl_t *filter_info)
{
EM_DEBUG_FUNC_BEGIN("account_id:[%d], mailbox_id:[%d], filter_info:[%p]", account_id, mailbox_id, filter_info);
int err = EMAIL_ERROR_NONE;
@@ -7464,11 +6753,10 @@ static int emcore_mail_move_by_filter_rule(int account_id, int mailbox_id, int m
return err;
}
- if (filter_info->rule_id > 0 && !emstorage_update_tag_id(filter_info->rule_id, 0, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_update_tag_id failed : [%d]", err);
- }
+ if (filter_info->rule_id > 0 && !emstorage_update_tag_id(multi_user_name, filter_info->rule_id, 0, &err))
+ EM_DEBUG_EXCEPTION("emstorage_update_tag_id failed : [%d]", err);
- if (!emstorage_filter_mails_by_rule(account_id, mailbox_id, mailbox_type, false, filter_info, &filter_mail_id_list, &filter_mail_id_count, &err)) {
+ if (!emstorage_filter_mails_by_rule(multi_user_name, account_id, mailbox_id, mailbox_type, false, filter_info, &filter_mail_id_list, &filter_mail_id_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_filter_mails_by_rule failed [%d]", err);
goto FINISH_OFF;
}
@@ -7505,29 +6793,29 @@ static int emcore_mail_move_by_filter_rule(int account_id, int mailbox_id, int m
if (filter_info->action_type != EMAIL_FILTER_MOVE) {
/* Move the mails on server */
- if ((err = emstorage_get_mailbox_by_id(mailbox_id, &dst_mailbox_tbl)) != EMAIL_ERROR_NONE || !dst_mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id, &dst_mailbox_tbl)) != EMAIL_ERROR_NONE || !dst_mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed : [%d]", err);
goto FINISH_OFF;
}
for (mail_id_index = 0; mail_id_index < filter_mail_id_count; mail_id_index++) {
- if (!emstorage_get_mail_by_id(filter_mail_id_list[mail_id_index], &mail_tbl, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, filter_mail_id_list[mail_id_index], &mail_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed : [%d]", err);
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(mail_tbl->mailbox_id, &src_mailbox_tbl)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, mail_tbl->mailbox_id, &src_mailbox_tbl)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed : [%d]", err);
goto FINISH_OFF;
}
- if (!emcore_move_mail_on_server(account_id, src_mailbox_tbl->mailbox_id, filter_mail_id_list, filter_mail_id_count, dst_mailbox_tbl->mailbox_name, &err)) {
+ if (!emcore_move_mail_on_server(multi_user_name, account_id, src_mailbox_tbl->mailbox_id, filter_mail_id_list, filter_mail_id_count, dst_mailbox_tbl->mailbox_name, &err)) {
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : [%d]", err);
goto FINISH_OFF;
}
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
- if (!emstorage_update_auto_download_activity(mail_tbl->server_mail_id, g_new_server_uid, NULL, dst_mailbox_tbl->mailbox_id, &err))
+ if (!emstorage_update_auto_download_activity(multi_user_name, mail_tbl->server_mail_id, g_new_server_uid, NULL, dst_mailbox_tbl->mailbox_id, &err))
EM_DEBUG_EXCEPTION("emstorage_update_auto_download_activity failed : [%d]", err);
#endif
@@ -7551,7 +6839,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err_code)
+INTERNAL_FUNC int emcore_mail_filter_by_rule(char *multi_user_name, email_rule_t *filter_info, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_info[%p], err_code[%p]", filter_info, err_code);
@@ -7571,13 +6859,13 @@ INTERNAL_FUNC int emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err
if (filter_info->type != EMAIL_PRIORITY_SENDER)
break;
- if ((err = emcore_mail_move_by_filter_rule(filter_info->account_id, 0, 0, (emstorage_rule_tbl_t *)filter_info)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_mail_move_by_filter_rule(multi_user_name, filter_info->account_id, 0, 0, (emstorage_rule_tbl_t *)filter_info)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_mail_move_by_filter_rule failed : [%d]", err);
goto FINISH_OFF;
}
break;
case EMAIL_FILTER_BLOCK :
- if (!emstorage_get_account_list(&account_count, &account_tbl_t_list, false, false, &err)) {
+ if (!emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_t_list, false, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -7585,12 +6873,12 @@ INTERNAL_FUNC int emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err
for (account_index = 0; account_index < account_count; account_index++) {
account_tbl_t = account_tbl_t_list + account_index;
- if (!emstorage_get_mailbox_by_mailbox_type(account_tbl_t->account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &spam_mailbox, false, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_tbl_t->account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &spam_mailbox, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type for account_id[%d] failed : [%d]", account_tbl_t->account_id, err);
continue;
}
- if ((err = emcore_mail_move_by_filter_rule(account_tbl_t->account_id, spam_mailbox->mailbox_id, spam_mailbox->mailbox_type, (emstorage_rule_tbl_t *)filter_info)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_mail_move_by_filter_rule(multi_user_name, account_tbl_t->account_id, spam_mailbox->mailbox_id, spam_mailbox->mailbox_type, (emstorage_rule_tbl_t *)filter_info)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_mail_move_by_filter_rule failed : [%d]", err);
goto FINISH_OFF;
}
@@ -7604,7 +6892,7 @@ INTERNAL_FUNC int emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err
break;
}
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
ret = true;
@@ -7622,12 +6910,12 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_add_rule(email_rule_t *filter_info)
+INTERNAL_FUNC int emcore_add_rule(char *multi_user_name, email_rule_t *filter_info)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- if (!emstorage_find_rule((emstorage_rule_tbl_t*)filter_info, true, &err)) {
+ if (!emstorage_find_rule(multi_user_name, (emstorage_rule_tbl_t*)filter_info, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_find_rule failed [%d]", err);
goto FINISH_OFF;
} else {
@@ -7655,7 +6943,7 @@ INTERNAL_FUNC int emcore_add_rule(email_rule_t *filter_info)
break;
}
- if (!emstorage_add_rule((emstorage_rule_tbl_t*)filter_info, true, &err)) {
+ if (!emstorage_add_rule(multi_user_name, (emstorage_rule_tbl_t*)filter_info, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_rule failed [%d]", err);
goto FINISH_OFF;
}
@@ -7671,7 +6959,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_update_rule(int filter_id, email_rule_t *filter_info)
+INTERNAL_FUNC int emcore_update_rule(char *multi_user_name, int filter_id, email_rule_t *filter_info)
{
EM_DEBUG_FUNC_BEGIN();
@@ -7691,12 +6979,12 @@ INTERNAL_FUNC int emcore_update_rule(int filter_id, email_rule_t *filter_info)
return err;
}
- if (!emstorage_get_rule_by_id(filter_id, &old_filter_info, false, &err)) {
+ if (!emstorage_get_rule_by_id(multi_user_name, filter_id, &old_filter_info, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_rule_by_id failed : [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_filter_mails_by_rule(old_filter_info->account_id, old_filter_info->target_mailbox_id, false, true, old_filter_info, &filter_mail_id_list, &filter_mail_id_count, &err)) {
+ if (!emstorage_filter_mails_by_rule(multi_user_name, old_filter_info->account_id, old_filter_info->target_mailbox_id, false, true, old_filter_info, &filter_mail_id_list, &filter_mail_id_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_filter_mails_by_rule failed : [%d]", err);
goto FINISH_OFF;
}
@@ -7723,7 +7011,7 @@ INTERNAL_FUNC int emcore_update_rule(int filter_id, email_rule_t *filter_info)
EM_DEBUG_LOG("param string [%s]", parameter_string);
}
- if (!emstorage_change_rule(filter_id, (emstorage_rule_tbl_t *)filter_info, true, &err)) {
+ if (!emstorage_change_rule(multi_user_name, filter_id, (emstorage_rule_tbl_t *)filter_info, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_rule failed [%d]", err);
goto FINISH_OFF;
}
@@ -7743,7 +7031,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_delete_rule(int filter_id)
+INTERNAL_FUNC int emcore_delete_rule(char *multi_user_name, int filter_id)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
@@ -7762,12 +7050,12 @@ INTERNAL_FUNC int emcore_delete_rule(int filter_id)
goto FINISH_OFF;
}
- if (!emstorage_get_rule_by_id(filter_id, &filter_info, false, &err)) {
+ if (!emstorage_get_rule_by_id(multi_user_name, filter_id, &filter_info, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_rule_by_id failed : [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_filter_mails_by_rule(filter_info->account_id, filter_info->target_mailbox_id, false, true, filter_info, &filter_mail_id_list, &filter_mail_id_count, &err)) {
+ if (!emstorage_filter_mails_by_rule(multi_user_name, filter_info->account_id, filter_info->target_mailbox_id, false, true, filter_info, &filter_mail_id_list, &filter_mail_id_count, &err)) {
EM_DEBUG_EXCEPTION("emstorage_filter_mails_by_rule failed : [%d]", err);
goto FINISH_OFF;
}
@@ -7794,7 +7082,7 @@ INTERNAL_FUNC int emcore_delete_rule(int filter_id)
EM_DEBUG_LOG("param string [%s]", parameter_string);
}
- if (!emstorage_delete_rule(filter_id, true, &err)) {
+ if (!emstorage_delete_rule(multi_user_name, filter_id, true, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_delete_rule failed [%d]", err);
goto FINISH_OFF;
}
@@ -7824,6 +7112,7 @@ INTERNAL_FUNC void emcore_free_content_info(struct _m_content_info *cnt_info)
EM_SAFE_FREE(cnt_info->text.plain_charset);
EM_SAFE_FREE(cnt_info->text.html);
EM_SAFE_FREE(cnt_info->text.html_charset);
+ EM_SAFE_FREE(cnt_info->text.mime_entity);
EM_SAFE_FREE(cnt_info->sections);
while (cnt_info->file) {
@@ -7868,3 +7157,558 @@ INTERNAL_FUNC void emcore_free_attachment_info(struct attachment_info *attchment
EM_DEBUG_FUNC_END();
}
+
+static int get_search_filter_string(email_search_filter_t *search_filter, int search_filter_count, char **output_filter_string)
+{
+ EM_DEBUG_FUNC_BEGIN("search_filter : [%p], search_filter_count : [%d]", search_filter, search_filter_count);
+
+ int i = 0, j = 0;
+ int err = EMAIL_ERROR_NONE;
+ char time_string[20];
+ char filter_string[MAX_PREVIEW_TEXT_LENGTH] = { 0, };
+ char temp_criteria[MAX_PREVIEW_TEXT_LENGTH] = { 0, };
+
+ if (search_filter == NULL || search_filter_count < 0 || output_filter_string == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid paramter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ for (i = 0; i < search_filter_count; i++) {
+ EM_DEBUG_LOG("search_filter_type [%d]", search_filter[i].search_filter_type);
+ memset(temp_criteria, 0x00, MAX_PREVIEW_TEXT_LENGTH);
+
+ switch (search_filter[i].search_filter_type) {
+ case EMAIL_SEARCH_FILTER_TYPE_ALL:
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value == 0) {
+ for (j = i + 1; j < search_filter_count; j++) {
+ if (search_filter[j + 1].search_filter_type == EMAIL_SEARCH_FILTER_TYPE_ALL &&
+ search_filter[j + 1].search_filter_key_value.integer_type_key_value) {
+ break;
+ }
+
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "OR ");
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ }
+ }
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value)
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "ANSWERED ");
+ else
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNANSWERED ");
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_BCC :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BCC \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
+ EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
+ emcore_make_date_string_for_search(search_filter[i].search_filter_key_value.time_type_key_value, time_string);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BEFORE %s ", time_string);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_BODY :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BODY \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_CC :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "CC \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value)
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "DELETED ");
+ else
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNDELETED ");
+
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value)
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FLAGGED ");
+ else
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNFLAGGED ");
+
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FROM :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FROM \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "KEYWORD \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value)
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "NEW ");
+
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value)
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "OLD ");
+
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON :
+ EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
+ emcore_make_date_string_for_search(search_filter[i].search_filter_key_value.time_type_key_value, time_string);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "ON %s ", time_string);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value)
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "RECENT ");
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ if (search_filter[i].search_filter_key_value.integer_type_key_value)
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SEEN ");
+ else
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "UNSEEN ");
+
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE :
+ EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
+ emcore_make_date_string_for_search(search_filter[i].search_filter_key_value.time_type_key_value, time_string);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SINCE %s ", time_string);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SUBJECT \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_TEXT :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TEXT \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_TO :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TO \"%s\" ",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "HEADER x-priority %d ", search_filter[i].search_filter_key_value.integer_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "X-GM-RAW \"has:attachment filename:%s\"",
+ search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET:
+ EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "charset %s", search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:
+ EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "%s", search_filter[i].search_filter_key_value.string_type_key_value);
+ strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
+ case EMAIL_SEARCH_FILTER_TYPE_UID :
+ EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
+ EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
+ break;
+
+ default :
+ EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", search_filter);
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+ }
+
+ em_trim_right(filter_string);
+
+ EM_DEBUG_LOG_SEC("filter_string[%s]", filter_string);
+
+FINISH_OFF:
+
+ if(output_filter_string)
+ *output_filter_string = EM_SAFE_STRDUP(filter_string);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+int emcore_search_mail_and_uids(MAILSTREAM *stream, email_search_filter_t *input_search_filter,
+ int input_search_filter_count, emcore_uid_list** output_uid_list,
+ int *output_uid_count)
+{
+ EM_DEBUG_FUNC_BEGIN("stream[%p] input_search_filter[%p] input_search_filter_count[%d] "
+ "output_uid_list[%p] output_uid_count[%p]",
+ stream, input_search_filter_count, output_uid_list, output_uid_count);
+
+ int err = EMAIL_ERROR_NONE;
+
+ IMAPLOCAL *imaplocal = NULL;
+ char tag[16], command[MAX_PREVIEW_TEXT_LENGTH];
+ char *response = NULL;
+ emcore_uid_list *uid_elem = NULL;
+ char delims[] = " ";
+ char *result = NULL;
+ int uid_count = 0;
+ char *search_filter_string = NULL;
+ char *uid_range_string = NULL;
+ emcore_uid_list *uid_list_for_listing = NULL;
+
+ if (stream == NULL || output_uid_list == NULL || input_search_filter == NULL || output_uid_count == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if (!(imaplocal = stream->local) || !imaplocal->netstream) {
+ EM_DEBUG_EXCEPTION(" invalid IMAP4 stream detected...");
+ err = EMAIL_ERROR_INVALID_PARAM; /* EMAIL_ERROR_UNKNOWN */
+ goto FINISH_OFF;
+ }
+
+ memset(tag, 0x00, sizeof(tag));
+ memset(command, 0x00, sizeof(command));
+
+ if ((err = get_search_filter_string(input_search_filter,
+ input_search_filter_count,
+ &search_filter_string)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("get_search_filter_string failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ SNPRINTF(tag, sizeof(tag), "%08lx", 0xffffffff & (stream->gensym++));
+ SNPRINTF(command, MAX_PREVIEW_TEXT_LENGTH, "%s UID SEARCH %s\015\012", tag, search_filter_string);
+ EM_DEBUG_LOG_SEC("COMMAND [%s] ", command);
+
+#ifdef FEATURE_CORE_DEBUG
+ EM_DEBUG_LOG_SEC(" [IMAP4] >>> [%s]", command);
+#endif
+
+ /* send command : get msgno/uid for all message */
+ if (!net_sout(imaplocal->netstream, command, (int)EM_SAFE_STRLEN(command))) {
+ EM_DEBUG_EXCEPTION(" net_sout failed...");
+ err = EMAIL_ERROR_CONNECTION_BROKEN;
+ goto FINISH_OFF;
+ }
+
+ while (imaplocal->netstream) {
+ char *p = NULL;
+ /* receive response */
+ if (!(response = net_getline(imaplocal->netstream))) {
+ EM_DEBUG_EXCEPTION(" net_getline failed...");
+ err = EMAIL_ERROR_INVALID_RESPONSE;
+ goto FINISH_OFF;
+ }
+#ifdef FEATURE_CORE_DEBUG
+ EM_DEBUG_LOG(" [IMAP4] <<< [%s]", response);
+#endif
+
+ if (!strncmp(response, tag, EM_SAFE_STRLEN(tag))) {
+ if (!strncmp(response + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
+ EM_SAFE_FREE (response);
+ break;
+ }
+ else { /* 'NO' or 'BAD' */
+ err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE; /* EMAIL_ERROR_INVALID_RESPONSE; */
+ goto FINISH_OFF;
+ }
+ }
+
+ if ((p = strstr(response, " SEARCH "))){
+ *p = '\0'; p += strlen(" SEARCH ");
+
+ result = strtok(p, delims);
+
+ while (result != NULL)
+ {
+ EM_DEBUG_LOG("UID VALUE DEEP is [%s]", result);
+
+ if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
+ EM_DEBUG_EXCEPTION(" malloc failed...");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ uid_elem->uid = EM_SAFE_STRDUP(result);
+
+ if (uid_list_for_listing != NULL)
+ uid_elem->next = uid_list_for_listing;
+ uid_list_for_listing = uid_elem;
+ result = strtok(NULL, delims);
+ uid_count++;
+ }
+
+ EM_SAFE_FREE(response);
+ continue;
+ }
+ else if ((p = strstr(response, " SEARCH"))){
+ /* there is no mail */
+ continue;
+ }
+ else {
+ err = EMAIL_ERROR_INVALID_RESPONSE;
+ goto FINISH_OFF;
+ }
+ }
+
+ EM_DEBUG_LOG("uid_count [%d] ", uid_count);
+ if (uid_count > 0) {
+ if ((err = emcore_make_uid_range_string(uid_list_for_listing,
+ uid_count,
+ &uid_range_string)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_make_uid_range_string failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("uid_range_string [%s] ", uid_range_string);
+
+ /* Get uids with flags */
+ if(!imap4_mailbox_get_uids(stream, uid_range_string, output_uid_list, &err)) {
+ EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+
+FINISH_OFF:
+
+ if (output_uid_count)
+ *output_uid_count = uid_count;
+
+ if (uid_list_for_listing)
+ emcore_free_uids(uid_list_for_listing, NULL);
+
+ EM_SAFE_FREE (response);
+ EM_SAFE_FREE (uid_range_string);
+ EM_SAFE_FREE (search_filter_string);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id, int mailbox_id,
+ email_search_filter_t *input_search_filter,
+ int input_search_filter_count,
+ int cancellable,
+ int event_handle)
+{
+ EM_DEBUG_FUNC_BEGIN_SEC("account_id : [%d], mailbox_id : [%d]", account_id, mailbox_id);
+
+ int err = EMAIL_ERROR_NONE;
+ int i = 0;
+ int mail_id = 0;
+ int thread_id = 0;
+ int uid_count = 0;
+ char *uid_range = NULL;
+ char mailbox_id_param_string[10] = {0,};
+ emcore_uid_list *uid_list = NULL;
+ emcore_uid_list *uid_elem = NULL;
+ emstorage_mailbox_tbl_t *search_mailbox = NULL;
+ emstorage_mail_tbl_t *new_mail_tbl_data = NULL;
+
+ MAILSTREAM *stream = NULL;
+ ENVELOPE *env = NULL;
+
+ if (account_id < 0 || mailbox_id == 0) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mailbox_id, (void **)&stream, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed");
+ goto FINISH_OFF;
+ }
+
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
+ if ((err = emcore_search_mail_and_uids(stream,
+ input_search_filter,
+ input_search_filter_count,
+ &uid_list,
+ &uid_count)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_search_mail_and_uids failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
+ uid_elem = uid_list;
+
+ if (uid_count > 0) {
+ if ((err = emcore_make_uid_range_string(uid_list, uid_count, &uid_range)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_make_uid_range_string failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("Calling ... mail_fetch_fast. uid_range [%s]", uid_range);
+ mail_fetch_fast(stream, uid_range, FT_UID | FT_PEEK | FT_NEEDENV);
+ EM_SAFE_FREE(uid_range);
+
+ EM_DEBUG_LOG("stream->nmsgs : [%d]", stream->nmsgs);
+ }
+
+ while (uid_elem) {
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
+ EM_DEBUG_LOG("msgno : [%4lu]", uid_elem->msgno);
+#ifdef __FEATURE_HEADER_OPTIMIZATION__
+ env = mail_fetchstructure_full(stream, uid_elem->msgno, NULL, FT_PEEK, 0);
+#else
+ env = mail_fetchstructure_full(stream, uid_elem->msgno, NULL, FT_PEEK);
+#endif
+ EM_DEBUG_LOG("env[%p]", env);
+ if (env)
+ EM_DEBUG_LOG("message_id[%s]", env->message_id);
+
+ if (!emcore_make_mail_tbl_data_from_envelope(multi_user_name,
+ account_id,
+ stream,
+ env,
+ uid_elem,
+ &new_mail_tbl_data,
+ &err) || !new_mail_tbl_data) {
+ EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_envelope failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ search_mailbox = em_malloc(sizeof(emstorage_mailbox_tbl_t));
+ if (search_mailbox == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ search_mailbox->account_id = account_id;
+ search_mailbox->mailbox_id = mailbox_id;
+ search_mailbox->mailbox_name = EM_SAFE_STRDUP(EMAIL_SEARCH_RESULT_MAILBOX_NAME);
+ search_mailbox->mailbox_type = EMAIL_MAILBOX_TYPE_SEARCH_RESULT;
+
+ if ((err = emcore_add_mail_to_mailbox(multi_user_name,
+ search_mailbox,
+ new_mail_tbl_data,
+ &mail_id,
+ &thread_id)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ memset(mailbox_id_param_string, 0, 10);
+ SNPRINTF(mailbox_id_param_string, 10, "%d", search_mailbox->mailbox_id);
+
+ if (!emcore_initiate_pbd(multi_user_name,
+ stream,
+ account_id,
+ mail_id,
+ uid_elem->uid,
+ search_mailbox->mailbox_id,
+ search_mailbox->mailbox_name,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_initiate_pbd failed : [%d]", err);
+ }
+
+ if (!emcore_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id)) {
+ EM_DEBUG_EXCEPTION("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
+ }
+
+ if (new_mail_tbl_data) {
+ emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
+ new_mail_tbl_data = NULL;
+ }
+
+ uid_elem = uid_elem->next;
+ i++;
+ }
+
+FINISH_OFF:
+
+ if (stream)
+ mail_close (stream);
+
+ if (uid_list)
+ emcore_free_uids(uid_list, NULL);
+
+ if (search_mailbox != NULL)
+ emstorage_free_mailbox(&search_mailbox, 1, NULL);
+
+ if (new_mail_tbl_data)
+ emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+
+}
diff --git a/email-core/email-core-mailbox-sync.c b/email-core/email-core-mailbox-sync.c
index 957a861..23c831e 100755
--- a/email-core/email-core-mailbox-sync.c
+++ b/email-core/email-core-mailbox-sync.c
@@ -47,7 +47,6 @@
#include "email-utilities.h"
#include "email-convert.h"
#include "email-core-mailbox-sync.h"
-#include "email-core-global.h"
#include "email-core-imap-mailbox.h"
#include "email-core-event.h"
#include "email-core-mailbox.h"
@@ -72,7 +71,6 @@ extern void imap_parse_body_structure (MAILSTREAM *stream, BODY *body, unsigned
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
static void emcore_free_email_partial_buffer(email_partial_buffer **partial_buffer, int item_count);
static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size, int item_count);
-static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, int mailbox_id, int *err_code);
#endif
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
@@ -447,6 +445,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
char *p_date = NULL;
char *s = NULL;
int seen = 0;
+ int answered = 0;
int forwarded = 0;
int draft = 0;
int flagged = 0;
@@ -479,6 +478,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
seen = strstr(p, "\\Seen") ? 1 : 0;
draft = strstr(p, "\\Draft") ? 1 : 0;
flagged = strstr(p, "\\Flagged") ? 1 : 0;
+ answered = strstr(p, "\\Answered") ? 1 : 0;
forwarded = strstr(p, "$Forwarded") ? 1 : 0;
if ((p = strstr(p, "UID "))) {
@@ -512,8 +512,9 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
uid_elem->uid = EM_SAFE_STRDUP(p + strlen("UID "));
uid_elem->flag.seen = seen;
uid_elem->flag.draft = draft;
- uid_elem->flag.forwarded = forwarded;
uid_elem->flag.flagged = flagged;
+ uid_elem->flag.answered = answered;
+ uid_elem->flag.forwarded = forwarded;
uid_elem->internaldate = EM_SAFE_STRDUP(internaldate);
if (*uid_list != NULL)
uid_elem->next = *uid_list; /* prepend new data to list */
@@ -639,7 +640,7 @@ int emcore_get_uids_order_by_datetime_from_imap_server(MAILSTREAM *stream, int c
while (result != NULL)
{
- EM_DEBUG_LOG("UID VALUE DEEP is [%s]", result);
+ EM_DEBUG_LOG_DEV("UID VALUE DEEP is [%s]", result);
if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
EM_DEBUG_EXCEPTION(" malloc failed...");
@@ -754,6 +755,11 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui
/* Reading the current timeinfo */
timeinfo = localtime (&week_before_RawTime);
+ if (timeinfo == NULL) {
+ EM_DEBUG_EXCEPTION("localtime failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
EM_DEBUG_LOG(">>>>>Mobile Date a Week before %d %d %d %d %d %d", 1900 + timeinfo->tm_year, timeinfo->tm_mon+1, timeinfo->tm_mday);
@@ -1159,10 +1165,19 @@ static gint emcore_compare_uid_elem(gconstpointer a, gconstpointer b)
return ret;
}
-static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *account, emstorage_mailbox_tbl_t *input_mailbox_tbl, int limit_count, emcore_uid_list** uid_list, int *uids, int retrieve_mode , int *err_code)
+static int emcore_get_uids_to_download(char *multi_user_name,
+ MAILSTREAM *stream,
+ email_account_t *account,
+ emstorage_mailbox_tbl_t *input_mailbox_tbl,
+ int limit_count,
+ emcore_uid_list** uid_list,
+ int *uids,
+ int retrieve_mode,
+ int *err_code)
{
EM_PROFILE_BEGIN(emCoreGetUidsDownload);
- EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_tbl[%p], limit_count[%d], uid_list[%p], err_code[%p]", account, input_mailbox_tbl, limit_count, uid_list, err_code);
+ EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_tbl[%p], limit_count[%d], uid_list[%p], err_code[%p]",
+ account, input_mailbox_tbl, limit_count, uid_list, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
@@ -1196,7 +1211,9 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
else { /* EMAIL_SERVER_TYPE_IMAP4 */
EM_DEBUG_LOG("nmsgs[%d]", ((MAILSTREAM *)stream)->nmsgs);
if ((limit_count < ((MAILSTREAM *)stream)->nmsgs)) {
- if ((err = emcore_get_uids_order_by_datetime_from_imap_server(stream, limit_count, uid_list)) != EMAIL_ERROR_NONE ) {
+ if ((err = emcore_get_uids_order_by_datetime_from_imap_server(stream,
+ limit_count,
+ uid_list)) != EMAIL_ERROR_NONE ) {
EM_DEBUG_EXCEPTION("emcore_get_uids_order_by_datetime_from_imap_server failed [%d]", err);
if (err != EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER)
goto FINISH_OFF;
@@ -1211,9 +1228,14 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
}
}
- if (!emstorage_get_downloaded_list(input_mailbox_tbl->account_id,
- (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) ? 0 : input_mailbox_tbl->mailbox_id,
- &downloaded_uids, &downloaded_uid_count, true, &err)) {
+ if (!emstorage_get_downloaded_list(multi_user_name,
+ input_mailbox_tbl->account_id,
+ (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) ?
+ 0 : input_mailbox_tbl->mailbox_id,
+ &downloaded_uids,
+ &downloaded_uid_count,
+ true,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_downloaded_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -1222,7 +1244,7 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
uid_elem = *uid_list;
uid_count = 0;
- if(!uid_elem) { /* If there is no mail in the input_mailbox_tbl, remove all mails in the input_mailbox_tbl */
+ if (!uid_elem) { /* If there is no mail in the input_mailbox_tbl, remove all mails in the input_mailbox_tbl */
for (i = 0; i < downloaded_uid_count; i++) {
downloaded_uids[i].sync_status = EMAIL_SYNC_STATUS_NOT_EXIST_ON_SERVER;
}
@@ -1265,7 +1287,8 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
while (uid_elem) {
next_uid_elem = uid_elem->next;
- if ((account->retrieval_mode & EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (uid_elem->flag.seen != 0)) { /* already seen */
+ if ((account->retrieval_mode & EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (uid_elem->flag.seen != 0)) {
+ /* already seen */
EM_SAFE_FREE (uid_elem->uid);
EM_SAFE_FREE (uid_elem->internaldate);
EM_SAFE_FREE (uid_elem);
@@ -1273,25 +1296,25 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
else {
int to_be_downloaded = 1;
- if (limit_count > 0 && uid_count >= limit_count){
+ if (limit_count > 0 && uid_count >= limit_count) {
/* EM_DEBUG_LOG("hit the limit[%d] for [%s]", limit_count, uid_elem->uid); */
to_be_downloaded = 0;
- }
- else{
+ } else {
for (i = downloaded_uid_count; i > 0; i--) {
if (downloaded_uids[i - 1].sync_status == EMAIL_SYNC_STATUS_NOT_EXIST_ON_SERVER
&& !EM_SAFE_STRCMP(uid_elem->uid, downloaded_uids[i - 1].server_uid)) {
if (downloaded_uids[i - 1].mailbox_id != input_mailbox_tbl->mailbox_id) {
uid_count--;
- }
- else {
- /* The mail exists on server and local storage, so it should not be downloaded, just check seen flag */
- if(downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen ||
+ } else {
+ /* The mail exists on server and local storage,
+ so it should not be downloaded, just check seen flag */
+ if (downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen ||
downloaded_uids[i - 1].flags_flagged_field != uid_elem->flag.flagged) {
if(downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen) {
downloaded_uids[i - 1].sync_status = EMAIL_SYNC_STATUS_FLAG_CHANGED;
downloaded_uids[i - 1].flags_seen_field = uid_elem->flag.seen;
}
+
if (downloaded_uids[i - 1].flags_flagged_field != uid_elem->flag.flagged) {
downloaded_uids[i - 1].sync_status = EMAIL_SYNC_STATUS_FLAG_CHANGED;
downloaded_uids[i - 1].flags_flagged_field = uid_elem->flag.flagged;
@@ -1299,43 +1322,74 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
} else {
downloaded_uids[i - 1].sync_status = EMAIL_SYNC_STATUS_EXIST_ON_SERVER;
}
+
+ if (!emstorage_get_mail_by_id(multi_user_name,
+ downloaded_uids[i-1].local_uid,
+ &mail,
+ false,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed : [%d]", err);
+ continue;
+ }
+
+ if (mail->flags_answered_field != uid_elem->flag.answered) {
+ if (!emcore_set_flags_field(multi_user_name,
+ downloaded_uids[i-1].account_id,
+ &(downloaded_uids[i-1].local_uid),
+ 1,
+ EMAIL_FLAGS_ANSWERED_FIELD,
+ uid_elem->flag.answered,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_set_flags_field failed : [%d]", err);
+ }
+ }
+
+ if (mail->flags_forwarded_field != uid_elem->flag.forwarded) {
+ if (!emcore_set_flags_field(multi_user_name,
+ downloaded_uids[i-1].account_id,
+ &(downloaded_uids[i-1].local_uid),
+ 1,
+ EMAIL_FLAGS_FORWARDED_FIELD,
+ uid_elem->flag.forwarded,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_set_flags_field failed : [%d]", err);
+ }
+ }
+
+ emstorage_free_mail(&mail, 1, NULL);
+ mail = NULL;
}
+
to_be_downloaded = 0;
break;
}
}
}
- //EM_DEBUG_LOG("Is uid[%s] datetime[%s] going to be downloaded ? [%d]", uid_elem->uid, uid_elem->internaldate, to_be_downloaded);
-
if (to_be_downloaded) {
- if (retrieve_mode == EMAIL_SYNC_OLDEST_MAILS_FIRST){
+ if (retrieve_mode == EMAIL_SYNC_OLDEST_MAILS_FIRST) {
uid_elem->next = head_uid_elem;
head_uid_elem = uid_elem;
- }
- else{ /* if retrieve_mode is EMAIL_SYNC_LATEST_MAILS_FIRST, add uid elem to end so that latest mails are in front of list */
- if (head_uid_elem == NULL){
+ } else {
+ /* if retrieve_mode is EMAIL_SYNC_LATEST_MAILS_FIRST,
+ add uid elem to end so that latest mails are in front of list */
+ if (head_uid_elem == NULL) {
uid_elem->next = head_uid_elem;
head_uid_elem = uid_elem;
end = head_uid_elem;
- }
- else{
+ } else {
end->next = uid_elem;
uid_elem->next = NULL;
end = uid_elem;
}
}
uid_to_be_downloaded_count++;
-
- }
- else {
+ } else {
EM_SAFE_FREE (uid_elem->uid);
EM_SAFE_FREE (uid_elem);
}
-
uid_count++;
}
-
uid_elem = next_uid_elem;
}
@@ -1343,27 +1397,44 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
EM_PROFILE_BEGIN(emCoreGetUidsDownloadForLoop);
for (i = 0; i < downloaded_uid_count; i++) {
- /* EM_DEBUG_LOG("input_mailbox_tbl[%s] sync_status[%d]", input_mailbox_tbl->name, downloaded_uids[i].sync_status); */
if ((downloaded_uids[i].sync_status == EMAIL_SYNC_STATUS_NOT_EXIST_ON_SERVER) &&
- (EM_SAFE_STRCMP(downloaded_uids[i].mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) != 0)) { /* deleted on server */
- if (!emstorage_get_maildata_by_servermailid(input_mailbox_tbl->mailbox_id, downloaded_uids[i].server_uid, &mail, true, &err)){
- EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid for uid[%s] Failed [%d] \n ", downloaded_uids[i].server_uid, err);
+ (EM_SAFE_STRCMP(downloaded_uids[i].mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) != 0)) {
+ /* deleted on server */
+ if (!emstorage_get_maildata_by_servermailid(multi_user_name,
+ downloaded_uids[i].server_uid,
+ input_mailbox_tbl->mailbox_id,
+ &mail,
+ true,
+ &err)){
+ EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid for uid[%s] Failed [%d] \n ",
+ downloaded_uids[i].server_uid, err);
if (err == EMAIL_ERROR_MAIL_NOT_FOUND){
continue;
}
}
if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
- ret = emcore_delete_mails_from_local_storage(input_mailbox_tbl->account_id, &(mail->mail_id), 1, EMAIL_DELETED_FROM_SERVER, false, &err);
+ ret = emcore_delete_mails_from_local_storage(multi_user_name,
+ input_mailbox_tbl->account_id,
+ &(mail->mail_id),
+ 1,
+ EMAIL_DELETED_FROM_SERVER,
+ false,
+ &err);
/* Update badge count */
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
if (!ret) {
EM_DEBUG_EXCEPTION("emcore_delete_mails_from_local_storage falied - %d", err);
goto FINISH_OFF;
}
}
- if (!emstorage_remove_downloaded_mail(input_mailbox_tbl->account_id, input_mailbox_tbl->mailbox_name, downloaded_uids[i].server_uid, true, &err)) { /* remove uid from uid list */
+ if (!emstorage_remove_downloaded_mail(multi_user_name,
+ input_mailbox_tbl->account_id,
+ input_mailbox_tbl->mailbox_name,
+ downloaded_uids[i].server_uid,
+ true,
+ &err)) { /* remove uid from uid list */
EM_DEBUG_EXCEPTION("emstorage_remove_downloaded_mail failed - %d", err);
/* goto FINISH_OFF; */
}
@@ -1372,19 +1443,30 @@ static int emcore_get_uids_to_download(MAILSTREAM *stream, email_account_t *acco
else if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
/* set seen flag of downloaded mail */
if (downloaded_uids[i].sync_status == EMAIL_SYNC_STATUS_FLAG_CHANGED) {
- if (!emcore_set_flags_field(downloaded_uids[i].account_id, &(downloaded_uids[i].local_uid), 1, EMAIL_FLAGS_FLAGGED_FIELD, downloaded_uids[i].flags_flagged_field, &err)) {
+ if (!emcore_set_flags_field(multi_user_name,
+ downloaded_uids[i].account_id,
+ &(downloaded_uids[i].local_uid),
+ 1,
+ EMAIL_FLAGS_FLAGGED_FIELD,
+ downloaded_uids[i].flags_flagged_field,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_set_flags_field failed [%d]", err);
}
- if (!emcore_set_flags_field(downloaded_uids[i].account_id, &(downloaded_uids[i].local_uid), 1, EMAIL_FLAGS_SEEN_FIELD, downloaded_uids[i].flags_seen_field, &err)) {
+ if (!emcore_set_flags_field(multi_user_name,
+ downloaded_uids[i].account_id,
+ &(downloaded_uids[i].local_uid),
+ 1,
+ EMAIL_FLAGS_SEEN_FIELD,
+ downloaded_uids[i].flags_seen_field,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_set_flags_field failed [%d]", err);
}
else
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
}
-
-
}
+
if (mail != NULL)
emstorage_free_mail(&mail, 1, NULL);
mail = NULL;
@@ -1417,7 +1499,14 @@ FINISH_OFF:
}
/* insert received mail UID to read mail uid table */
-static int emcore_add_read_mail_uid(emstorage_mailbox_tbl_t *input_maibox_data, char *server_mailbox_name, int mail_id, char *uid, int rfc822_size, int rule_id, int *err_code)
+static int emcore_add_read_mail_uid(char *multi_user_name,
+ emstorage_mailbox_tbl_t *input_maibox_data,
+ char *server_mailbox_name,
+ int mail_id,
+ char *uid,
+ int rfc822_size,
+ int rule_id,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("input_maibox_data[%p], server_mailbox_name[%s], uid[%s], rfc822_size[%d], rule_id[%d], err_code[%p]", input_maibox_data, server_mailbox_name, uid, rfc822_size, rule_id, err_code);
@@ -1434,9 +1523,13 @@ static int emcore_add_read_mail_uid(emstorage_mailbox_tbl_t *input_maibox_data,
}
read_mail_uid.account_id = input_maibox_data->account_id;
-
- if (!(input_maibox_data->mailbox_id) || !(server_mailbox_name)){
- if (!emstorage_get_mailbox_by_mailbox_type(input_maibox_data->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl, false, &err)) {
+ if (!(input_maibox_data->mailbox_id) || !(server_mailbox_name)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name,
+ input_maibox_data->account_id,
+ EMAIL_MAILBOX_TYPE_INBOX,
+ &mailbox_tbl,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
@@ -1458,9 +1551,8 @@ static int emcore_add_read_mail_uid(emstorage_mailbox_tbl_t *input_maibox_data,
read_mail_uid.server_uid = uid;
read_mail_uid.rfc822_size = rfc822_size;
- if (!emstorage_add_downloaded_mail(&read_mail_uid, false, &err)) {
+ if (!emstorage_add_downloaded_mail(multi_user_name, &read_mail_uid, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_downloaded_mail failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -1478,7 +1570,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_BODY_SEARCH__
-int emcore_add_mail_text(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, char *stripped_text, int *err_code)
+int emcore_add_mail_text(char *multi_user_name, emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, char *stripped_text, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("input_maibox_data[%p], input_new_mail_tbl_data[%p], err_code[%p]", input_maibox_data, input_new_mail_tbl_data, err_code);
@@ -1502,7 +1594,7 @@ int emcore_add_mail_text(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_m
else
mail_text.body_text = NULL;
- if (!emstorage_add_mail_text(&mail_text, false, &err)) {
+ if (!emstorage_add_mail_text(multi_user_name, &mail_text, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mail_text failed [%d]", err);
goto FINISH_OFF;
}
@@ -1521,9 +1613,15 @@ FINISH_OFF:
}
#endif
-INTERNAL_FUNC int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, int *output_mail_id, int *output_thread_id)
+INTERNAL_FUNC int emcore_add_mail_to_mailbox(char *multi_user_name,
+ emstorage_mailbox_tbl_t *input_maibox_data,
+ emstorage_mail_tbl_t *input_new_mail_tbl_data,
+ int *output_mail_id,
+ int *output_thread_id)
{
- EM_DEBUG_FUNC_BEGIN("input_maibox_data[%p], input_new_mail_tbl_data[%p], uid_elem[%p], output_mail_id[%p], output_thread_id[%p]", mail_stream, input_maibox_data, input_new_mail_tbl_data, output_mail_id, output_thread_id);
+ EM_DEBUG_FUNC_BEGIN("input_maibox_data[%p], input_new_mail_tbl_data[%p], "
+ "uid_elem[%p], output_mail_id[%p], output_thread_id[%p]", mail_stream, input_maibox_data,
+ input_new_mail_tbl_data, output_mail_id, output_thread_id);
int err = EMAIL_ERROR_NONE;
int thread_id = -1;
@@ -1540,48 +1638,79 @@ INTERNAL_FUNC int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maib
input_new_mail_tbl_data->mailbox_id = input_maibox_data->mailbox_id;
input_new_mail_tbl_data->mailbox_type = input_maibox_data->mailbox_type;
- emstorage_begin_transaction(NULL, NULL, NULL);
+ emstorage_begin_transaction(multi_user_name, NULL, NULL, NULL);
/* Get the Mail_id */
- if (!emstorage_increase_mail_id(&(input_new_mail_tbl_data->mail_id), false, &err)) {
+ if (!emstorage_increase_mail_id(multi_user_name, &(input_new_mail_tbl_data->mail_id), false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_increase_mail_id failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
- if (emstorage_get_thread_id_of_thread_mails(input_new_mail_tbl_data, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
+ err = emstorage_get_thread_id_of_thread_mails(multi_user_name,
+ input_new_mail_tbl_data,
+ &thread_id,
+ &latest_mail_id_in_thread,
+ &thread_item_count);
+ if (err != EMAIL_ERROR_NONE)
EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed.");
if (thread_id == -1){
input_new_mail_tbl_data->thread_id = input_new_mail_tbl_data->mail_id;
input_new_mail_tbl_data->thread_item_count = thread_item_count = 1;
- }
- else {
+ } else {
input_new_mail_tbl_data->thread_id = thread_id;
thread_item_count++;
}
- if (!emstorage_add_mail(input_new_mail_tbl_data, 0, false, &err)) {
+ EM_DEBUG_LOG("MULTI USER NAME: [%s]", multi_user_name);
+ input_new_mail_tbl_data->user_name = EM_SAFE_STRDUP(multi_user_name);
+
+ if (!emstorage_add_mail(multi_user_name, input_new_mail_tbl_data, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
if (thread_item_count > 1) {
- if (!emstorage_update_latest_thread_mail(input_new_mail_tbl_data->account_id, input_new_mail_tbl_data->mailbox_id, input_new_mail_tbl_data->thread_id, NULL, -1, -1, NOTI_THREAD_ID_CHANGED_BY_ADD, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ input_new_mail_tbl_data->account_id,
+ input_new_mail_tbl_data->mailbox_id,
+ input_new_mail_tbl_data->mailbox_type,
+ input_new_mail_tbl_data->thread_id,
+ NULL,
+ -1,
+ -1,
+ NOTI_THREAD_ID_CHANGED_BY_ADD,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
- if (!emstorage_update_latest_thread_mail(input_new_mail_tbl_data->account_id, input_new_mail_tbl_data->mailbox_id, input_new_mail_tbl_data->thread_id, NULL, 0, 0, NOTI_THREAD_ID_CHANGED_BY_ADD, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ input_new_mail_tbl_data->account_id,
+ input_new_mail_tbl_data->mailbox_id,
+ input_new_mail_tbl_data->mailbox_type,
+ input_new_mail_tbl_data->thread_id,
+ NULL,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_ADD,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
- if (emstorage_get_thread_id_of_thread_mails(input_new_mail_tbl_data, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
+ if (emstorage_get_thread_id_of_thread_mails(multi_user_name,
+ input_new_mail_tbl_data,
+ &thread_id,
+ &latest_mail_id_in_thread,
+ &thread_item_count) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed.");
if (output_thread_id)
@@ -1590,23 +1719,28 @@ INTERNAL_FUNC int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maib
if (output_mail_id != NULL)
*output_mail_id = input_new_mail_tbl_data->mail_id;
-
-
- if (!emcore_add_read_mail_uid(input_maibox_data, input_maibox_data->mailbox_name, input_new_mail_tbl_data->mail_id, input_new_mail_tbl_data->server_mail_id, input_new_mail_tbl_data->mail_size, 0, &err)) {
+ if (!emcore_add_read_mail_uid(multi_user_name,
+ input_maibox_data,
+ input_maibox_data->mailbox_name,
+ input_new_mail_tbl_data->mail_id,
+ input_new_mail_tbl_data->server_mail_id,
+ input_new_mail_tbl_data->mail_size,
+ 0,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_add_read_mail_uid failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
#ifdef __FEATURE_BODY_SEARCH__
- if (!emcore_add_mail_text(input_maibox_data, input_new_mail_tbl_data, NULL, &err)) {
+ if (!emcore_add_mail_text(multi_user_name, input_maibox_data, input_new_mail_tbl_data, NULL, &err)) {
EM_DEBUG_EXCEPTION("emcore_add_mail_text failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
#endif
- emstorage_commit_transaction(NULL, NULL, NULL);
+ emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL);
FINISH_OFF:
@@ -1743,7 +1877,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code)
+INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(char *multi_user_name, int account_id, MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code)
{
EM_PROFILE_BEGIN(emCoreParseEnvelope);
EM_DEBUG_FUNC_BEGIN("input_envelope[%p], input_uid_elem [%p], output_mail_tbl_data[%p], err_code[%p]", input_envelope, input_uid_elem, output_mail_tbl_data, err_code);
@@ -1760,7 +1894,7 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILST
char *rfc822_subject = NULL;
char *rfc822_from = NULL;
- account_ref = emcore_get_account_reference(account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, account_id, false);
if (!account_ref) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -1820,7 +1954,7 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILST
}
if (input_envelope->subject) {
- temp_mail_tbl_data->subject = emcore_decode_rfc2047_text(input_envelope->subject, &err);
+ temp_mail_tbl_data->subject = emcore_gmime_get_decoding_text(input_envelope->subject);
em_trim_left(temp_mail_tbl_data->subject);
char *charset = NULL;
@@ -1846,8 +1980,6 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILST
EM_DEBUG_EXCEPTION("emcore_get_utf8_address failed [%d]", err);
goto FINISH_OFF;
}
-
-
}
if (input_envelope->to) {
@@ -1855,8 +1987,6 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILST
EM_DEBUG_EXCEPTION("emcore_get_utf8_address failed [%d]", err);
goto FINISH_OFF;
}
-
-
}
if (input_envelope->cc) {
@@ -1922,12 +2052,12 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILST
temp_mail_tbl_data->server_mail_id = EM_SAFE_STRDUP(input_uid_elem->uid);
temp_mail_tbl_data->mail_size = mail_cache_element->rfc822_size;
temp_mail_tbl_data->flags_seen_field = input_uid_elem->flag.seen;
+ temp_mail_tbl_data->flags_draft_field = input_uid_elem->flag.draft;
+ temp_mail_tbl_data->flags_flagged_field = input_uid_elem->flag.flagged;
+ temp_mail_tbl_data->flags_answered_field = input_uid_elem->flag.answered;
+ temp_mail_tbl_data->flags_forwarded_field = input_uid_elem->flag.forwarded;
temp_mail_tbl_data->flags_deleted_field = mail_cache_element->deleted;
- temp_mail_tbl_data->flags_flagged_field = mail_cache_element->flagged;
- temp_mail_tbl_data->flags_answered_field = mail_cache_element->answered;
temp_mail_tbl_data->flags_recent_field = mail_cache_element->recent;
- temp_mail_tbl_data->flags_draft_field = mail_cache_element->draft;
- temp_mail_tbl_data->flags_forwarded_field = input_uid_elem->flag.forwarded;
temp_mail_tbl_data->priority = priority;
temp_mail_tbl_data->report_status = (req_read_receipt ? EMAIL_MAIL_REQUEST_MDN : 0);
temp_mail_tbl_data->attachment_count = 0;
@@ -1935,7 +2065,7 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILST
temp_mail_tbl_data->eas_data = NULL;
temp_mail_tbl_data->account_id = account_id;
- emcore_fill_address_information_of_mail_tbl(temp_mail_tbl_data);
+ emcore_fill_address_information_of_mail_tbl(multi_user_name, temp_mail_tbl_data);
*output_mail_tbl_data = temp_mail_tbl_data;
temp_mail_tbl_data = NULL;
@@ -1964,12 +2094,11 @@ FINISH_OFF:
return ret;
}
-
-
-INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl,
- void **stream,
- emcore_uid_list **input_uid_list,
- int *mail_count,
+INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
+ emstorage_mailbox_tbl_t *input_mailbox_tbl,
+ void **stream,
+ emcore_uid_list **input_uid_list,
+ int *mail_count,
int *unread_mail,
int *vip_mail_count,
int *vip_unread_mail,
@@ -1978,7 +2107,9 @@ INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl
int *err_code)
{
EM_PROFILE_BEGIN(emCoreSyncHeader);
- EM_DEBUG_FUNC_BEGIN("input_mailbox_tbl[%p], input_uid_list [%p], err_code[%p]", input_mailbox_tbl, input_uid_list, err_code);
+ EM_DEBUG_FUNC_BEGIN("input_mailbox_tbl[%p], input_uid_list [%p], err_code[%p]",
+ input_mailbox_tbl, input_uid_list, err_code);
+
if (!stream) {
EM_DEBUG_EXCEPTION ("NULL stream");
if (err_code)
@@ -1988,12 +2119,12 @@ INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl
int ret = false;
int err = EMAIL_ERROR_NONE, err_2 = EMAIL_ERROR_NONE;
- int err_from_vconf = 0;
int download_limit_count;
- email_account_t *account_ref = NULL;
+ email_session_t *session = NULL;
+ email_account_t *account_ref = NULL;
emstorage_rule_tbl_t *rule = NULL;
- emcore_uid_list *uid_list = NULL;
- emcore_uid_list *uid_elem = NULL;
+ emcore_uid_list *uid_list = NULL;
+ emcore_uid_list *uid_elem = NULL;
emstorage_mail_tbl_t *new_mail_tbl_data = NULL;
emstorage_mailbox_tbl_t *destination_mailbox = NULL;
@@ -2011,7 +2142,7 @@ INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl
account_id = input_mailbox_tbl->account_id;
g_current_sync_account_id = account_id;
- account_ref = emcore_get_account_reference(account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, account_id, false);
if (!account_ref) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -2024,18 +2155,18 @@ INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl
goto FINISH_OFF;
}
-
if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && input_mailbox_tbl->local_yn == 1) {
/* mailbox recovery starts */
if (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) {
- if (!emcore_sync_mailbox_list (account_id, "", event_handle, &err)) {
+ if (!emcore_sync_mailbox_list (multi_user_name, account_id, "", event_handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list error [%d] account_id [%d]", err, account_id);
goto FINISH_OFF;
}
}
else {
- EM_DEBUG_EXCEPTION ("because mailbox_name[%s] mailbox_type[%d] of account[%d] is a local box, it cant be synced",
- input_mailbox_tbl->mailbox_name, input_mailbox_tbl->mailbox_type, account_id);
+ EM_DEBUG_EXCEPTION("because mailbox_name[%s] mailbox_type[%d] of account[%d] is "
+ "a local box, it cant be synced",
+ input_mailbox_tbl->mailbox_name, input_mailbox_tbl->mailbox_type, account_id);
err = EMAIL_ERROR_INVALID_MAILBOX;
goto FINISH_OFF;
}
@@ -2045,12 +2176,18 @@ INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl
FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
#ifdef __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__
+ int err_from_vconf = 0;
+
if ((err_from_vconf = vconf_set_int(VCONFKEY_EMAIL_SYNC_STATE, 1)) != 0 ) {
EM_DEBUG_EXCEPTION("vconf_set_int failed (sync state) [%d]", err_from_vconf);
}
#endif /* __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__ */
- if (!emcore_connect_to_remote_mailbox(account_id, input_mailbox_tbl->mailbox_id, (void **)stream, &err) || !*stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name,
+ account_id,
+ input_mailbox_tbl->mailbox_id,
+ (void **)stream,
+ &err) || !*stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err);
goto FINISH_OFF;
}
@@ -2058,286 +2195,367 @@ INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl
if (cancellable)
FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+
+ /* check the connection broken */
+ EM_DEBUG_LOG("((MAILSTREAM *)stream)->nmsgs [%ld]", ((MAILSTREAM *)*stream)->nmsgs);
+
+ unsigned long nmsgs_count = ((MAILSTREAM *)*stream)->nmsgs;
+ if (!nmsgs_count) {
+ EM_DEBUG_LOG("MAILSTREAM");
+ if (!emcore_get_current_session(&session)) {
+ EM_DEBUG_EXCEPTION("emcore_get_current_session failed");
+ err = EMAIL_ERROR_SESSION_NOT_FOUND;
+ goto FINISH_OFF;
+ }
+
+ if (session->error == EMAIL_ERROR_CONNECTION_BROKEN) {
+ EM_DEBUG_EXCEPTION("session error : [%d]", session->error);
+ err = session->error;
+ goto FINISH_OFF;
+ }
+ }
+
/* save total mail count on server to DB */
- if (!emstorage_update_mailbox_total_count(account_id, input_mailbox_tbl->mailbox_id, ((MAILSTREAM *)*stream)->nmsgs, 1, &err)){
+ if (!emstorage_update_mailbox_total_count(multi_user_name,
+ account_id,
+ input_mailbox_tbl->mailbox_id,
+ ((MAILSTREAM *)*stream)->nmsgs,
+ 1,
+ &err)){
EM_DEBUG_EXCEPTION("emstorage_update_mailbox_total_count failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ email_option_t *opt_ref = &account_ref->options;
+ EM_DEBUG_LOG_SEC("block_address = %d, block_subject = %d", opt_ref->block_address, opt_ref->block_subject);
+
+ if (opt_ref->block_address || opt_ref->block_subject) {
+ int is_completed = false;
+ int type = 0;
+
+ if (!opt_ref->block_address)
+ type = EMAIL_FILTER_SUBJECT;
+ else if (!opt_ref->block_subject)
+ type = EMAIL_FILTER_FROM;
+
+ if (!emstorage_get_rule(multi_user_name,
+ ALL_ACCOUNT,
+ type,
+ 0,
+ &rule_count,
+ &is_completed,
+ &rule,
+ true,
+ &err) || !rule) {
+ if ( err != EMAIL_ERROR_FILTER_NOT_FOUND )
+ EM_DEBUG_EXCEPTION ("emstorage_get_rule error [%d]", err);
+ }
+ }
+
+ download_limit_count = input_mailbox_tbl->mail_slot_size;
+ if (!emcore_get_uids_to_download(multi_user_name,
+ *stream,
+ account_ref,
+ input_mailbox_tbl,
+ download_limit_count,
+ &uid_list,
+ &total,
+ EMAIL_SYNC_LATEST_MAILS_FIRST,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_get_uids_to_download failed [%d]", err);
goto FINISH_OFF;
}
- /* if (((MAILSTREAM *)stream)->nmsgs > 0) */
- {
- email_option_t *opt_ref = &account_ref->options;
- EM_DEBUG_LOG_SEC("block_address = %d, block_subject = %d", opt_ref->block_address, opt_ref->block_subject);
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- if (opt_ref->block_address || opt_ref->block_subject) {
- int is_completed = false;
- int type = 0;
+ if (input_uid_list && *input_uid_list){
+ emcore_free_uids(*input_uid_list, NULL);
+ *input_uid_list = uid_list;
+ }
+ uid_elem = uid_list;
+ i = 0;
+ EM_PROFILE_BEGIN(emCoreSyncHeaderwhileloop);
- if (!opt_ref->block_address)
- type = EMAIL_FILTER_SUBJECT;
- else if (!opt_ref->block_subject)
- type = EMAIL_FILTER_FROM;
+#ifdef __FEATURE_HEADER_OPTIMIZATION__
+ /* g.shyamakshi@samsung.com : Bulk fetch of headers only if the receiving server type is IMAP */
- if (!emstorage_get_rule(ALL_ACCOUNT, type, 0, &rule_count, &is_completed, &rule, true, &err) || !rule) {
- if ( err != EMAIL_ERROR_FILTER_NOT_FOUND )
- EM_DEBUG_EXCEPTION ("emstorage_get_rule error [%d]", err);
- }
- }
+ EM_DEBUG_LOG("uid_list [%p]", uid_list);
- download_limit_count = input_mailbox_tbl->mail_slot_size;
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && uid_list != NULL) {
- if (!emcore_get_uids_to_download(*stream, account_ref, input_mailbox_tbl, download_limit_count, &uid_list,
- &total, EMAIL_SYNC_LATEST_MAILS_FIRST, &err)){
- EM_DEBUG_EXCEPTION("emcore_get_uids_to_download failed [%d]", err);
+ if ((err = emcore_make_uid_range_string(uid_list, total, &uid_range)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_make_uid_range_string failed [%d]", err);
goto FINISH_OFF;
}
if (cancellable)
FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- if (input_uid_list && *input_uid_list){
- emcore_free_uids(*input_uid_list, NULL);
- *input_uid_list = uid_list;
- }
uid_elem = uid_list;
- i = 0;
- EM_PROFILE_BEGIN(emCoreSyncHeaderwhileloop);
-
-#ifdef __FEATURE_HEADER_OPTIMIZATION__
- /* g.shyamakshi@samsung.com : Bulk fetch of headers only if the receiving server type is IMAP */
-
- EM_DEBUG_LOG("((MAILSTREAM *)stream)->nmsgs [%d]", ((MAILSTREAM *)*stream)->nmsgs);
- EM_DEBUG_LOG("uid_list [%p]", uid_list);
-
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && uid_list != NULL) {
-
- if ((err = emcore_make_uid_range_string(uid_list, total, &uid_range)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_make_uid_range_string failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
-
- uid_elem = uid_list;
- if (*stream && uid_elem){
- EM_DEBUG_LOG("msgno : %d", uid_elem->msgno);
- ((MAILSTREAM *)*stream)->nmsgs = uid_elem->msgno;
- }
- else{
- EM_DEBUG_LOG("Uid List Null");
- }
- EM_DEBUG_LOG("Calling ... mail_fetch_fast. uid_range [%s]", uid_range);
- mail_fetch_fast(*stream, uid_range, FT_UID | FT_PEEK | FT_NEEDENV);
- EM_SAFE_FREE(uid_range);
+ if (*stream && uid_elem){
+ EM_DEBUG_LOG("msgno : %d", uid_elem->msgno);
+ ((MAILSTREAM *)*stream)->nmsgs = uid_elem->msgno;
+ }
+ else{
+ EM_DEBUG_LOG("Uid List Null");
}
+ EM_DEBUG_LOG("Calling ... mail_fetch_fast. uid_range [%s]", uid_range);
+ mail_fetch_fast(*stream, uid_range, FT_UID | FT_PEEK | FT_NEEDENV);
+ EM_SAFE_FREE(uid_range);
+ }
#endif
- /* h.gahlaut@samsung.com : Clear the event queue of partial body download thread before starting fetching new headers */
+ /* h.gahlaut@samsung.com : Clear the event queue of partial body download thread before starting fetching new headers */
#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
- /* Partial body download feature is only for IMAP accounts */
- if (false == emcore_clear_partial_body_thd_event_que(&err))
- EM_DEBUG_LOG("emcore_clear_partial_body_thd_event_que failed [%d]", err);
+ /* Partial body download feature is only for IMAP accounts */
+ if (false == emcore_clear_partial_body_thd_event_que(&err))
+ EM_DEBUG_LOG("emcore_clear_partial_body_thd_event_que failed [%d]", err);
#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
- }
+ }
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
- while (uid_elem) {
- EM_PROFILE_BEGIN(emCoreSyncHeaderEachMail);
- EM_DEBUG_LOG("mail_fetchstructure_full : uid_elem->msgno[%d]", uid_elem->msgno);
+ while (uid_elem) {
+ EM_PROFILE_BEGIN(emCoreSyncHeaderEachMail);
+ EM_DEBUG_LOG("mail_fetchstructure_full : uid_elem->msgno[%d]", uid_elem->msgno);
- env = NULL;
+ env = NULL;
- if (uid_elem->msgno > ((MAILSTREAM *)*stream)->nmsgs) {
- EM_DEBUG_LOG ("WARN: msgno[%d] can't be greater than nmsgs[%d].",
- uid_elem->msgno, ((MAILSTREAM *)*stream)->nmsgs);
- }
- else{
+ if (uid_elem->msgno > ((MAILSTREAM *)*stream)->nmsgs) {
+ EM_DEBUG_LOG ("WARN: msgno[%d] can't be greater than nmsgs[%d].",
+ uid_elem->msgno, ((MAILSTREAM *)*stream)->nmsgs);
+ }
+ else{
#ifdef __FEATURE_HEADER_OPTIMIZATION__
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */
- env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 0);
- else /* Fetch header from network in case of POP */
- env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 1);
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */
+ env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 0);
+ else /* Fetch header from network in case of POP */
+ env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 1);
#else
- env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK);
+ env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK);
#endif
- }
-
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
-
- if (env != NULL) {
- int searched_mail_id = 0;
- int blocked = false;
- int priority_sender = false;
+ }
- if (!emcore_make_mail_tbl_data_from_envelope (account_id, *stream, env, uid_elem,
- &new_mail_tbl_data, &err) || !new_mail_tbl_data) {
- EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_envelope failed [%d]", err);
- goto CONTINUE_NEXT;
- }
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- /* Check message_id for duplicated mail in sentbox */
- if ((input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX) && (emstorage_check_and_update_server_uid_by_message_id(new_mail_tbl_data->account_id, input_mailbox_tbl->mailbox_type, new_mail_tbl_data->message_id, new_mail_tbl_data->server_mail_id, &searched_mail_id) == EMAIL_ERROR_NONE)) {
- EM_DEBUG_LOG("Existed the duplicated mail : message_id[%s]", new_mail_tbl_data->message_id);
+ if (env != NULL) {
+ int searched_mail_id = 0;
+ int blocked = false;
+ int priority_sender = false;
- if (!emcore_add_read_mail_uid(input_mailbox_tbl, input_mailbox_tbl->mailbox_name, searched_mail_id, new_mail_tbl_data->server_mail_id, new_mail_tbl_data->mail_size, 0, &err)) {
- EM_DEBUG_EXCEPTION("emcore_add_read_mail_uid failed");
- }
+ if (!emcore_make_mail_tbl_data_from_envelope (multi_user_name, account_id, *stream, env, uid_elem,
+ &new_mail_tbl_data, &err) || !new_mail_tbl_data) {
+ EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_envelope failed [%d]", err);
+ goto CONTINUE_NEXT;
+ }
+ /* Check message_id for duplicated mail in sentbox */
+ if ((input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_SENTBOX) &&
+ (emstorage_check_and_update_server_uid_by_message_id(multi_user_name,
+ new_mail_tbl_data->account_id,
+ input_mailbox_tbl->mailbox_type,
+ new_mail_tbl_data->message_id,
+ new_mail_tbl_data->server_mail_id,
+ &searched_mail_id) == EMAIL_ERROR_NONE)) {
+ EM_DEBUG_LOG("Existed the duplicated mail : message_id[%s]", new_mail_tbl_data->message_id);
+
+ if (!emcore_add_read_mail_uid(multi_user_name, input_mailbox_tbl,
+ input_mailbox_tbl->mailbox_name, searched_mail_id,
+ new_mail_tbl_data->server_mail_id, new_mail_tbl_data->mail_size,
+ 0, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_add_read_mail_uid failed : [%d]", err);
goto CONTINUE_NEXT;
}
-
- if (rule && !emcore_check_rule(new_mail_tbl_data->full_address_from, new_mail_tbl_data->subject, rule, rule_count, &priority_sender, &blocked, &err)) {
- EM_DEBUG_EXCEPTION("emcore_check_rule failed [%d]", err);
+
+ if (!emstorage_change_mail_field(multi_user_name, searched_mail_id, UPDATE_DATETIME,
+ new_mail_tbl_data, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed : [%d]", err);
+ goto CONTINUE_NEXT;
}
- if(destination_mailbox) /* cleanup before reusing */
- emstorage_free_mailbox(&destination_mailbox, 1, NULL);
+ goto CONTINUE_NEXT;
+ }
- if (priority_sender) {
- new_mail_tbl_data->tag_id = PRIORITY_SENDER_TAG_ID;
- vip_total ++;
- }
+ if (rule && !emcore_check_rule(new_mail_tbl_data->full_address_from,
+ new_mail_tbl_data->subject,
+ rule,
+ rule_count,
+ &priority_sender,
+ &blocked,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emcore_check_rule failed [%d]", err);
+ }
- if (blocked && (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
- if (input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX) {
- EM_DEBUG_LOG("mail[%d] added to spambox", mail_id);
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SPAMBOX,
- &destination_mailbox, false, &err)) {
- EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
- }
- }
- else
- blocked = 0;
- }
+ if (destination_mailbox) /* cleanup before reusing */
+ emstorage_free_mailbox(&destination_mailbox, 1, NULL);
- /* Set the noti waited */
- new_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_NOTI_WAITED;
+ if (priority_sender) {
+ new_mail_tbl_data->tag_id = PRIORITY_SENDER_TAG_ID;
+ vip_total ++;
+ }
- if (destination_mailbox) {
- if (destination_mailbox->local_yn == 0 || account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
- if ((err = emcore_move_mail_on_server_by_server_mail_id((void*)*stream, new_mail_tbl_data->server_mail_id, destination_mailbox->mailbox_name)) != EMAIL_ERROR_NONE){
- EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_by_server_mail_id falied [%d]", err);
- goto CONTINUE_NEXT;
- }
+ if (blocked && (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
+ if (input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX) {
+ EM_DEBUG_LOG("This mail would be added to spambox");
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name,
+ account_id,
+ EMAIL_MAILBOX_TYPE_SPAMBOX,
+ &destination_mailbox,
+ false,
+ &err)) {
+ EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
}
- else { /* local mailbox */
- if ((err = emcore_add_mail_to_mailbox(destination_mailbox, new_mail_tbl_data, &mail_id,
- &thread_id)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox failed [%d]", err);
- goto CONTINUE_NEXT;
- }
+ }
+ else
+ blocked = 0;
+ }
+ /* Set the noti waited */
+ new_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_NOTI_WAITED;
+
+ if (destination_mailbox) {
+ if (destination_mailbox->local_yn == 0 ||
+ account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ err = emcore_move_mail_on_server_by_server_mail_id((void*)*stream,
+ new_mail_tbl_data->server_mail_id,
+ destination_mailbox->mailbox_name);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_by_server_mail_id falied [%d]", err);
+ goto CONTINUE_NEXT;
}
- SNPRINTF(mailbox_id_param_string, 10, "%d", destination_mailbox->mailbox_id);
- } else {
- /* add mails to specified mail box */
- EM_DEBUG_LOG_SEC("mail[%d] moved to input_mailbox_tbl [%s]", mail_id, input_mailbox_tbl->mailbox_name);
- if ( (err = emcore_add_mail_to_mailbox (input_mailbox_tbl, new_mail_tbl_data,
- &mail_id, &thread_id)) != EMAIL_ERROR_NONE) {
+ } else { /* local mailbox */
+ if ((err = emcore_add_mail_to_mailbox(multi_user_name,
+ destination_mailbox,
+ new_mail_tbl_data,
+ &mail_id,
+ &thread_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err);
goto CONTINUE_NEXT;
}
+ }
+ SNPRINTF(mailbox_id_param_string, 10, "%d", destination_mailbox->mailbox_id);
+ } else {
+ /* add mails to specified mail box */
+ EM_DEBUG_LOG_SEC("mail[%d] moved to input_mailbox_tbl [%s]", mail_id, input_mailbox_tbl->mailbox_name);
+ if ((err = emcore_add_mail_to_mailbox(multi_user_name,
+ input_mailbox_tbl,
+ new_mail_tbl_data,
+ &mail_id,
+ &thread_id)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_add_mail_to_mailbox falied [%d]", err);
+ goto CONTINUE_NEXT;
+ }
+
#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
- if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+ if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
- if (account_ref->auto_download_size != 0) {
- if (false == emcore_initiate_pbd (*stream, account_id, mail_id, uid_elem->uid,
- input_mailbox_tbl->mailbox_id, &err))
- EM_DEBUG_LOG("Partial body download initiation failed [%d]", err);
- }
-#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
+ if (account_ref->auto_download_size != 0) {
+ if (false == emcore_initiate_pbd(multi_user_name,
+ *stream,
+ account_id,
+ mail_id,
+ uid_elem->uid,
+ input_mailbox_tbl->mailbox_id,
+ input_mailbox_tbl->mailbox_name,
+ &err))
+ EM_DEBUG_LOG("Partial body download initiation failed [%d]", err);
}
+#ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
+ }
#endif /* __FEATURE_PARTIAL_BODY_FOR_POP3__ */
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
- if (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) {
- if (!emcore_insert_auto_download_job(account_id, input_mailbox_tbl->mailbox_id,
- mail_id, /*account_ref->wifi_auto_download*/ 1, uid_elem->uid, &err))
- EM_DEBUG_LOG("emcore_insert_auto_download_job failed [%d]", err);
- }
+ if (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) {
+ if (!emcore_insert_auto_download_job(multi_user_name,
+ account_id,
+ input_mailbox_tbl->mailbox_id,
+ mail_id,
+ /*account_ref->wifi_auto_download*/ 1,
+ uid_elem->uid,
+ &err))
+ EM_DEBUG_LOG("emcore_insert_auto_download_job failed [%d]", err);
+ }
#endif
/*
- if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX)
- emcore_add_notification_for_unread_mail(new_mail_tbl_data);
+ if (!uid_elem->flag.seen && input_mailbox_tbl->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX)
+ emcore_add_notification_for_unread_mail(new_mail_tbl_data);
*/
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- if (!uid_elem->flag.seen) {
- unread++;
- if (priority_sender) {
- vip_unread++;
- }
+ if (!uid_elem->flag.seen) {
+ unread++;
+ if (priority_sender) {
+ vip_unread++;
}
-
- percentage = ((i+1) * 100) / total ;
- EM_DEBUG_LOG("Header Percentage Completed [%d] : [%d/%d] mail_id [%d]", percentage, i+1,
- total, mail_id);
- SNPRINTF(mailbox_id_param_string, 10, "%d", input_mailbox_tbl->mailbox_id);
}
- if (!emcore_notify_storage_event (NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id))
- EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
+ percentage = ((i+1) * 100) / total ;
+ EM_DEBUG_LOG("Header Percentage Completed [%d] : [%d/%d] mail_id [%d]", percentage, i+1,
+ total, mail_id);
+ SNPRINTF(mailbox_id_param_string, 10, "%d", input_mailbox_tbl->mailbox_id);
+ }
-#ifdef __FEATURE_BLOCKING_MODE__
- /* Check the blocking mode */
- int blocking_mode = false;
-
- blocking_mode = emcore_get_blocking_mode_status();
- if (!blocking_mode) {
- if ((err = emcore_check_blocking_mode (new_mail_tbl_data->email_address_sender,
- &blocking_mode)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION ("emcore_check_blocking_mode failed : [%d]", err);
- }
+ if (!emcore_notify_storage_event (NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id))
+ EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
- if (blocking_mode)
- emcore_set_blocking_mode_status (blocking_mode);
+#ifdef __FEATURE_BLOCKING_MODE__
+ /* Check the blocking mode */
+ int blocking_mode = false;
+
+ blocking_mode = emcore_get_blocking_mode_status();
+ if (!blocking_mode) {
+ if ((err = emcore_check_blocking_mode (multi_user_name, new_mail_tbl_data->email_address_sender,
+ &blocking_mode)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION ("emcore_check_blocking_mode failed : [%d]", err);
}
+
+ if (blocking_mode)
+ emcore_set_blocking_mode_status (blocking_mode);
+ }
#endif /* __FEATURE_BLOCKING_MODE__ */
- /* Set contact log */
- switch (input_mailbox_tbl->mailbox_type) {
- case EMAIL_MAILBOX_TYPE_INBOX :
- if ((err = emcore_set_received_contacts_log(new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_set_received_contacts_log failed : [%d]", err);
- }
- break;
- case EMAIL_MAILBOX_TYPE_SENTBOX:
- case EMAIL_MAILBOX_TYPE_OUTBOX:
- if ((err = emcore_set_sent_contacts_log(new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_set_sent_contacts_log failed : [%d]", err);
- }
- break;
- default:
- EM_DEBUG_LOG("Mailbox type : [%d]", input_mailbox_tbl->mailbox_type);
- break;
+ /* Set contact log */
+ switch (input_mailbox_tbl->mailbox_type) {
+ case EMAIL_MAILBOX_TYPE_INBOX :
+ if ((err = emcore_set_received_contacts_log(multi_user_name, new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_received_contacts_log failed : [%d]", err);
+ }
+ break;
+ case EMAIL_MAILBOX_TYPE_SENTBOX:
+ case EMAIL_MAILBOX_TYPE_OUTBOX:
+ if ((err = emcore_set_sent_contacts_log(multi_user_name, new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_sent_contacts_log failed : [%d]", err);
}
+ break;
+ default:
+ EM_DEBUG_LOG("Mailbox type : [%d]", input_mailbox_tbl->mailbox_type);
+ break;
+ }
- /* Release for envelope is not required and it may cause crash. Don't free the memory for envelope here. */
- /* Envelope data will be freed by garbage collector in mail_close_full */
+ /* Release for envelope is not required and it may cause crash. Don't free the memory for envelope here. */
+ /* Envelope data will be freed by garbage collector in mail_close_full */
- if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
- }
+ if (cancellable)
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+ }
CONTINUE_NEXT:
- if (new_mail_tbl_data){
- emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
- new_mail_tbl_data = NULL;
- }
- uid_elem = uid_elem->next;
- i++;
- EM_PROFILE_END(emCoreSyncHeaderEachMail);
+ if (new_mail_tbl_data){
+ emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
+ new_mail_tbl_data = NULL;
}
- EM_PROFILE_END(emCoreSyncHeaderwhileloop);
+ uid_elem = uid_elem->next;
+ i++;
+ EM_PROFILE_END(emCoreSyncHeaderEachMail);
}
+ EM_PROFILE_END(emCoreSyncHeaderwhileloop);
ret = true;
+
FINISH_OFF:
if (mail_count != NULL)
@@ -2357,11 +2575,11 @@ FINISH_OFF:
EM_SAFE_FREE(account_ref);
}
- if (!emcore_remove_overflowed_mails(input_mailbox_tbl, &err_2))
+ if (!emcore_remove_overflowed_mails(multi_user_name, input_mailbox_tbl, &err_2))
EM_DEBUG_EXCEPTION("emcore_remove_overflowed_mails failed - %d", err_2);
if (ret && input_mailbox_tbl)
- emstorage_stamp_last_sync_time_of_mailbox(input_mailbox_tbl->mailbox_id, 1);
+ emstorage_stamp_last_sync_time_of_mailbox(multi_user_name, input_mailbox_tbl->mailbox_id, 1);
#ifdef __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__
if ((err_from_vconf = vconf_set_int(VCONFKEY_EMAIL_SYNC_STATE, 0)) != 0 ) {
@@ -2417,7 +2635,7 @@ emcore_uid_list *__ReverseList(emcore_uid_list *uid_list)
-int emcore_download_uid_all(MAILSTREAM *mail_stream, email_internal_mailbox_t *mailbox, emcore_uid_list** uid_list, int *total, emstorage_read_mail_uid_tbl_t *downloaded_uids, int count, emcore_get_uids_for_delete_t for_delete, int *err_code)
+int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, email_internal_mailbox_t *mailbox, emcore_uid_list** uid_list, int *total, emstorage_read_mail_uid_tbl_t *downloaded_uids, int count, emcore_get_uids_for_delete_t for_delete, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox[%p], uid_list[%p], total[%p], downloaded_uids[%p], count[%d], for_delete[%d], err_code[%p]", mailbox, uid_list, total, downloaded_uids, count, for_delete, err_code);
@@ -2439,7 +2657,7 @@ int emcore_download_uid_all(MAILSTREAM *mail_stream, email_internal_mailbox_t *m
goto FINISH_OFF;
}
- if (!(ref_account = emcore_get_account_reference(mailbox->account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, mailbox->account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", mailbox->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -2447,7 +2665,7 @@ int emcore_download_uid_all(MAILSTREAM *mail_stream, email_internal_mailbox_t *m
}
if (!mail_stream) {
- if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)){
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)){
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed...");
goto FINISH_OFF;
@@ -2477,7 +2695,6 @@ int emcore_download_uid_all(MAILSTREAM *mail_stream, email_internal_mailbox_t *m
if (!net_sout(pop3local->netstream, cmd, (int)EM_SAFE_STRLEN(cmd))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
-
err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
@@ -2580,7 +2797,6 @@ int emcore_download_uid_all(MAILSTREAM *mail_stream, email_internal_mailbox_t *m
#endif
if (!net_sout(imaplocal->netstream, cmd, (int)EM_SAFE_STRLEN(cmd))) {
EM_DEBUG_EXCEPTION("net_sout failed...");
-
err = EMAIL_ERROR_CONNECTION_BROKEN;
goto FINISH_OFF;
}
@@ -2716,7 +2932,7 @@ FINISH_OFF:
return ret;
}
-int emcore_download_imap_msgno(email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code)
+int emcore_download_imap_msgno(char *multi_user_name, email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox[%p], uid[%p], msgno[%p], err_code[%p]", mailbox, uid, msgno, err_code);
@@ -2736,7 +2952,7 @@ int emcore_download_imap_msgno(email_internal_mailbox_t *mailbox, char *uid, int
goto FINISH_OFF;
}
- if (!(ref_account = emcore_get_account_reference(mailbox->account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, mailbox->account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", mailbox->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -2749,7 +2965,7 @@ int emcore_download_imap_msgno(email_internal_mailbox_t *mailbox, char *uid, int
}
if (!mailbox->mail_stream) {
- if (!emcore_connect_to_remote_mailbox(mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mailbox->account_id, mailbox->mailbox_id, (void **)&tmp_stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err);
goto FINISH_OFF;
@@ -2935,7 +3151,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC char *emcore_guess_charset(char *source_string)
+INTERNAL_FUNC char *emcore_guess_charset(char *multi_user_name, char *source_string)
{
EM_DEBUG_FUNC_BEGIN("source - %s", source_string);
@@ -2995,9 +3211,9 @@ INTERNAL_FUNC char *emcore_guess_charset(char *source_string)
EM_DEBUG_LOG("ucsdet_getConfidence failed");
charset = ucsdet_getName(match[i], &err);
- if (U_FAILURE(err))
+ if(U_FAILURE(err))
EM_DEBUG_LOG("ucsdet_getName failed");
-
+
if (most_confidence < confidence) {
most_confidence = confidence;
detected_charset = charset;
@@ -3019,7 +3235,7 @@ INTERNAL_FUNC char *emcore_guess_charset(char *source_string)
if (uscdet_result_charset)
return uscdet_result_charset;
- account_ref = emcore_get_account_reference(g_current_sync_account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, g_current_sync_account_id, false);
if (!account_ref) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d",
g_current_sync_account_id);
@@ -3051,7 +3267,7 @@ void mail_appenduid(char *mailbox, unsigned long uidvalidity, SEARCHSET *set)
EM_DEBUG_LOG("append uid - %s", g_append_uid_rsp);
}
-INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id)
+INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name, int mail_id)
{
EM_DEBUG_FUNC_BEGIN("mail_id [%d]", mail_id);
@@ -3077,26 +3293,26 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id)
int alloc_size = 0;
/* get a mail from mail table */
- if (!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
- account_ref = emcore_get_account_reference(mail_table_data->account_id);
-
+ account_ref = emcore_get_account_reference(multi_user_name, mail_table_data->account_id, false);
if(account_ref == NULL || account_ref->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
EM_DEBUG_EXCEPTION("This account doesn't support sync");
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if ((err = emstorage_get_attachment_list(mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("mailbox_id [%d]", mail_table_data->mailbox_id);
- if ((err = emstorage_get_mailbox_by_id(mail_table_data->mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl){
+
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, mail_table_data->mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl){
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err);
goto FINISH_OFF;
}
@@ -3107,7 +3323,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id)
goto FINISH_OFF;
}
- if (!emcore_get_long_encoded_path(mailbox_tbl->account_id, mailbox_tbl->mailbox_name, '/', &long_enc_path, &err)) {
+ if (!emcore_get_long_encoded_path(multi_user_name, mailbox_tbl->account_id, mailbox_tbl->mailbox_name, '/', &long_enc_path, &err)) {
EM_DEBUG_EXCEPTION(">>emcore_get_long_encoded_path : Failed [%d] ", err);
goto FINISH_OFF;
}
@@ -3117,7 +3333,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id)
goto FINISH_OFF;
}
- if (!emcore_make_rfc822_file_from_mail(mail_table_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fname, NULL, &err)){
+ if (!emcore_make_rfc822_file_from_mail(multi_user_name, mail_table_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fname, NULL, &err)){
EM_DEBUG_EXCEPTION(" emcore_make_rfc822_file_from_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -3150,7 +3366,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id)
rewind(fp);
- if (!emcore_connect_to_remote_mailbox(mail_table_data->account_id, 0, (void **)&stream, &err)){
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, mail_table_data->account_id, 0, (void **)&stream, &err)){
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : Mailbox open[%d]", err);
goto FINISH_OFF;
}
@@ -3259,16 +3475,16 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id)
}
/* Update read_mail_uid tbl */
- if (!emcore_add_read_mail_uid(mailbox_tbl, mailbox_tbl->mailbox_name, mail_table_data->mail_id, g_append_uid_rsp, mail_table_data->mail_size, 0, &err)) {
+ if (!emcore_add_read_mail_uid(multi_user_name, mailbox_tbl, mailbox_tbl->mailbox_name, mail_table_data->mail_id, g_append_uid_rsp, mail_table_data->mail_size, 0, &err)) {
EM_DEBUG_EXCEPTION(" emcore_add_read_mail_uid failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
/* Update mail_data tbl */
- if (!emstorage_update_server_uid(mail_table_data->server_mail_id, g_append_uid_rsp, &err)) {
+ if (!emstorage_update_server_uid(multi_user_name, mail_table_data->server_mail_id, g_append_uid_rsp, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_server_uid failed : [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
@@ -3330,14 +3546,16 @@ FINISH_OFF:
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id, char *uid, int input_maibox_id, int *err_code)
+INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream, int account_id,
+ int mail_id, char *uid, int input_maibox_id,
+ char *input_mailbox_name, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_maibox_id[%d]", account_id, mail_id, uid, input_maibox_id);
+ EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_id[%d], uid[%p], input_maibox_id[%d], input_mailbox_name[%s]",
+ account_id, mail_id, uid, input_maibox_id, input_mailbox_name);
int ret = false;
int err = EMAIL_ERROR_NONE;
email_account_t *account_ref = NULL;
- emstorage_mailbox_tbl_t* mailbox = NULL;
if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || 0 == input_maibox_id){
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -3345,10 +3563,20 @@ static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id,
goto FINISH_OFF;
}
- account_ref = emcore_get_account_reference(account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, account_id, false);
+ if (account_ref == NULL) {
+ EM_DEBUG_EXCEPTION("emcore_get_account_reference failed");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
- email_event_partial_body_thd pbd_event;
+ if (account_ref->auto_download_size == 0) {
+ EM_DEBUG_LOG("Header only download");
+ ret = true;
+ goto FINISH_OFF;
+ }
+ email_event_partial_body_thd pbd_event;
memset(&pbd_event, 0x00, sizeof(email_event_partial_body_thd));
pbd_event.account_id = account_id;
@@ -3357,19 +3585,16 @@ static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id,
else
pbd_event.activity_type = ACTIVITY_PARTIAL_BODY_DOWNLOAD_IMAP4;
- if ( (err = emstorage_get_mailbox_by_id(input_maibox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- pbd_event.mailbox_id = input_maibox_id;
- pbd_event.mail_id = mail_id;
- pbd_event.server_mail_id = strtoul(uid, NULL, 0);
- pbd_event.mailbox_name = EM_SAFE_STRDUP(mailbox->mailbox_name);
+ pbd_event.mail_id = mail_id;
+ pbd_event.server_mail_id = strtoul(uid, NULL, 0);
+ pbd_event.mailbox_id = input_maibox_id;
+ pbd_event.mailbox_name = EM_SAFE_STRDUP(input_mailbox_name);
+ pbd_event.multi_user_name = EM_SAFE_STRDUP(multi_user_name);
EM_DEBUG_LOG("input_mailbox_name name [%d]", pbd_event.mailbox_id);
EM_DEBUG_LOG("uid [%s]", uid);
- EM_DEBUG_LOG("pbd_event.account_id[%d], pbd_event.mail_id[%d], pbd_event.server_mail_id [%d]", pbd_event.account_id, pbd_event.mail_id , pbd_event.server_mail_id);
+ EM_DEBUG_LOG("pbd_event.account_id[%d], pbd_event.mail_id[%d], pbd_event.server_mail_id [%d]",
+ pbd_event.account_id, pbd_event.mail_id , pbd_event.server_mail_id);
if (!emcore_insert_pbd_activity(&pbd_event, &pbd_event.activity_id, &err)){
EM_DEBUG_EXCEPTION("Inserting Partial Body Download activity failed with error[%d]", err);
@@ -3402,16 +3627,12 @@ static int emcore_initiate_pbd(MAILSTREAM *stream, int account_id, int mail_id,
FINISH_OFF:
- if (mailbox) {
- emstorage_free_mailbox(&mailbox, 1, &err);
- }
-
if (account_ref) {
emcore_free_account(account_ref);
EM_SAFE_FREE(account_ref);
}
- emcore_free_partial_body_thd_event(&pbd_event, NULL);
+ emcore_free_partial_body_thd_event(&pbd_event, NULL);
if (NULL != err_code)
*err_code = err;
@@ -3420,96 +3641,17 @@ FINISH_OFF:
return ret;
}
-static int emcore_parse_bodystructure(void *stream, IMAPPARSEDREPLY *reply_from_server, char *bodystructure, BODY **body, struct _m_content_info **cnt_info, int *total_mail_size)
-{
- EM_DEBUG_FUNC_BEGIN("stream:[%p], reply_from_server:[%p], bodystructure:[%p]", stream, reply_from_server, bodystructure);
-
- int err = EMAIL_ERROR_NONE;
- char* ptr = NULL;
-
- if (!stream || !reply_from_server || !bodystructure || !cnt_info || !body || !total_mail_size) {
- EM_DEBUG_EXCEPTION("Invalid paramter stream[%p] reply_from_server[%p] bodystructure[%p] cnt_info[%p] body[%p] total_mail_size[%p]",
- stream, reply_from_server, bodystructure, cnt_info, body, total_mail_size);
- err = EMAIL_ERROR_INVALID_PARAM;
- return err;
- }
-
- int p_total_mail_size = 0;
- char *bodystructure_start = NULL;
- char *bodystructure_string = NULL;
- BODY *p_body = NULL;
- struct _m_content_info *p_cnt_info = NULL;
-
- /* Get the body strcuture string */
- bodystructure_start = strstr(bodystructure, "BODYSTRUCTURE (");
- if (!bodystructure_start) {
- EM_DEBUG_EXCEPTION("Invalid bodystructure :[%s]", bodystructure);
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- bodystructure_start = bodystructure_start + strlen("BODYSTRUCTURE");
- ptr = bodystructure_string = strdup(bodystructure_start);
-
- EM_DEBUG_LOG_DEV("BODYSTRUCTURE:%s", bodystructure_string);
-
- /* Parse the bodystructure string */
- p_body = mail_newbody();
- if (p_body == NULL) {
- EM_DEBUG_EXCEPTION("New body creationg failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- /* valgrind : free body->sparep */
- mail_parameters(stream, SET_FREEBODYSPAREP, emcore_free_body_sparep);
-
- /*imap_parse_body_structure changes param pointer*/
- imap_parse_body_structure(stream, p_body, (unsigned char **)&bodystructure_string, reply_from_server);
-
- /* Get the total mail size */
- if (emcore_set_fetch_body_section(p_body, true, &p_total_mail_size, NULL, &err) < 0) {
- EM_DEBUG_EXCEPTION("emcore_set_fetch_body_section failed:[%d]", err);
- goto FINISH_OFF;
- }
-
- /* Fill the content_info structure */
- if (!(p_cnt_info = em_malloc(sizeof(struct _m_content_info)))) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- if (emcore_get_body(stream, 0, 0, 0, p_body, NULL, p_cnt_info, &err) < 0 || !p_cnt_info) {
- EM_DEBUG_EXCEPTION("emcore_get_body failed[%d]", err);
- err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
-
- EM_SAFE_FREE(ptr);
-
- if (err != EMAIL_ERROR_NONE) {
- if (p_cnt_info) {
- emcore_free_content_info(p_cnt_info);
- EM_SAFE_FREE(p_cnt_info);
- }
- if (p_body)
- mail_free_body(&p_body);
- } else {
- *cnt_info = p_cnt_info;
- *body = p_body;
- *total_mail_size = p_total_mail_size;
- }
-
- EM_DEBUG_FUNC_END("Err:[%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_update_attachment_except_inline(struct _m_content_info *cnt_info, int account_id, int mail_id, int mailbox_id, int *output_total_attachment_size, int *output_attachment_count, int *output_inline_attachment_count)
+INTERNAL_FUNC int emcore_update_attachment_except_inline(char *multi_user_name,
+ struct _m_content_info *cnt_info,
+ int account_id,
+ int mail_id,
+ int mailbox_id,
+ int *output_total_attachment_size,
+ int *output_attachment_count,
+ int *output_inline_attachment_count)
{
- EM_DEBUG_FUNC_BEGIN("cnt_info : [%p], account_id : [%d], mail_id : [%d], mailbox_id : [%d]", cnt_info, account_id, mail_id, mailbox_id);
+ EM_DEBUG_FUNC_BEGIN("cnt_info : [%p], account_id : [%d], mail_id : [%d], mailbox_id : [%d]",
+ cnt_info, account_id, mail_id, mailbox_id);
int err = EMAIL_ERROR_NONE;
if (!cnt_info || !account_id || !mail_id || !mailbox_id) {
@@ -3530,23 +3672,13 @@ INTERNAL_FUNC int emcore_update_attachment_except_inline(struct _m_content_info
attachment_tbl.mailbox_id = mailbox_id;
attachment_tbl.attachment_save_status = 0;
-#ifdef __FEATURE_USE_GMIME__
for (inline_attachment_count = 0, attach_info = cnt_info->inline_file; attach_info; attach_info = attach_info->next) {
if (attach_info->type == INLINE_ATTACHMENT) {
inline_attachment_count++;
}
}
-#endif
for (attachment_count = 0, attach_info = cnt_info->file; attach_info; attach_info = attach_info->next, attachment_count++) {
-
-#ifndef __FEATURE_USE_GMIME__
- if (attach_info->type == INLINE_ATTACHMENT) {
- EM_DEBUG_LOG("INLINE ATTACHMENT");
- inline_attachment_count++;
- continue;
- }
-#endif
total_attach_size += attach_info->size;
attachment_tbl.attachment_size = attach_info->size;
attachment_tbl.attachment_path = attach_info->save;
@@ -3558,8 +3690,7 @@ INTERNAL_FUNC int emcore_update_attachment_except_inline(struct _m_content_info
attachment_tbl.encoding = attach_info->encoding;
attachment_tbl.section = attach_info->section;
#endif
-
- if (!emstorage_add_attachment(&attachment_tbl, 0, false, &err)) {
+ if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed : [%d]", err);
goto FINISH_OFF;
}
@@ -3571,11 +3702,7 @@ INTERNAL_FUNC int emcore_update_attachment_except_inline(struct _m_content_info
FINISH_OFF:
if (output_attachment_count)
-#ifdef __FEATURE_USE_GMIME__
*output_attachment_count = attachment_count;
-#else
- *output_attachment_count = attachment_count - inline_attachment_count;
-#endif
if (output_inline_attachment_count)
*output_inline_attachment_count = inline_attachment_count;
@@ -3592,850 +3719,6 @@ FINISH_OFF:
#define TEMP_STRING_LENGTH 50
#define CONTENT_TRANSFER_ENCODING_STRING "Content-Transfer-Encoding"
-static int emcore_parse_html_part_for_partial_body(char *start_header, char *boundary_string, char *bufsendforparse, char *text_html, int body_size)
-{
- EM_DEBUG_FUNC_BEGIN("start_header [%p], boundary_string [%s], bufsendforparse [%s], text_html [%s], body_size [%d]", start_header, boundary_string, bufsendforparse, text_html, body_size);
-
- int err = EMAIL_ERROR_NONE;
- int iEncodingHeader = 0;
- int enc_type = ENCOTHER, dec_len = 0;
- char EncodingHeader[40] = {0};
- char Encoding[30] = {0};
- char *pEncodingHeaderEnd = NULL;
- char *txt_html = NULL;
- char *pHeaderStart = NULL;
- char *start = NULL, *end = NULL;
- char *temp_enc1 = NULL;
-
- EM_DEBUG_LOG("Content-Type : text/html or message/rfc822 or text/rfc822-headers");
-
- if(start_header == NULL) { /*prevent 27448*/
- EM_DEBUG_EXCEPTION("start_header NULL");
- return false;
- }
-
- pHeaderStart = start_header;
- pHeaderStart = pHeaderStart-2;
- do{
- pHeaderStart--;
- } while (*pHeaderStart != LF && bufsendforparse < pHeaderStart);
-
- pHeaderStart++;
-
- /* Check string size */
- if (EM_SAFE_STRLEN(pHeaderStart) < strlen(CONTENT_TRANSFER_ENCODING_STRING)) {
- EM_DEBUG_EXCEPTION("pHeaderStart is truncated.");
- return false;
- }
-
- memcpy(EncodingHeader, pHeaderStart, strlen(CONTENT_TRANSFER_ENCODING_STRING));
-
- if (strcasecmp(EncodingHeader, CONTENT_TRANSFER_ENCODING_STRING) == 0){
- pEncodingHeaderEnd = strstr(pHeaderStart, CRLF_STRING);
-
- if ((pEncodingHeaderEnd - (pHeaderStart+27)) > 30) {
- EM_DEBUG_EXCEPTION("Encoding is too long");
- return false;
- }
- memcpy(Encoding, pHeaderStart + 27, pEncodingHeaderEnd - (pHeaderStart+27));
- iEncodingHeader = 1;
- }
-
- /* HTML Content found */
- txt_html = start_header;
- txt_html = strstr(txt_html, CRLF_STRING CRLF_STRING);
-
- if (txt_html != NULL){
- txt_html += 4; /* txt_html points at html content */
- start = txt_html;
- char multipart_boundary[MULTIPART_BOUNDARY_LENGTH] = {0};
- char *multipart_related_boundry = NULL;
- char *multipart_related_boundry_end = NULL;
-
- if (iEncodingHeader == 1)
- multipart_related_boundry = pHeaderStart;
- else
- multipart_related_boundry = start_header;
-
- multipart_related_boundry = multipart_related_boundry - 3;
- multipart_related_boundry_end = multipart_related_boundry;
-
- while (bufsendforparse < multipart_related_boundry && *multipart_related_boundry != LF && *multipart_related_boundry != NULL_CHAR)
- multipart_related_boundry -= 1;
-
- if ((multipart_related_boundry_end - multipart_related_boundry) > MULTIPART_BOUNDARY_LENGTH) {
- EM_DEBUG_EXCEPTION("Encoding is too long");
- return false;
- }
-
- memcpy(multipart_boundary, multipart_related_boundry, multipart_related_boundry_end - multipart_related_boundry);
-
- if (strcmp(multipart_boundary, boundary_string) == 0)
- end = strstr(txt_html, boundary_string);
- else
- end = strstr(txt_html, multipart_boundary);
-
- memset(multipart_boundary, 0, EM_SAFE_STRLEN(multipart_boundary));
-
- if (end == NULL) {
- EM_DEBUG_LOG("HTML body contents exceeds limited Bytes");
- end = txt_html + body_size - (txt_html - bufsendforparse);
- }
- else if(end == txt_html) { /* empty multipart */
- EM_DEBUG_LOG("Emtpy HTML multipart");
- return false;
- }
- else {
- if ((*(end-2) == CR) && (*(end-1) == LF))
- end -= 2;
- else if ((*(end-2) == CR) && (*(end-1) == LF)
- && (*(end-4) == CR) && (*(end-3) == LF))
- end -= 4;
- else
- EM_DEBUG_EXCEPTION(" Content not per as grammar.");
- }
- EM_DEBUG_LOG("iEncodingHeader [%d]", iEncodingHeader);
-
- if (iEncodingHeader == 1){
- enc_type = ENCOTHER;
- if (strncasecmp(Encoding, "base64", strlen("base64")) == 0)
- enc_type = ENCBASE64;
- else if (strncasecmp(Encoding, "quoted-printable", strlen("quoted-printable")) == 0)
- enc_type = ENCQUOTEDPRINTABLE;
-
- EM_DEBUG_LOG("enc_type [%d]", enc_type);
-
- memcpy(text_html, start, end - txt_html);
-
- if (emcore_decode_body_text(text_html, end - txt_html, enc_type , &dec_len, &err) < 0)
- EM_DEBUG_EXCEPTION("emcore_decode_body_text failed [%d]", err);
- }
- else if ((temp_enc1 = (char *)strcasestr(start_header, "Content-transfer-encoding:")) && (temp_enc1 < end)){ /*prevent 27448*/
- if (temp_enc1)
- start_header = temp_enc1;
-
- start_header += strlen(CONTENT_TRANSFER_ENCODING_STRING);
- start_header = em_skip_whitespace_without_strdup(start_header);
-
- if (!start_header)
- EM_DEBUG_EXCEPTION(" Invalid parsing ");
- else{
- enc_type = ENCOTHER;
- if (strncasecmp(start_header, "base64", strlen("base64")) == 0)
- enc_type = ENCBASE64;
- else if (strncasecmp(start_header, "quoted-printable", strlen("quoted-printable")) == 0)
- enc_type = ENCQUOTEDPRINTABLE;
-
- EM_DEBUG_LOG("enc_type [%d]", enc_type);
-
- memcpy(text_html, start, end - txt_html);
-
- if (emcore_decode_body_text(text_html, end - txt_html, enc_type , &dec_len, &err) < 0)
- EM_DEBUG_EXCEPTION("emcore_decode_body_text failed [%d]", err);
- }
-
- EM_DEBUG_LOG("Decoded length = %d", dec_len);
- }
- else{
- memcpy(text_html, start, end-txt_html);
- }
-
- /* EM_DEBUG_LOG(" Content-Type: text/html [%s]\n", text_html); */
- }
- else
- EM_DEBUG_EXCEPTION(" Invalid html body content ");
-
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-
-
-/*For the following scenario
-*------= SAMSUNG_mySingle_MIME_MULTIPART_BOUNDARY
-*Content-Transfer-Encoding : base64
-*Content-Type : text/plain; charset = "windows-1252"
-*MIME-Version : 1.0
-*Message-ID: <11512468.945901271910226702.JavaMail.weblogic@epml03>
-*/
-
-#define CONTENT_TRANSFER_ENCODING "Content-Transfer-Encoding"
-
-static int emcore_parse_plain_part_for_partial_body(char *header_start_string, char *start_header, char *boundary_string, char *bufsendforparse, char *text_plain, int body_size)
-{
- EM_DEBUG_FUNC_BEGIN("header_start_string[%p], start_header[%p], boundary_string [%p], bufsendforparse [%p], text_plain [%p]", header_start_string, start_header, boundary_string, bufsendforparse, text_plain);
- int err = EMAIL_ERROR_NONE, iEncodingHeader = 0, enc_type = ENCOTHER;
- int dec_len = 0, strcmpret = -1;
- char *pHeaderStart = NULL, *pEncodingHeaderEnd = NULL;
- char EncodingHeader[40] = {0, };
- char Encoding[30] = {0, };
- char *start = NULL, *end = NULL, *txt_plain = NULL, *temp_enc1 = NULL;
-
- EM_DEBUG_LOG("Content-Type : text/plain");
-
- pHeaderStart = header_start_string;
-
- memcpy(EncodingHeader, pHeaderStart, 25);
-
- if (strcasecmp(EncodingHeader, CONTENT_TRANSFER_ENCODING_STRING) == 0){
- pEncodingHeaderEnd = strstr(pHeaderStart, CRLF_STRING);
- memcpy(Encoding, pHeaderStart + 27, pEncodingHeaderEnd - (pHeaderStart + 27));
- iEncodingHeader = 1;
- }
-
- /* Plain text content found */
- if(!start_header) { /*prevent 27450*/
- EM_DEBUG_EXCEPTION("start_header NULL");
- return false;
- }
- txt_plain = start_header;
- txt_plain = strstr(txt_plain, CRLF_STRING CRLF_STRING);
-
- if (txt_plain != NULL){
- txt_plain += EM_SAFE_STRLEN(CRLF_STRING CRLF_STRING); /* txt_plain points at plain text content */
-
- /* Fix is done for mail having "Content-Type: text/plain" but there is no content but having only attachment. */
-
- strcmpret = strncmp(txt_plain, boundary_string, EM_SAFE_STRLEN(boundary_string));
- if (strcmpret == 0){
- }
- else{
- start = txt_plain;
- end = strstr(txt_plain, boundary_string);
-
- if (end == NULL){
- EM_DEBUG_LOG("Text body contents exceeds limited Bytes");
- end = txt_plain + body_size - (txt_plain - bufsendforparse);
- }
- else{
- /* EM_DEBUG_LOG("pbd_event[temp_count].partial_body_complete - %d", partial_body_complete); */
-
- if ((*(end-2) == CR) && (*(end-1) == LF))
- end -= 2;
- else if ((*(end-2) == CR) && (*(end-1) == LF)
- && (*(end-4) == CR) && (*(end-3) == LF))
- end -= 4;
- else
- EM_DEBUG_EXCEPTION(" Content not per as grammar.");
- }
-
- if (iEncodingHeader == 1){
- enc_type = ENCOTHER;
- if (strncasecmp(Encoding, "base64", strlen("base64")) == 0)
- enc_type = ENCBASE64;
- else if (strncasecmp(Encoding, "quoted-printable", strlen("quoted-printable")) == 0)
- enc_type = ENCQUOTEDPRINTABLE;
-
- EM_DEBUG_LOG("enc_type [%d]", enc_type);
-
- memcpy(text_plain, start, end - txt_plain);
-
- if (emcore_decode_body_text(text_plain, end - txt_plain, enc_type , &dec_len, &err) < 0)
- EM_DEBUG_EXCEPTION("emcore_decode_body_text failed [%d]", err);
- }
- else if (start_header && ((temp_enc1 = (char *)strcasestr(start_header, "Content-transfer-encoding:")) != NULL) && !(temp_enc1 && temp_enc1 >= end)){
- if (temp_enc1)
- start_header = temp_enc1;
-
- start_header += strlen(CONTENT_TRANSFER_ENCODING_STRING);
- start_header = em_skip_whitespace_without_strdup(start_header);
-
- if (!start_header)
- EM_DEBUG_EXCEPTION(" Invalid parsing ");
- else{
- enc_type = ENCOTHER;
- if (strncasecmp(start_header, "base64", strlen("base64")) == 0)
- enc_type = ENCBASE64;
- else if (strncasecmp(start_header, "quoted-printable", strlen("quoted-printable")) == 0)
- enc_type = ENCQUOTEDPRINTABLE;
-
- EM_DEBUG_LOG("enc_type [%d]", enc_type);
- memcpy(text_plain, start, end - txt_plain);
- if (emcore_decode_body_text(text_plain, end - txt_plain, enc_type , &dec_len, &err) < 0)
- EM_DEBUG_EXCEPTION("emcore_decode_body_text failed [%d]", err);
- }
-
- EM_DEBUG_LOG("Decoded length = %d", dec_len);
- /* EM_DEBUG_LOG("start - %s", start); */ /* print raw MIME content. */
- }
- else
- memcpy(text_plain, start, end-txt_plain);
-
- /* EM_DEBUG_LOG(" Content-type: text/plain [%s]\n", text_plain); */
- }
- }
- else
- EM_DEBUG_EXCEPTION(" Invalid text body content ");
-
- EM_DEBUG_FUNC_END();
- return 1;
-}
-
-
-
-/* Content-Type: IMAGE/octet-stream; name = Default.png */
-/* Content-Transfer-Encoding: BASE64 */
-/* Content-ID: <4b0d6810b17291f9438783a8eb9d5228@org.tizen.email> */
-/* Content-Disposition: inline; filename = Default.png */
-
-static void emcore_free_email_image_data(email_image_data **image_data, int count)
-{
- EM_DEBUG_FUNC_BEGIN("image_data : [%p], count : [%d]", image_data, count);
-
- if ((image_data == NULL) || (*image_data == NULL) || (count <= 0)) {
- EM_DEBUG_EXCEPTION("Invalid paramter");
- return;
- }
-
- email_image_data *p = *image_data;
- int i = 0;
-
- for (i = 0; i < count; i++) {
- EM_SAFE_FREE(p[i].image_file_name);
- EM_SAFE_FREE(p[i].text_image);
- EM_SAFE_FREE(p[i].content_id);
- EM_SAFE_FREE(p[i].mime_type);
- }
-
- EM_SAFE_FREE(p);
- *image_data = NULL;
-
- EM_DEBUG_FUNC_END();
-}
-
-static int emcore_parse_image_part_for_partial_body(char *header_start_string, char *start_header, char *boundary_string, char *bufsendforparse, email_image_data *image_data, int body_size)
-{
- EM_DEBUG_FUNC_BEGIN("boundary_string : [%s]", boundary_string);
-
- int err = EMAIL_ERROR_NONE;
- char *multiple_image = NULL;
- int donot_parse_next_image = 0;
- char *image_boundary = NULL;
- char *image_boundary_end = NULL;
- char *temp_image_boundary = NULL;
- int i = 0, ch_image = 0;
- int enc_type = ENCOTHER;
- char *p = header_start_string;
- char *start = NULL, *end = NULL, *txt_image = NULL;
- char *temp_image = NULL;
- char *temp_cid1 = NULL;
- char *cid_end = NULL;
- char *temp_enc1 = NULL;
- char *p_boundary_string = NULL;
-
- if(image_data == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- return false;
- }
-
- image_boundary = start_header;
- image_boundary_end = image_boundary - 2;
- image_boundary = image_boundary - 2;
-
- EM_DEBUG_LOG("Content-type: image");
-
- while (bufsendforparse < image_boundary && image_boundary && *image_boundary != LF)
- image_boundary--;
-
- image_boundary++;
-
- temp_image_boundary = em_malloc((image_boundary_end - image_boundary) + 1);
- if (temp_image_boundary == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- return false;
- }
-
- if (image_boundary != NULL && image_boundary_end != NULL)
- memcpy(temp_image_boundary, image_boundary, image_boundary_end-image_boundary);
-
-
- if (((char *)strcasestr((const char *)temp_image_boundary, "Content-type:") == NULL) && (temp_image_boundary[0] == '-'))
- p_boundary_string = strdup(temp_image_boundary);
- else
- p_boundary_string = EM_SAFE_STRDUP(boundary_string);
-
- EM_SAFE_FREE(temp_image_boundary);
-
- do {
- if (multiple_image != NULL){
- p = multiple_image;
- start_header = multiple_image;
- }
-
- emcore_get_content_type_from_mime_string(start_header, &(image_data[i].mime_type));
- EM_DEBUG_LOG("image_data[i].mime_type : [%s]", image_data[i].mime_type);
-
- if ((strcasestr(p, "Content-Disposition: attachment")) || (!strcasestr(p, "Content-ID: <"))) {
- EM_DEBUG_LOG("Body has attachment no need to parse ");
- end = NULL;
- multiple_image = NULL;
- }
- else { /* HTML Content found */
- ch_image = 0;
- char *cid = NULL;
- char *temp_name = NULL;
- char *decoded_filename = NULL;
-
- image_data[i].image_file_name = NULL;
-
- if(!start_header) { /*prevent 27449*/
- EM_DEBUG_EXCEPTION("start_header NULL");
- EM_SAFE_FREE(p_boundary_string);
- return false;
- }
-
- txt_image = start_header;
- temp_image = start_header;
-
- temp_name = strstr(txt_image, "name=");
- if (temp_name != NULL){
- temp_image = temp_name;
- if (*(temp_image + 5) == '"') {
- temp_image = temp_image + 6;
- temp_name = temp_name + 6 ;
- } else {
- temp_image = temp_image + 5;
- temp_name = temp_name + 5;
- }
-
- while (*temp_image != CR){
- temp_image++;
- ch_image++;
- }
-
- if (ch_image > 0) {
- image_data[i].image_file_name = em_malloc(ch_image+3);
- if (image_data[i].image_file_name == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- EM_SAFE_FREE(p_boundary_string);
- return false;
- }
- if (*(temp_image - 1) == '"') {
- memcpy(image_data[i].image_file_name, temp_name, ch_image - 2);
- } else {
- memcpy(image_data[i].image_file_name, temp_name, ch_image);
- }
- }
-
- decoded_filename = emcore_decode_rfc2047_text(image_data[i].image_file_name, &err);
- if(decoded_filename) {
- memset(image_data[i].image_file_name, 0, ch_image);
- memcpy(image_data[i].image_file_name, decoded_filename, EM_SAFE_STRLEN(decoded_filename));
- EM_SAFE_FREE(decoded_filename);
- }
- }
-
- if (((temp_cid1 = (char *)strcasestr((const char *)start_header, "Content-ID: <")) != NULL)){
- if (temp_cid1) {
- cid = temp_cid1;
- temp_image = temp_cid1;
- }
-
- cid += 13;
- cid_end = strstr(temp_image, "\076"); /* 076 == '>' */
-
- image_data[i].content_id = (char *)em_malloc(cid_end-cid+5);
- if (image_data[i].content_id != NULL){
- strcpy(image_data[i].content_id, "cid:");
- memcpy(image_data[i].content_id+4, cid, cid_end-cid);
- }
- else
- EM_DEBUG_EXCEPTION("em_malloc() failed");
-
- if (image_data[i].image_file_name == NULL) {
- image_data[i].image_file_name = em_malloc((cid_end - cid) + 1);
- if (image_data[i].image_file_name == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- EM_SAFE_FREE(p_boundary_string);
- return false;
- }
- memcpy(image_data[i].image_file_name, cid, cid_end - cid);
- }
- }
-
- txt_image = strstr(txt_image, CRLF_STRING CRLF_STRING);
-
- if (txt_image != NULL){
- txt_image += 4; /* txt_image points at image content */
- start = txt_image;
-
- if (p_boundary_string)
- end = strstr(txt_image, p_boundary_string);
-
- if (end == NULL){
- EM_DEBUG_LOG("HTML body contents exceeds limited Bytes");
- /* end points to end of partial body data */
- end = txt_image + body_size - (txt_image-bufsendforparse);
- }
- else{
- EM_DEBUG_LOG("This image is fully downloaded");
- end -= 2;
- image_data[i].fully_downloaded = 1;
- }
-
- if ((temp_enc1 = (char *)strcasestr((const char *)start_header, "Content-transfer-encoding:")) != NULL){ /*prevent 27449*/
- if (temp_enc1)
- start_header = temp_enc1;
-
- start_header += strlen(CONTENT_TRANSFER_ENCODING_STRING);
- start_header = em_skip_whitespace_without_strdup(start_header);
-
- if (!start_header)
- EM_DEBUG_EXCEPTION(" Invalid parsing ");
- else{
- enc_type = ENCOTHER;
- if (strncasecmp(start_header, "base64", strlen("base64")) == 0)
- enc_type = ENCBASE64;
- else if (strncasecmp(start_header, "quoted-printable", strlen("quoted-printable")) == 0)
- enc_type = ENCQUOTEDPRINTABLE;
-
- EM_DEBUG_LOG("enc_type [%d]", enc_type);
-
- image_data[i].text_image = (char *)em_malloc((end-txt_image)+1);
- if (image_data[i].text_image){
- memcpy(image_data[i].text_image, start, end-txt_image);
- if (emcore_decode_body_text(image_data[i].text_image, end-txt_image, enc_type , &(image_data[i].dec_len), &err) < 0)
- EM_DEBUG_EXCEPTION("emcore_decode_body_text failed [%d]", err);
- }
- else
- EM_DEBUG_EXCEPTION("em_malloc() failed");
- }
-
- EM_DEBUG_LOG("Decoded length [%d]", image_data[i].dec_len);
- }
- else{
- image_data[i].text_image = (char *)em_malloc(end-txt_image);
- if (image_data[i].text_image)
- memcpy(image_data[i].text_image, start, end - txt_image);
- else
- EM_DEBUG_EXCEPTION("em_malloc() failed");
- }
- }
- else{
- donot_parse_next_image = 1;
- EM_DEBUG_EXCEPTION(" Invalid html body content ");
- }
- }
-
- if (end != NULL) {
- multiple_image = (char *)strcasestr((const char *)end, "Content-type: image");
- i++;
- }
- } while (multiple_image != NULL && donot_parse_next_image != 1 && (i < IMAGE_DISPLAY_PARTIAL_BODY_COUNT));
-
- EM_SAFE_FREE(p_boundary_string);
-
- EM_DEBUG_FUNC_END();
- return 1;
-}
-
-static int emcore_find_boundary_string_of_the_part(const char *whole_string, const char *first_line_of_part, char **result_boundary_string, int *error)
-{
- EM_DEBUG_FUNC_BEGIN("whole_string[%p], first_line_of_part[%p], result_boundary_string[%p]", whole_string, first_line_of_part, result_boundary_string);
- int ret = false, err = EMAIL_ERROR_NONE;
- char *boundary_cur = NULL, *boundary_end = NULL, *boundary_string = NULL;
-
- if(!whole_string || !first_line_of_part || !result_boundary_string) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- if(first_line_of_part - 2 > whole_string) {
- boundary_cur = (char*)first_line_of_part - 2; /* 2 means CRLF. */
- boundary_end = boundary_cur;
-
- do{
- boundary_cur--;
- } while (whole_string <= boundary_cur && *boundary_cur != LF && *boundary_cur != NULL_CHAR);
-
- boundary_cur++;
-
- if(boundary_end > boundary_cur && boundary_cur >= whole_string) {
-
- boundary_string = em_malloc(boundary_end - boundary_cur + 15);
- if(!boundary_string) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- memcpy(boundary_string, boundary_cur, boundary_end - boundary_cur);
- EM_DEBUG_LOG("boundary_string [%s]", boundary_string);
- *result_boundary_string = boundary_string;
- }
- else {
- EM_DEBUG_EXCEPTION("There is no string before the part");
- err = EMAIL_ERROR_ON_PARSING;
- goto FINISH_OFF;
- }
- }
- else {
- EM_DEBUG_EXCEPTION("There is no string before the part");
- err = EMAIL_ERROR_ON_PARSING;
- goto FINISH_OFF;
- }
- ret = true;
-FINISH_OFF:
-
- if(error)
- *error = err;
-
- EM_DEBUG_FUNC_END("ret[%d], err[%d]", ret, err);
- return ret;
-}
-
-static int emcore_parse_body_for_imap(char *body_str, int body_size, struct _m_content_info *cnt_info, int encoding_type, char **output_text_plain, char **output_text_html, email_image_data **output_image_data)
-{
- EM_DEBUG_FUNC_BEGIN("body_str:[%p], cnt_info:[%p], encoding_type:[%d]", body_str, cnt_info, encoding_type);
- int err = EMAIL_ERROR_NONE;
-
- if (!body_str || strlen(body_str) == 0 || !cnt_info) {
- EM_DEBUG_EXCEPTION("Invalid paramter");
- err = EMAIL_ERROR_INVALID_PARAM;
- return err;
- }
-
- if (!output_text_plain || !output_text_html || !output_image_data) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
- err = EMAIL_ERROR_INVALID_PARAM;
- return err;
- }
-
- int dec_len = 0;
- int no_alternative_part_flag = 0;
- int no_html = 0;
- char *boundary_start = NULL;
- char *boundary_end = NULL;
- char *boundary_string = NULL;
- char *p_body_str = NULL;
- char *start_header = NULL;
- char *text_plain = NULL;
- char *text_html = NULL;
- email_image_data *image_data = NULL;
-
- char *temp_alternative_plain_header = NULL;
- char *temp_content_type = NULL;
-
- char *local_encoding_str = NULL;
- char *local_boundary_str = NULL;
- char *local_body_str = NULL;
-
- p_body_str = g_strdup(body_str);
-
- text_plain = em_malloc(body_size + 1);
- text_html = em_malloc(body_size + 1);
-
- if (!text_plain || !text_html) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- if ((cnt_info->text.plain && cnt_info->text.html) || cnt_info->file) {
- /* Start multipart parsing */
- /* Partial body has headers with Content-Type: text/html or Content-Type: text/plain */
- no_alternative_part_flag = 0;
- if (((temp_alternative_plain_header = (char *)strcasestr(p_body_str, "Content-type: multipart/alternative")) != NULL)) { /* Found 'alternative' */
- if (((temp_content_type = (char *)strcasestr(p_body_str, "Content-type: text/plain")) != NULL)) {
- if (temp_content_type < temp_alternative_plain_header) {
- /* This part is text/plain not alternative. */
- no_html = 1;
- no_alternative_part_flag = 1;
- } else {
- EM_DEBUG_LOG(" Content-type: multipart/alternative ");
- boundary_start = strstr(temp_alternative_plain_header, "--");
- if(!boundary_start) { /*prevent 37946 */
- err = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- boundary_end = strcasestr(boundary_start, "Content-type:");
- if(!boundary_end) { /*prevent 37946 */
- err = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
-
- boundary_string = em_malloc(boundary_end - (boundary_start + strlen("--")));
- if (boundary_string == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- memcpy(boundary_string, boundary_start, boundary_end - (boundary_start + strlen("--")));
- }
- }
- } else
- no_alternative_part_flag = 1;
-
- if (no_alternative_part_flag) {
- boundary_start = strstr(p_body_str, "--");
- if(!boundary_start) { /*prevent 37946 */
- err = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
- boundary_end = strcasestr(boundary_start, "\r\n");
- if(!boundary_end) { /*prevent 37946 */
- err = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
-
- boundary_string = em_malloc(boundary_end - (boundary_start + strlen("--")));
- if (boundary_string == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- memcpy(boundary_string, boundary_start, boundary_end - (boundary_start + strlen("--")));
- }
-
- if (boundary_string && boundary_end) { /*prevent 37946 */
- /* EM_DEBUG_LOG("boundary_string : [%s]", boundary_string); */
-
- if (((start_header = (char *)strcasestr(boundary_end, "Content-Type: text/html")) != NULL) && (no_html != 1) &&(((char *)strcasestr(boundary_end, "Content-Type: message/rfc822")) == NULL) &&
- (((char *)strcasestr(boundary_end, "Content-Type: text/rfc822-headers")) == NULL))
- emcore_parse_html_part_for_partial_body(start_header, boundary_string, p_body_str, text_html, body_size);
-
- if (((start_header = (char *)strcasestr(boundary_end, "Content-Type: text/plain")) != NULL)) {
- char *internal_boundary_string = NULL;
-
- if(!emcore_find_boundary_string_of_the_part(p_body_str, start_header, &internal_boundary_string, &err)) {
- EM_DEBUG_EXCEPTION("internal_boundary_string failed [%d]", err);
- }
-
- if(!internal_boundary_string)
- internal_boundary_string = EM_SAFE_STRDUP(boundary_string);
-
- emcore_parse_plain_part_for_partial_body(boundary_end, start_header, internal_boundary_string, p_body_str, text_plain, body_size);
- EM_SAFE_FREE(internal_boundary_string);
- }
-
- if (((start_header = (char *)strcasestr((const char *)boundary_end, "Content-type: image/jpeg")) != (char *)NULL) ||
- ((start_header = (char *)strcasestr((const char *)boundary_end, "Content-Type: image/jpg")) != (char *)NULL) ||
- ((start_header = (char *)strcasestr((const char *)boundary_end, "Content-Type: image/gif")) != (char *)NULL) ||
- ((start_header = (char *)strcasestr((const char *)boundary_end, "Content-Type: image/bmp")) != (char *)NULL) ||
- ((start_header = (char *)strcasestr((const char *)boundary_end, "Content-Type: image/png")) != (char *)NULL)) {
- image_data = em_malloc(sizeof(email_image_data) * IMAGE_DISPLAY_PARTIAL_BODY_COUNT);
- if (image_data == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
- emcore_parse_image_part_for_partial_body(boundary_end, start_header, boundary_string, p_body_str, image_data, body_size);
- }
- }
- }
- else {
- /* Encoded Content-Type: text/html or Content-Type: text/plain */
- /* No Partial body has No headers with Content-Type: text/html or Content-Type: text/plain */
- char *start_of_body = NULL;
- char *end_of_body = NULL;
- char *local_encoding = NULL;
- char *local_encoding_end = NULL;
- char *local_boundary_end = NULL;
- int local_encoding_len = 0;
- int local_boundary_len = 0;
- int enc_type = encoding_type;
- EM_DEBUG_LOG_DEV("mbody->encoding [%d] ", enc_type);
-
- if (EM_SAFE_STRLEN(p_body_str) > 2 && p_body_str[0] == '-' && p_body_str[1] == '-') {
-
- local_boundary_end = strstr(p_body_str, "\r\n");
- if (local_boundary_end) {
- local_boundary_len = local_boundary_end - p_body_str;
- local_boundary_str = em_malloc(local_boundary_len + 2);
- memcpy(local_boundary_str, p_body_str+2, local_boundary_len-2);
- EM_DEBUG_LOG_DEV("local_boundary_str : %s", local_boundary_str);
- end_of_body = strstr(local_boundary_end, local_boundary_str);
- if (end_of_body) end_of_body -= 2;
- }
-
- local_encoding = strcasestr(p_body_str, "Content-Transfer-Encoding: ");
- if (local_encoding) {
- local_encoding_end = strstr(local_encoding, "\r\n");
-
- if (local_encoding && (local_encoding_end > local_encoding)) {
- local_encoding_len = local_encoding_end - local_encoding;
- local_encoding_str = em_malloc(local_encoding_len + 2);
- if (local_encoding_str == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- if (local_encoding_str) {
- memcpy(local_encoding_str, local_encoding + EM_SAFE_STRLEN("Content-Transfer-Encoding: "), local_encoding_len);
-
- enc_type = ENCOTHER;
- if (strncasecmp(local_encoding_str, "base64", strlen("base64")) == 0)
- enc_type = ENCBASE64;
- else if (strncasecmp(local_encoding_str, "quoted-printable", strlen("quoted-printable")) == 0)
- enc_type = ENCQUOTEDPRINTABLE;
-
- EM_DEBUG_LOG_DEV("local enc_type [%d]", enc_type);
- }
- }
- }
-
- start_of_body = strstr(p_body_str, "\r\n\r\n");
- if (start_of_body) {
- start_of_body = start_of_body+strlen("\r\n\r\n");
- if (end_of_body && (end_of_body > start_of_body)) {
- local_body_str = em_malloc(end_of_body - start_of_body + 2);
- memcpy(local_body_str, start_of_body, end_of_body - start_of_body);
- } else {
- local_body_str = EM_SAFE_STRDUP(start_of_body);
- }
- }
- }
-
- if (!local_body_str)
- local_body_str = g_strdup(p_body_str);
-
- if (emcore_decode_body_text(local_body_str, EM_SAFE_STRLEN(local_body_str), enc_type, &dec_len, &err) < 0) {
- EM_DEBUG_EXCEPTION("emcore_decode_body_text failed [%d]", err);
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG("Decoded length [%d]", dec_len);
-
- if (dec_len > 0) {
- if (cnt_info->text.plain) {
- memcpy(text_plain, local_body_str, dec_len);
- }
-
- if (cnt_info->text.html) {
- memcpy(text_html, local_body_str, dec_len);
- }
- }
- }
-
-FINISH_OFF:
-
- EM_SAFE_FREE(p_body_str);
- EM_SAFE_FREE(boundary_string);
- EM_SAFE_FREE(local_boundary_str);
- EM_SAFE_FREE(local_encoding_str);
- EM_SAFE_FREE(local_body_str);
-
- if (err != EMAIL_ERROR_NONE) {
- EM_SAFE_FREE(text_plain);
- EM_SAFE_FREE(text_html);
-
- if (image_data)
- emcore_free_email_image_data(&image_data, IMAGE_DISPLAY_PARTIAL_BODY_COUNT);
- } else {
- *output_text_plain = text_plain;
- *output_text_html = text_html;
- *output_image_data = image_data;
- }
-
- EM_DEBUG_FUNC_END("err : [%d]", err);
- return err;
-}
-
#define TAG_LENGTH 16
#define COMMAND_LENGTH 2000
static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int input_download_size, email_event_partial_body_thd *pbd_event, int item_count, int *error)
@@ -4448,7 +3731,8 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
int total_mail_size = 0, total_attachment_size = 0;
int temp_count = 0, attachment_num = 0, inline_attachment_num = 0;
int inline_download_count = 0;
- char buf[512] = {0, };
+ char path_buf[512] = {0,};
+ char move_buf[512] = {0,};
char uid_range_string_to_be_downloaded[UID_RANGE_STRING_LENGTH] = {0,};
char imap_tag[TAG_LENGTH] = {0, };
char command[COMMAND_LENGTH] = {0, };
@@ -4459,6 +3743,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
IMAPLOCAL *imaplocal = NULL;
IMAPPARSEDREPLY *reply_from_server = NULL;
emstorage_mail_tbl_t *mail = NULL;
+ emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
email_partial_buffer *imap_response = NULL;
BODY *body = NULL;
struct _m_content_info *cnt_info = NULL;
@@ -4555,12 +3840,22 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
/* Check the body download status and body size */
SNPRINTF(uid_string, sizeof(uid_string), "%ld", imap_response[i].uid_no);
- if (!emstorage_get_maildata_by_servermailid(pbd_event[temp_count].mailbox_id, uid_string, &mail, true, &err) || !mail) {
+ if (!emstorage_get_maildata_by_servermailid(pbd_event[temp_count].multi_user_name,
+ uid_string,
+ pbd_event[temp_count].mailbox_id,
+ &mail,
+ false,
+ &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_data_by_servermailid failed : [%d]", err);
if (err == EMAIL_ERROR_MAIL_NOT_FOUND || !mail)
goto FINISH_OFF;
}
+ if (mailbox_tbl) {
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+ mailbox_tbl = NULL;
+ }
+
if (mail->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) {
EM_DEBUG_LOG("Downloaded mail");
continue;
@@ -4617,6 +3912,11 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
message1 = g_mime_parser_construct_message(parser1);
if (parser1) g_object_unref(parser1);
+ if (message1 == NULL) {
+ EM_DEBUG_LOG("message1 is NULL");
+ continue;
+ }
+
/* message1 is multipart? */
if (GMIME_IS_MULTIPART (message1->mime_part)) {
@@ -4726,6 +4026,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
message2 = NULL;
}
+
if (g_strrstr(g_mime_message_get_sender(message1), "mmsc.plusnet.pl") != NULL ||
g_strrstr(g_mime_message_get_sender(message1), "mms.t-mobile.pl") != NULL) {
cnt_info->attachment_only = 1;
@@ -4733,6 +4034,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
g_mime_message_foreach(message1, emcore_gmime_imap_parse_foreach_cb, (gpointer)cnt_info);
+
} else if (GMIME_IS_PART (message1->mime_part)) {
GMimeDataWrapper *content = NULL;
GMimePart *single_part = GMIME_PART(message1->mime_part);
@@ -4761,7 +4063,12 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
}
if (!strcasecmp(body->subtype, "pkcs7-mime")) {
- if (emcore_get_attribute_value_of_body_part(body->parameter, "PROTOCOL", rfc822_protocol, TEMP_STRING_LENGTH, false, &err)) {
+ if (emcore_get_attribute_value_of_body_part(body->parameter,
+ "PROTOCOL",
+ rfc822_protocol,
+ TEMP_STRING_LENGTH,
+ false,
+ &err)) {
if (strcasestr(rfc822_protocol, "enveloped-data"))
mail->smime_type = EMAIL_SMIME_ENCRYPTED;
else
@@ -4770,11 +4077,21 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
} else if (!strcasecmp(body->subtype, "encrypted")) {
mail->smime_type = EMAIL_PGP_ENCRYPTED;
} else if (!strcasecmp(body->subtype, "signed")) {
- if (emcore_get_attribute_value_of_body_part(body->parameter, "MICALG", rfc822_micalg, TEMP_STRING_LENGTH, false, &err)) {
+ if (emcore_get_attribute_value_of_body_part(body->parameter,
+ "MICALG",
+ rfc822_micalg,
+ TEMP_STRING_LENGTH,
+ false,
+ &err)) {
mail->digest_type = emcore_get_digest_type(rfc822_micalg);
}
- if (emcore_get_attribute_value_of_body_part(body->parameter, "PROTOCOL", rfc822_protocol, TEMP_STRING_LENGTH, false, &err)) {
+ if (emcore_get_attribute_value_of_body_part(body->parameter,
+ "PROTOCOL",
+ rfc822_protocol,
+ TEMP_STRING_LENGTH,
+ false,
+ &err)) {
if (strcasestr(rfc822_protocol, "pkcs7-signature"))
mail->smime_type = EMAIL_SMIME_SIGNED;
else
@@ -4795,9 +4112,14 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
}
/* Update the attachment info except inline attachment */
- if ((err = emcore_update_attachment_except_inline(cnt_info, pbd_event[temp_count].account_id,
- mail->mail_id, pbd_event[temp_count].mailbox_id, &total_attachment_size,
- &attachment_num, &inline_attachment_num)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_update_attachment_except_inline(pbd_event[temp_count].multi_user_name,
+ cnt_info,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ pbd_event[temp_count].mailbox_id,
+ &total_attachment_size,
+ &attachment_num,
+ &inline_attachment_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_update_attachment_except_inline failed : [%d]", err);
goto FINISH_OFF;
}
@@ -4814,7 +4136,8 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
/* text/plain */
if (cnt_info->text.plain) {
char *charset_plain_text = NULL;
- memset(buf, 0x00, sizeof(buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(move_buf, 0x00, sizeof(move_buf));
if (cnt_info->text.plain_charset)
charset_plain_text = cnt_info->text.plain_charset;
@@ -4826,25 +4149,38 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
}
}
- if (!emstorage_create_dir(pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
+ if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ &err))
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- if (!emstorage_get_save_name(pbd_event[temp_count].account_id, mail->mail_id, 0, charset_plain_text, buf, sizeof(buf), &err))
+ if (!emstorage_get_save_name(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ charset_plain_text,
+ move_buf,
+ path_buf,
+ sizeof(path_buf),
+ &err))
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- if (!emstorage_move_file(cnt_info->text.plain, buf, false, &err)) {
+ if (!emstorage_move_file(cnt_info->text.plain, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
mail->file_path_plain = NULL;
}
else
- mail->file_path_plain = EM_SAFE_STRDUP(buf);
+ mail->file_path_plain = EM_SAFE_STRDUP(path_buf);
EM_DEBUG_LOG_SEC("mail->file_path_plain [%s]", mail->file_path_plain);
}
/* text/html */
if (cnt_info->text.html) {
char *charset_html_text = NULL;
- memset(buf, 0x00, sizeof(buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(move_buf, 0x00, sizeof(move_buf));
if (cnt_info->text.html_charset)
charset_html_text = cnt_info->text.html_charset;
@@ -4858,21 +4194,64 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
charset_html_text = g_strconcat(charset_html_text, HTML_EXTENSION_STRING, NULL);
- if (!emstorage_create_dir(pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
+ if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ &err))
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- if (!emstorage_get_save_name(pbd_event[temp_count].account_id, mail->mail_id, 0, charset_html_text, buf, sizeof(buf), &err))
+ if (!emstorage_get_save_name(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ charset_html_text,
+ move_buf,
+ path_buf,
+ sizeof(path_buf),
+ &err))
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- if (!emstorage_move_file(cnt_info->text.html, buf, false, &err)) {
+ if (!emstorage_move_file(cnt_info->text.html, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
mail->file_path_html = NULL;
}
else
- mail->file_path_html = EM_SAFE_STRDUP(buf);
+ mail->file_path_html = EM_SAFE_STRDUP(path_buf);
g_free(charset_html_text);
}
+ /* mime_entity */
+ if (cnt_info->text.mime_entity) {
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(move_buf, 0x00, sizeof(move_buf));
+
+ if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ &err))
+ EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
+
+ if (!emstorage_get_save_name(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ "mime_entity",
+ move_buf,
+ path_buf,
+ sizeof(path_buf),
+ &err))
+ EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
+
+ if (!emstorage_move_file(cnt_info->text.mime_entity, move_buf, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
+ mail->file_path_mime_entity = NULL;
+ }
+
+ mail->file_path_mime_entity = EM_SAFE_STRDUP(path_buf);
+ }
+
/* inline attachment */
inline_download_count = 0;
if (cnt_info->inline_file) {
@@ -4883,15 +4262,28 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
while (temp_file) {
if (temp_file->type == INLINE_ATTACHMENT && temp_file->save_status == 1) {
inline_download_count++;
- memset(buf, 0x00, sizeof(buf));
-
- if (!emstorage_create_dir(pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(move_buf, 0x00, sizeof(move_buf));
+
+ if (!emstorage_create_dir(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ &err))
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- if (!emstorage_get_save_name(pbd_event[temp_count].account_id, mail->mail_id, 0, temp_file->name, buf, sizeof(buf), &err))
+ if (!emstorage_get_save_name(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ mail->mail_id,
+ 0,
+ temp_file->name,
+ move_buf,
+ path_buf,
+ sizeof(path_buf),
+ &err))
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- if (!emstorage_move_file(temp_file->save, buf, false, &err)) {
+ if (!emstorage_move_file(temp_file->save, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
@@ -4903,13 +4295,18 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
attachment_tbl.mailbox_id = pbd_event[temp_count].mailbox_id;
attachment_tbl.attachment_name = temp_file->name;
attachment_tbl.attachment_size = temp_file->size;
- attachment_tbl.attachment_path = buf;
+ attachment_tbl.attachment_path = path_buf;
attachment_tbl.attachment_save_status = 1;
attachment_tbl.attachment_inline_content_status = 1; /* set to 1 for inline image */
attachment_tbl.attachment_mime_type = temp_file->attachment_mime_type;
attachment_tbl.content_id = temp_file->content_id;
EM_DEBUG_LOG("mime_type : [%s]", temp_file->attachment_mime_type);
- if (!emstorage_add_attachment(&attachment_tbl, false, false, &err))
+
+ if (!emstorage_add_attachment(pbd_event[temp_count].multi_user_name,
+ &attachment_tbl,
+ false,
+ false,
+ &err))
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed - %d", err);
}
}
@@ -4922,20 +4319,33 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
}
}
- mail->body_download_status = (mail->body_download_status & ~0x00000003) | (( (total_mail_size - total_attachment_size <= input_download_size) && (inline_download_count == inline_attachment_num))?
- EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED: EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED);
+ mail->body_download_status = (mail->body_download_status & ~0x00000003) |
+ (((total_mail_size - total_attachment_size <= input_download_size) &&
+ (inline_download_count == inline_attachment_num)) ?
+ EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED :
+ EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED);
- EM_DEBUG_LOG("inline_download_count[%d] inline_attachment_num[%d]", inline_download_count, inline_attachment_num);
- EM_DEBUG_LOG("total_mail_size[%d] total_attachment_size[%d] input_download_size[%d]", total_mail_size, total_attachment_size, input_download_size);
+ EM_DEBUG_LOG("inline_download_count[%d] inline_attachment_num[%d]",
+ inline_download_count, inline_attachment_num);
+ EM_DEBUG_LOG("total_mail_size[%d] total_attachment_size[%d] input_download_size[%d]",
+ total_mail_size, total_attachment_size, input_download_size);
EM_DEBUG_LOG("mail_id [%d] body_download_status [%d]", mail->mail_id, mail->body_download_status);
/* Get preview text */
- if ( (err = emcore_get_preview_text_from_file(mail->file_path_plain,
- mail->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &(mail->preview_text))) != EMAIL_ERROR_NONE)
+ if ( (err = emcore_get_preview_text_from_file(pbd_event[temp_count].multi_user_name,
+ mail->file_path_plain,
+ mail->file_path_html,
+ MAX_PREVIEW_TEXT_LENGTH,
+ &(mail->preview_text))) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file() failed[%d]", err);
/* Update body contents */
- if (!emstorage_change_mail_field(mail->mail_id, UPDATE_PARTIAL_BODY_DOWNLOAD, mail, true, &err)) {
+ if (!emstorage_change_mail_field(pbd_event[temp_count].multi_user_name,
+ mail->mail_id,
+ UPDATE_PARTIAL_BODY_DOWNLOAD,
+ mail,
+ true,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed - %d", err);
goto FINISH_OFF;
}
@@ -4943,18 +4353,30 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
#ifdef __FEATURE_BODY_SEARCH__
/* strip html content and save into mail_text_tbl */
char *stripped_text = NULL;
- if (!emcore_strip_mail_body_from_file(mail, &stripped_text, &err) || stripped_text == NULL) {
+ if (!emcore_strip_mail_body_from_file(pbd_event[temp_count].multi_user_name,
+ mail,
+ &stripped_text,
+ &err) || stripped_text == NULL) {
EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
}
- if (!emstorage_get_mail_text_by_id(mail->mail_id, &mail_text, true, &err) || !mail_text) {
+ if (!emstorage_get_mail_text_by_id(pbd_event[temp_count].multi_user_name,
+ mail->mail_id,
+ &mail_text,
+ true,
+ &err) || !mail_text) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_text_by_id failed [%d]", err);
goto FINISH_OFF;
}
EM_SAFE_FREE(mail_text->body_text);
mail_text->body_text = stripped_text;
- if (!emstorage_change_mail_text_field(mail->mail_id, mail_text, false, &err)) {
+
+ if (!emstorage_change_mail_text_field(pbd_event[temp_count].multi_user_name,
+ mail->mail_id,
+ mail_text,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_text_field failed [%d]", err);
goto FINISH_OFF;
}
@@ -4966,7 +4388,11 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
if (mail)
emstorage_free_mail(&mail, 1, NULL);
- if (false == emcore_delete_pbd_activity(pbd_event[temp_count].account_id, pbd_event[temp_count].mail_id, pbd_event[temp_count].activity_id, &err)){
+ if (false == emcore_delete_pbd_activity(pbd_event[temp_count].multi_user_name,
+ pbd_event[temp_count].account_id,
+ pbd_event[temp_count].mail_id,
+ pbd_event[temp_count].activity_id,
+ &err)){
EM_DEBUG_EXCEPTION("emcore_delete_pbd_activity failed [%d]", err);
goto FINISH_OFF;
}
@@ -5023,6 +4449,9 @@ FINISH_OFF:
if (mail)
emstorage_free_mail(&mail, 1, NULL);
+ if (mailbox_tbl)
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+
if (mail_text)
emstorage_free_mail_text(&mail_text, 1, NULL);
@@ -5035,376 +4464,6 @@ FINISH_OFF:
return ret;
}
-static int emcore_download_bulk_partial_mail_body_for_imap(MAILSTREAM *stream, int input_download_size, email_event_partial_body_thd *pbd_event, int item_count, int *error)
-{
- EM_DEBUG_FUNC_BEGIN("stream [%p], input_download_size[%d], pbd_event [%p], item_count [%d], error [%p]", stream, input_download_size, pbd_event, item_count, error);
-
- int ret = false, err = EMAIL_ERROR_NONE;
- int j = 0, i = 0;
- int i32_index = 0;
- int total_mail_size = 0, total_attachment_size = 0;
- int temp_count = 0, attachment_num = 0, inline_attachment_num = 0;
- char buf[512] = {0, };
- char *text_plain = NULL;
- char *text_html = NULL;
- char uid_range_string_to_be_downloaded[UID_RANGE_STRING_LENGTH] = {0, };
- char imap_tag[TAG_LENGTH] = {0, };
- char command[COMMAND_LENGTH] = {0, };
- char *temp_data_html = NULL;
- char uid_string[TEMP_STRING_LENGTH] = {0, };
- IMAPLOCAL *imaplocal = NULL;
- IMAPPARSEDREPLY *reply_from_server = NULL;
- emstorage_mail_tbl_t *mail = NULL;
- email_partial_buffer *imap_response = NULL;
- BODY *body = NULL;
- struct _m_content_info *cnt_info = NULL;
- emstorage_attachment_tbl_t attachment_tbl;
- email_event_partial_body_thd *stSectionNo = NULL;
- email_image_data *image_data = NULL;
-
- if (!(stream) || !(imaplocal = stream->local) || !imaplocal->netstream || !pbd_event) {
- EM_DEBUG_EXCEPTION("invalid parameter");
- err = EMAIL_ERROR_INVALID_PARAM;
- EM_DEBUG_FUNC_END("ret [%d]", ret);
- return ret;
- }
-
- EM_DEBUG_LOG("Start of emcore_get_section_for_partial_download, item_count = %d ", item_count);
-
- /* For constructing UID list which is having 10 UID or less at a time */
- for (j = 0, stSectionNo = pbd_event; (stSectionNo != NULL && j < item_count); j++)
- {
- /* delete log before uploading master branch. it is flooding */
-
- if (i32_index >= UID_RANGE_STRING_LENGTH){
- EM_DEBUG_EXCEPTION("String length exceeded its limitation!");
- goto FINISH_OFF;
- }
-
- if (j == item_count - 1)
- i32_index += SNPRINTF(uid_range_string_to_be_downloaded + i32_index, UID_RANGE_STRING_LENGTH - i32_index, "%lu", stSectionNo[j].server_mail_id);
- else
- i32_index += SNPRINTF(uid_range_string_to_be_downloaded + i32_index, UID_RANGE_STRING_LENGTH - i32_index, "%lu,", stSectionNo[j].server_mail_id);
- }
-
- SNPRINTF(imap_tag, TAG_LENGTH, "%08lx", 0xffffffff & (stream->gensym++));
- SNPRINTF(command, COMMAND_LENGTH, "%s UID FETCH %s (BODYSTRUCTURE BODY.PEEK[TEXT]<0.%d>)\015\012", imap_tag, uid_range_string_to_be_downloaded, input_download_size);
-
- EM_DEBUG_LOG("command : %s", command);
-
- /* Sending out the IMAP request */
- if (!net_sout(imaplocal->netstream, command, (int)EM_SAFE_STRLEN(command))) {
- EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMAIL_ERROR_CONNECTION_BROKEN;
- goto FINISH_OFF;
- }
-
- /* responce from the server */
- imap_response = emcore_get_response_from_server(imaplocal->netstream, imap_tag, &reply_from_server, input_download_size, item_count);
-
- if (!imap_response || !reply_from_server ){
- EM_DEBUG_EXCEPTION(" Invalid response from emcore_get_response_from_server");
- goto FINISH_OFF;
- }
-
- for (i = 0; i < item_count ; i++) {
- total_mail_size = 0;
- total_attachment_size = 0;
- attachment_num = 0;
-
- if( !(imap_response[i].bodystructure) ) continue;
-
- if (body) {
- mail_free_body(&body);
- body = NULL;
- }
-
- if (cnt_info) {
- emcore_free_content_info(cnt_info);
- EM_SAFE_FREE(cnt_info);
- }
-
- err = emcore_parse_bodystructure(stream, reply_from_server, imap_response[i].bodystructure, &body, &cnt_info, &total_mail_size);
- if (err != EMAIL_ERROR_NONE || !body) {
- EM_DEBUG_EXCEPTION("emcore_parse_bodystructure failed : [%d]", err);
- err = EMAIL_ERROR_ON_PARSING;
- goto FINISH_OFF;
- }
-
- /* Search the account id of pbd_event */
- for (temp_count = 0; temp_count <= item_count && pbd_event[temp_count].server_mail_id != imap_response[i].uid_no; temp_count++)
- continue;
-
- if (temp_count > item_count) {
- EM_DEBUG_EXCEPTION("Can't find proper server_mail_id");
- goto FINISH_OFF;
- }
-
- /* Start to parse the body */
- EM_DEBUG_LOG("Start partial body of server_mail_id %d", imap_response[i].uid_no);
-
- /* Check the body download status and body size */
- SNPRINTF(uid_string, sizeof(uid_string), "%ld", imap_response[i].uid_no);
- if (!emstorage_get_maildata_by_servermailid(pbd_event[temp_count].mailbox_id, uid_string, &mail, true, &err) || !mail) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_data_by_servermailid failed : [%d]", err);
- if (err == EMAIL_ERROR_MAIL_NOT_FOUND || !mail)
- goto FINISH_OFF;
- }
-
- if (mail->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) {
- EM_DEBUG_LOG("Downloaded mail");
- continue;
- }
-
- /* Update the attachment info except inline attachment */
- if ((err = emcore_update_attachment_except_inline(cnt_info, pbd_event[temp_count].account_id, mail->mail_id, pbd_event[temp_count].mailbox_id, &total_attachment_size, &attachment_num, &inline_attachment_num)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_update_attachment_except_inline failed : [%d]", err);
- goto FINISH_OFF;
- }
-
-
- mail->mail_size = total_mail_size;
- mail->attachment_count = attachment_num;
- mail->inline_content_count = inline_attachment_num;
-
- if (imap_response[i].bodytext_len == 0) {
- EM_DEBUG_LOG("BODY size is zero");
- continue;
- }
-
- /*free the plain, html, and image_data before reusing*/
- if (image_data)
- emcore_free_email_image_data(&image_data, IMAGE_DISPLAY_PARTIAL_BODY_COUNT);
-
- EM_SAFE_FREE(text_plain);
- EM_SAFE_FREE(text_html);
-
- if ((err = emcore_parse_body_for_imap(imap_response[i].bodytext, imap_response[i].bodytext_len, cnt_info, body->encoding, &text_plain, &text_html, &image_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_parse_body_for_imap failed");
- goto FINISH_OFF;
- }
-
- int text_plain_len = EM_SAFE_STRLEN(text_plain);
- if (text_plain_len > 0) {
- char *charset_plain_text = NULL;
- memset(buf, 0x00, sizeof(buf));
-
- if (cnt_info->text.plain_charset)
- charset_plain_text = cnt_info->text.plain_charset;
- else {
- if (mail->default_charset) {
- charset_plain_text = mail->default_charset;
- } else {
- charset_plain_text = "UTF-8";
- }
- }
-
- if (!emstorage_create_dir(pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
-
- if (!emstorage_get_save_name(pbd_event[temp_count].account_id, mail->mail_id, 0, charset_plain_text, buf, sizeof(buf), &err))
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
-
- if (!emstorage_create_file(text_plain, text_plain_len, buf, &err))
- EM_DEBUG_EXCEPTION("emstorage_create_file failed [%d]", err);
-
- mail->file_path_plain = EM_SAFE_STRDUP(buf);
- EM_DEBUG_LOG_SEC("mail->file_path_plain [%s]", mail->file_path_plain);
- }
-
- if (image_data != NULL && image_data[0].text_image != NULL && image_data[0].text_image[0] != NULL_CHAR) {
- char *result_string_of_replacing = NULL;
- int store_file = 0;
- int content_index = 0;
-
- temp_data_html = em_malloc(imap_response[i].bodytext_len + 1);
- if(!temp_data_html) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- memset(buf, 0x00, sizeof(buf));
- if (text_html != NULL)
- memcpy(temp_data_html, text_html, EM_SAFE_STRLEN(text_html));
- /* EM_SAFE_STRNCPY(temp_data_html, text_html, text_html); */
-
- do {
- if(image_data[store_file].fully_downloaded == 1) {
- if (!emstorage_create_dir(pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
-
- if (!emstorage_get_save_name(pbd_event[temp_count].account_id, mail->mail_id, 0, image_data[store_file].image_file_name, buf, sizeof(buf), &err))
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
-
- if (image_data[store_file].dec_len>0)
- if (!emstorage_create_file(image_data[store_file].text_image, image_data[store_file].dec_len, buf, &err))
- EM_DEBUG_EXCEPTION("emstorage_create_file failed [%d]", err);
-
- if (!(mail->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED)){
- memset(&attachment_tbl, 0x00, sizeof(emstorage_attachment_tbl_t));
- attachment_tbl.mail_id = mail->mail_id;
- attachment_tbl.account_id = pbd_event[temp_count].account_id;
- attachment_tbl.mailbox_id = pbd_event[temp_count].mailbox_id;
- attachment_tbl.attachment_name = image_data[store_file].image_file_name;
- attachment_tbl.attachment_size = image_data[store_file].dec_len;
- attachment_tbl.attachment_path = buf;
- attachment_tbl.attachment_save_status = 1;
- attachment_tbl.attachment_inline_content_status = 1; /* set to 1 for inline image */
- attachment_tbl.attachment_mime_type = image_data[store_file].mime_type;
- attachment_tbl.content_id = image_data[store_file].content_id;
- EM_DEBUG_LOG("mime_type : [%s]", image_data[store_file].mime_type);
- if (!emstorage_add_attachment (&attachment_tbl, false, false, &err))
- EM_DEBUG_EXCEPTION("emstorage_add_attachment failed - %d", err);
- }
- }
-
- store_file++;
- } while (image_data[store_file].text_image != NULL && image_data[store_file].text_image[0] != NULL_CHAR && (store_file < IMAGE_DISPLAY_PARTIAL_BODY_COUNT));
-
- while (image_data[content_index].text_image != NULL && image_data[content_index].text_image[0] != NULL_CHAR &&
- image_data[content_index].content_id && image_data[content_index].content_id[0] != NULL_CHAR && (content_index < IMAGE_DISPLAY_PARTIAL_BODY_COUNT)){
- /* Finding CID in HTML and replacing with image name. */
- if(image_data[content_index].fully_downloaded == 1) {
- result_string_of_replacing = em_replace_string((char *)temp_data_html, (char *)image_data[content_index].content_id, (char *)image_data[content_index].image_file_name);
- if (result_string_of_replacing) {
- memset(temp_data_html, 0x00, imap_response[i].bodytext_len + 1);
- strncpy(temp_data_html, result_string_of_replacing, strlen(result_string_of_replacing));
- EM_SAFE_FREE (result_string_of_replacing);
- }
-
- if (strstr(temp_data_html, image_data[content_index].content_id) != NULL)
- continue; /* Replace content id on HTML with same file name one more time. */
- }
- content_index++;
- }
-
- memset(text_html, 0, imap_response[i].bodytext_len + 1);
-
- if (temp_data_html != NULL)
- memcpy(text_html, temp_data_html, EM_SAFE_STRLEN(temp_data_html));
-
- EM_SAFE_FREE(temp_data_html);
- }
-
- if (EM_SAFE_STRLEN(text_html) > 0) {
- memset(buf, 0x00, sizeof(buf));
- char html_body[MAX_CHARSET_VALUE] = {0x00, };
- if (cnt_info->text.plain_charset != NULL){
- if (EM_SAFE_STRLEN(cnt_info->text.plain_charset) < MAX_CHARSET_VALUE)
- memcpy(html_body, cnt_info->text.plain_charset, EM_SAFE_STRLEN(cnt_info->text.plain_charset));
- else
- memcpy(html_body, "UTF-8", strlen("UTF-8"));
- }
- if (html_body[0] != NULL_CHAR)
- strcat(html_body, HTML_EXTENSION_STRING);
- else
- memcpy(html_body, "UTF-8.htm", strlen("UTF-8.htm"));
-
- if (!emstorage_create_dir(pbd_event[temp_count].account_id, mail->mail_id, 0, &err))
- EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
-
- if (!emstorage_get_save_name(pbd_event[temp_count].account_id, mail->mail_id, 0, html_body, buf, sizeof(buf), &err))
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
-
- int text_html_len = EM_SAFE_STRLEN(text_html);
- if (text_html_len>0)
- if (!emstorage_create_file(text_html, EM_SAFE_STRLEN(text_html), buf, &err))
- EM_DEBUG_EXCEPTION("emstorage_create_file failed [%d]", err);
-
- mail->file_path_html = EM_SAFE_STRDUP(buf);
-
- }
-
- mail->body_download_status = (mail->body_download_status & ~0x00000003) | ((total_mail_size - total_attachment_size < input_download_size) ? 1 : 2);
- EM_DEBUG_LOG("total_mail_size[%d] total_attachment_size[%d] input_download_size[%d]", total_mail_size, total_attachment_size, input_download_size);
- EM_DEBUG_LOG("mail_id [%d] body_download_status [%d]", mail->mail_id, mail->body_download_status);
-
- /* Get preview text */
- if ( (err = emcore_get_preview_text_from_file(mail->file_path_plain, mail->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &(mail->preview_text))) != EMAIL_ERROR_NONE)
- EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file() failed[%d]", err);
-
- /* Update body contents */
- if (!emstorage_change_mail_field(mail->mail_id, UPDATE_PARTIAL_BODY_DOWNLOAD, mail, true, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed - %d", err);
- goto FINISH_OFF;
- }
-
-#ifdef __FEATURE_BODY_SEARCH__
- /* strip html content and save into mail_text_tbl */
- char *stripped_text = NULL;
- if (!emcore_strip_mail_body_from_file(mail, &stripped_text, &err) || stripped_text == NULL) {
- EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
- }
-
- emstorage_mail_text_tbl_t *mail_text;
- if (!emstorage_get_mail_text_by_id(mail->mail_id, &mail_text, true, &err) || !mail_text) {
- EM_DEBUG_EXCEPTION("emstorage_get_mail_text_by_id failed [%d]", err);
- goto FINISH_OFF;
- }
-
- EM_SAFE_FREE(mail_text->body_text);
- mail_text->body_text = stripped_text;
- if (!emstorage_change_mail_text_field(mail->mail_id, mail_text, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_change_mail_text_field failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (mail_text)
- emstorage_free_mail_text(&mail_text, 1, NULL);
-#endif
-
- if (mail)
- emstorage_free_mail(&mail, 1, NULL);
-
- if (false == emcore_delete_pbd_activity(pbd_event[temp_count].account_id, pbd_event[temp_count].mail_id, pbd_event[temp_count].activity_id, &err)){
- EM_DEBUG_EXCEPTION("emcore_delete_pbd_activity failed [%d]", err);
- goto FINISH_OFF;
- }
- }
-
- ret = true;
-
-FINISH_OFF:
-
- if (error)
- *error = err;
-
- if (true != ret)
- EM_DEBUG_EXCEPTION("Failed download for the uid list %s", command);
-
- if(reply_from_server) {
- EM_SAFE_FREE(reply_from_server->key);
- EM_SAFE_FREE(reply_from_server->line);
- EM_SAFE_FREE(reply_from_server->tag);
- EM_SAFE_FREE(reply_from_server->text);
- EM_SAFE_FREE(reply_from_server);
- }
-
- EM_SAFE_FREE(text_plain);
- EM_SAFE_FREE(text_html);
-
- if (image_data)
- emcore_free_email_image_data(&image_data, IMAGE_DISPLAY_PARTIAL_BODY_COUNT);
-
- if (cnt_info) {
- emcore_free_content_info(cnt_info);
- EM_SAFE_FREE(cnt_info);
- }
-
- if (body)
- mail_free_body(&body);
-
- if (mail)
- emstorage_free_mail(&mail, 1, NULL);
-
- if (imap_response)
- emcore_free_email_partial_buffer(&imap_response, item_count);
-
- EM_DEBUG_FUNC_END("ret [%d]", ret);
- return ret;
-}
-
INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_pop3(MAILSTREAM *stream, int input_download_size, email_event_partial_body_thd *pbd_event, int item_count, int *error)
{
EM_DEBUG_FUNC_BEGIN("stream [%p], pbd_event [%p], item_count [%d], error [%p]", stream, pbd_event, item_count, error);
@@ -5421,28 +4480,13 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_pop3(MAILSTREAM *st
EM_DEBUG_LOG_SEC("pbd_event[%d].account_id [%d], mail_id [%d], server_mail_id [%d], activity_id [%d]", \
i, pbd_event[i].account_id, pbd_event[i].mail_id, pbd_event[i].server_mail_id, pbd_event[i].activity_id);
-#ifdef __FEATURE_USE_GMIME__
- if (!emcore_gmime_download_body_sections(stream, pbd_event[i].account_id,
+ if (!emcore_gmime_download_body_sections(pbd_event[i].multi_user_name, stream, pbd_event[i].account_id,
pbd_event[i].mail_id, 0, input_download_size, -1, 0, 0, &err)) {
EM_DEBUG_EXCEPTION("emcore_gmime_download_body_sections failed - %d", err);
goto FINISH_OFF;
}
-#else
- if (!emcore_download_body_multi_sections_bulk (stream,
- pbd_event[i].account_id,
- pbd_event[i].mail_id,
- false,
- false,
- input_download_size,
- -1,
- 0,
- &err)) {
- EM_DEBUG_EXCEPTION("emcore_download_body_multi_sections_bulk failed");
- goto FINISH_OFF;
- }
-#endif
- if (false == emcore_delete_pbd_activity(pbd_event[i].account_id, pbd_event[i].mail_id, pbd_event[i].activity_id, &err)){
+ if (false == emcore_delete_pbd_activity(pbd_event[i].multi_user_name, pbd_event[i].account_id, pbd_event[i].mail_id, pbd_event[i].activity_id, &err)){
EM_DEBUG_EXCEPTION("emcore_delete_pbd_activity failed [%d]", err);
goto FINISH_OFF;
}
@@ -5458,8 +4502,6 @@ FINISH_OFF:
return ret;
}
-
-
INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, email_event_partial_body_thd *pbd_event, int item_count, int *error)
{
EM_DEBUG_FUNC_BEGIN("stream [%p], pbd_event [%p], item_count [%d], error [%p]", stream, pbd_event, item_count, error);
@@ -5473,20 +4515,16 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, ema
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(pbd_event[0].account_id, EMAIL_ACC_GET_OPT_DEFAULT, &pbd_account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(pbd_event[0].multi_user_name, pbd_event[0].account_id, EMAIL_ACC_GET_OPT_DEFAULT, &pbd_account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
- auto_download_size = (pbd_account_tbl->auto_download_size<4096)?4096:pbd_account_tbl->auto_download_size;
+ auto_download_size = (pbd_account_tbl->auto_download_size < 4096) ? 4096 : pbd_account_tbl->auto_download_size;
switch (pbd_account_tbl->incoming_server_type){
case EMAIL_SERVER_TYPE_IMAP4:
-#ifdef __FEATURE_USE_GMIME__
ret = emcore_gmime_download_imap_partial_mail_body(stream, auto_download_size, pbd_event, item_count, &err);
-#else
- ret = emcore_download_bulk_partial_mail_body_for_imap(stream, auto_download_size, pbd_event, item_count, &err);
-#endif
break;
case EMAIL_SERVER_TYPE_POP3:
@@ -5581,7 +4619,7 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
EM_SAFE_FREE(cur_line);
EM_SAFE_FREE(tmp);
- p_rfc822header = strcasestr(full_line, "RFC822.HEADER {");
+ if (full_line) p_rfc822header = strcasestr(full_line, "RFC822.HEADER {");
if (p_rfc822header && server_response[count].rfc822header == NULL) {
p_rfc822header += strlen("RFC822.HEADER {");
rfc822header_size = atoi(p_rfc822header);
@@ -5593,7 +4631,8 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
goto FINISH_OFF;
}
- if (net_getbuffer(nstream, server_response[count].rfc822header_len, server_response[count].rfc822header) <= 0) {
+ if (net_getbuffer(nstream, server_response[count].rfc822header_len,
+ server_response[count].rfc822header) <= 0) {
EM_DEBUG_EXCEPTION("net_getbuffer failed");
goto FINISH_OFF;
}
@@ -5602,8 +4641,8 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
continue;
}
- p_bodystructure = strcasestr(full_line, "BODYSTRUCTURE");
- p_bodystructure_end = strcasestr(full_line, "BODY[TEXT]");
+ if (full_line) p_bodystructure = strcasestr(full_line, "BODYSTRUCTURE");
+ if (full_line) p_bodystructure_end = strcasestr(full_line, "BODY[TEXT]");
/* check whether full header is received */
if (p_bodystructure && p_bodystructure_end) {
diff --git a/email-core/email-core-mailbox.c b/email-core/email-core-mailbox.c
index baccd2f..3c9b5ab 100755
--- a/email-core/email-core-mailbox.c
+++ b/email-core/email-core-mailbox.c
@@ -189,7 +189,7 @@ INTERNAL_FUNC void emcore_close_recv_stream_list (void)
EM_DEBUG_FUNC_END();
}
-INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (int account_id, int mailbox_id, int *error)
+INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (char *multi_user_name, int account_id, int mailbox_id, int *error)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
GList* cur = g_recv_stream_list;
@@ -198,7 +198,7 @@ INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (int account_id, int mailbox_i
int err = EMAIL_ERROR_NONE;
email_account_t *ref_account = NULL;
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -257,7 +257,7 @@ INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (int account_id, int mailbox_i
goto FINISH_OFF;
}
- if (!emcore_connect_to_remote_mailbox(account_id, mailbox_id, (void **)ret, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mailbox_id, (void **)ret, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
EM_SAFE_FREE(ret);
goto FINISH_OFF;
@@ -296,12 +296,15 @@ FINISH_OFF:
/* description
* get local mailbox list
*/
-INTERNAL_FUNC int emcore_get_mailbox_list(int account_id, email_mailbox_t **mailbox_list, int *p_count, int *err_code)
+INTERNAL_FUNC int emcore_get_mailbox_list(char *multi_user_name, int account_id, email_mailbox_t **mailbox_list,
+ int *p_count, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], p_count[%p], err_code[%p]", account_id, mailbox_list, p_count, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], p_count[%p], err_code[%p]",
+ account_id, mailbox_list, p_count, err_code);
if (account_id <= 0 || !mailbox_list || !p_count) {
- EM_DEBUG_EXCEPTION("PARAM Failed account_id[%d], mailbox_list[%p], p_count[%p]", account_id, mailbox_list, p_count);
+ EM_DEBUG_EXCEPTION("PARAM Failed account_id[%d], mailbox_list[%p], p_count[%p]",
+ account_id, mailbox_list, p_count);
if (err_code != NULL)
*err_code = EMAIL_ERROR_INVALID_PARAM;
return false;
@@ -314,16 +317,16 @@ INTERNAL_FUNC int emcore_get_mailbox_list(int account_id, email_mailbox_t **mail
int i, count = 512;
/* get mailbox list from mailbox table */
-
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION(" emcore_get_account_reference failed - %d", account_id);
error = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_list(ref_account->account_id, EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &count, &local_mailbox_list, true, &error)) {
+ if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id,
+ EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC,
+ &count, &local_mailbox_list, true, &error)) {
EM_DEBUG_EXCEPTION(" emstorage_get_mailbox failed - %d", error);
-
goto FINISH_OFF;
}
@@ -366,7 +369,7 @@ FINISH_OFF:
/* description
* get imap sync mailbox list
*/
-int emcore_get_mailbox_list_to_be_sync(int account_id, email_mailbox_t **mailbox_list, int *p_count, int *err_code)
+int emcore_get_mailbox_list_to_be_sync(char *multi_user_name, int account_id, email_mailbox_t **mailbox_list, int *p_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], p_count[%p], err_code[%p]", account_id, mailbox_list, p_count, err_code);
@@ -385,15 +388,16 @@ int emcore_get_mailbox_list_to_be_sync(int account_id, email_mailbox_t **mailbox
int i, count = 512;
/* get mailbox list from mailbox table */
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id);
error = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_list(ref_account->account_id, 0, EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &count, &mailbox_tbl_list, true, &error)) {
+ if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id, 0,
+ EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &count,
+ &mailbox_tbl_list, true, &error)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed - %d", error);
-
goto FINISH_OFF;
}
@@ -433,7 +437,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_get_mail_count(email_mailbox_t *mailbox, int *total, int *unseen, int *err_code)
+INTERNAL_FUNC int emcore_get_mail_count(char *multi_user_name, email_mailbox_t *mailbox, int *total, int *unseen, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p], err_code[%p]", mailbox, total, unseen, err_code);
@@ -446,9 +450,8 @@ INTERNAL_FUNC int emcore_get_mail_count(email_mailbox_t *mailbox, int *total, in
goto FINISH_OFF;
}
- if (!emstorage_get_mail_count(mailbox->account_id, mailbox->mailbox_id, total, unseen, true, &err)) {
+ if (!emstorage_get_mail_count(multi_user_name, mailbox->account_id, mailbox->mailbox_id, total, unseen, true, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_mail_count failed - %d", err);
-
goto FINISH_OFF;
}
@@ -456,13 +459,14 @@ INTERNAL_FUNC int emcore_get_mail_count(email_mailbox_t *mailbox, int *total, in
ret = true;
FINISH_OFF:
+
if (err_code != NULL)
*err_code = err;
return ret;
}
-INTERNAL_FUNC int emcore_create_mailbox(email_mailbox_t *new_mailbox, int on_server, int server_type, int slot_size, int *err_code)
+INTERNAL_FUNC int emcore_create_mailbox(char *multi_user_name, email_mailbox_t *new_mailbox, int on_server, int server_type, int slot_size, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("new_mailbox[%p], err_code[%p]", new_mailbox, err_code);
int ret = false;
@@ -483,7 +487,7 @@ INTERNAL_FUNC int emcore_create_mailbox(email_mailbox_t *new_mailbox, int on_ser
mail_slot_size = slot_size;
}
else {
- account_ref = emcore_get_account_reference(new_mailbox->account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, new_mailbox->account_id, false);
if (!account_ref) {
EM_DEBUG_EXCEPTION("Invalid account_id [%d]", new_mailbox->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -505,11 +509,14 @@ INTERNAL_FUNC int emcore_create_mailbox(email_mailbox_t *new_mailbox, int on_ser
}
EM_SAFE_FREE(new_mailbox->mailbox_name);
new_mailbox->mailbox_name = enc_mailbox_name;
+
+ EM_SAFE_FREE(new_mailbox->alias);
+ new_mailbox->alias = emcore_get_alias_of_mailbox((const char *)new_mailbox->mailbox_name);
}
if (on_server) {
/* Create a mailbox from Sever */
- if (!emcore_create_imap_mailbox(new_mailbox, &err)) {
+ if (!emcore_create_imap_mailbox(multi_user_name, new_mailbox, &err)) {
EM_DEBUG_EXCEPTION("Creating a mailbox on server failed.");
goto FINISH_OFF;
}
@@ -528,7 +535,7 @@ INTERNAL_FUNC int emcore_create_mailbox(email_mailbox_t *new_mailbox, int on_ser
local_mailbox->mail_slot_size = mail_slot_size;
- if (!emstorage_add_mailbox(local_mailbox, true, &err)) {
+ if (!emstorage_add_mailbox(multi_user_name, local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -547,13 +554,14 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_delete_mailbox(int input_mailbox_id, int input_on_server, int input_recursive)
+INTERNAL_FUNC int emcore_delete_mailbox(char *multi_user_name, int input_mailbox_id, int input_on_server, int input_recursive)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_on_server[%d] input_recursive[%d]", input_mailbox_id, input_on_server, input_recursive);
int err = EMAIL_ERROR_NONE;
int i = 0;
int mailbox_count = 0;
+ char *old_mailbox_name = NULL;
emstorage_mailbox_tbl_t *target_mailbox = NULL;
emstorage_mailbox_tbl_t *target_mailbox_array = NULL;
@@ -563,21 +571,30 @@ INTERNAL_FUNC int emcore_delete_mailbox(int input_mailbox_id, int input_on_serve
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE || !target_mailbox) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE || !target_mailbox) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
+ old_mailbox_name = g_strdup(target_mailbox->mailbox_name);
+
#ifdef __FEATURE_DELETE_MAILBOX_RECURSIVELY__
if(input_recursive) {
/* Getting children mailbox list */
- if(!emstorage_get_child_mailbox_list(target_mailbox->account_id, target_mailbox->mailbox_name, &mailbox_count, &target_mailbox_array, false,&err)) {
+ if(!emstorage_get_child_mailbox_list(multi_user_name,
+ target_mailbox->account_id,
+ target_mailbox->mailbox_name,
+ &mailbox_count,
+ &target_mailbox_array,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_child_mailbox_list failed. [%d]", err);
goto FINISH_OFF;
}
if (target_mailbox)
- emstorage_free_mailbox(&target_mailbox, 1, NULL);
+ emstorage_free_mailbox(&target_mailbox, 1, NULL);
+
target_mailbox = NULL;
}
else
@@ -589,11 +606,18 @@ INTERNAL_FUNC int emcore_delete_mailbox(int input_mailbox_id, int input_on_serve
}
/* Remove mailboxes */
- for(i = 0; i < mailbox_count ; i++) {
+ for (i = 0; i < mailbox_count; i++) {
+ if (strncasecmp(target_mailbox_array[i].mailbox_name, old_mailbox_name, strlen(old_mailbox_name))) {
+ if (!strcasestr(target_mailbox_array[i].mailbox_name, "/")) {
+ EM_DEBUG_LOG("Not folder");
+ continue;
+ }
+ }
+
EM_DEBUG_LOG("Deleting mailbox_id [%d]", target_mailbox_array[i].mailbox_id);
if (input_on_server) {
EM_DEBUG_LOG("Delete the mailbox in Sever >>> ");
- if (!emcore_delete_imap_mailbox(target_mailbox_array[i].mailbox_id, &err)) {
+ if (!emcore_delete_imap_mailbox(multi_user_name, target_mailbox_array[i].mailbox_id, &err)) {
EM_DEBUG_EXCEPTION("Delete the mailbox in server : failed [%d]", err);
goto FINISH_OFF;
}
@@ -601,18 +625,28 @@ INTERNAL_FUNC int emcore_delete_mailbox(int input_mailbox_id, int input_on_serve
EM_DEBUG_LOG("Delete the mailbox in server : success");
}
- if (!emcore_delete_all_mails_of_mailbox(target_mailbox_array[i].account_id, target_mailbox_array[i].mailbox_id, false, &err)) {
- EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
- goto FINISH_OFF;
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ target_mailbox_array[i].account_id,
+ target_mailbox_array[i].mailbox_id,
+ 0,
+ false,
+ &err)) {
+ if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
+ EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
+ goto FINISH_OFF;
+ }
}
- if (!emstorage_delete_mailbox(target_mailbox_array[i].account_id, -1, target_mailbox_array[i].mailbox_id, true, &err)) {
+ if (!emstorage_delete_mailbox(multi_user_name, target_mailbox_array[i].account_id, -1, target_mailbox_array[i].mailbox_id, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_delete_mailbox failed [%d]", err);
goto FINISH_OFF;
}
}
FINISH_OFF:
+
+ EM_SAFE_FREE(old_mailbox_name);
+
if (target_mailbox)
emstorage_free_mailbox(&target_mailbox, 1, NULL);
@@ -624,7 +658,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, int input_on_server, int input_recursive)
+INTERNAL_FUNC int emcore_delete_mailbox_ex(char *multi_user_name, int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, int input_on_server, int input_recursive)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d] input_mailbox_id_array[%p] input_mailbox_id_count[%d] input_on_server[%d] input_recursive[%d]", input_mailbox_id_array, input_mailbox_id_array, input_mailbox_id_count, input_on_server, input_recursive);
int err = EMAIL_ERROR_NONE;
@@ -636,13 +670,13 @@ INTERNAL_FUNC int emcore_delete_mailbox_ex(int input_account_id, int *input_mail
goto FINISH_OFF;
}
- if((err = emstorage_set_field_of_mailbox_with_integer_value(input_account_id, input_mailbox_id_array, input_mailbox_id_count, "deleted_flag", 1, true)) != EMAIL_ERROR_NONE) {
+ if((err = emstorage_set_field_of_mailbox_with_integer_value(multi_user_name, input_account_id, input_mailbox_id_array, input_mailbox_id_count, "deleted_flag", 1, true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mailbox_with_integer_value failed[%d]", err);
goto FINISH_OFF;
}
for(i = 0; i < input_mailbox_id_count; i++) {
- if((err = emcore_delete_mailbox(input_mailbox_id_array[i] , input_on_server, input_recursive)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_delete_mailbox(multi_user_name, input_mailbox_id_array[i] , input_on_server, input_recursive)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_delete_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -653,7 +687,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_delete_mailbox_all(email_mailbox_t *mailbox, int *err_code)
+INTERNAL_FUNC int emcore_delete_mailbox_all(char *multi_user_name, email_mailbox_t *mailbox, int *err_code)
{
EM_DEBUG_FUNC_BEGIN(" mailbox[%p], err_code[%p]", mailbox, err_code);
@@ -665,17 +699,21 @@ INTERNAL_FUNC int emcore_delete_mailbox_all(email_mailbox_t *mailbox, int *err_c
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
-
- if (!emcore_delete_all_mails_of_mailbox(mailbox->account_id, mailbox->mailbox_id, 0, /*NULL, */ &err)) {
- EM_DEBUG_EXCEPTION(" emcore_delete_all_mails_of_mailbox failed - %d", err);
-
- goto FINISH_OFF;
+
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ mailbox->account_id,
+ mailbox->mailbox_id,
+ 0,
+ 0, /*NULL, */
+ &err)) {
+ if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
+ EM_DEBUG_EXCEPTION(" emcore_delete_all_mails_of_mailbox failed - %d", err);
+ goto FINISH_OFF;
+ }
}
- if (!emstorage_delete_mailbox(mailbox->account_id, -1, mailbox->mailbox_id, true, &err)) {
+ if (!emstorage_delete_mailbox(multi_user_name, mailbox->account_id, -1, mailbox->mailbox_id, true, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_delete_mailbox failed - %d", err);
-
-
goto FINISH_OFF;
}
@@ -688,7 +726,15 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_rename_mailbox(int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int input_recursive, int handle_to_be_published)
+INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
+ int input_mailbox_id,
+ char *input_new_mailbox_name,
+ char *input_new_mailbox_alias,
+ void *input_eas_data,
+ int input_eas_data_length,
+ int input_on_server,
+ int input_recursive,
+ int handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_new_mailbox_name[%p] input_new_mailbox_alias[%p] input_eas_data[%p] input_eas_data_length[%d] input_on_server[%d] input_recursive[%d] handle_to_be_published[%d]", input_mailbox_id, input_new_mailbox_name, input_new_mailbox_alias, input_eas_data, input_eas_data_length, input_on_server, input_recursive, handle_to_be_published);
@@ -709,13 +755,12 @@ INTERNAL_FUNC int emcore_rename_mailbox(int input_mailbox_id, char *input_new_ma
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE || !target_mailbox) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE || !target_mailbox) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
- account_ref = emcore_get_account_reference(target_mailbox->account_id);
-
+ account_ref = emcore_get_account_reference(multi_user_name, target_mailbox->account_id, false);
if (account_ref == NULL) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed.");
goto FINISH_OFF;
@@ -738,7 +783,12 @@ INTERNAL_FUNC int emcore_rename_mailbox(int input_mailbox_id, char *input_new_ma
if (input_on_server) {
EM_DEBUG_LOG("Rename the mailbox in Sever >>> ");
- if ((err = emcore_rename_mailbox_on_imap_server(target_mailbox->account_id, target_mailbox->mailbox_id, target_mailbox->mailbox_name, new_mailbox_name, handle_to_be_published)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_rename_mailbox_on_imap_server(multi_user_name,
+ target_mailbox->account_id,
+ target_mailbox->mailbox_id,
+ target_mailbox->mailbox_name,
+ new_mailbox_name,
+ handle_to_be_published)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_rename_mailbox_on_imap_server failed [%d]", err);
goto FINISH_OFF;
}
@@ -749,7 +799,13 @@ INTERNAL_FUNC int emcore_rename_mailbox(int input_mailbox_id, char *input_new_ma
#ifdef __FEATURE_RENAME_MAILBOX_RECURSIVELY__
if(account_ref->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_recursive) {
/* Getting children mailbox list */
- if(!emstorage_get_child_mailbox_list(target_mailbox->account_id, target_mailbox->mailbox_name, &mailbox_count, &target_mailbox_array, false,&err)) {
+ if(!emstorage_get_child_mailbox_list(multi_user_name,
+ target_mailbox->account_id,
+ target_mailbox->mailbox_name,
+ &mailbox_count,
+ &target_mailbox_array,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_child_mailbox_list failed. [%d]", err);
goto FINISH_OFF;
}
@@ -768,20 +824,49 @@ INTERNAL_FUNC int emcore_rename_mailbox(int input_mailbox_id, char *input_new_ma
/* Rename mailboxes */
for(i = 0; i < mailbox_count ; i++) {
- EM_DEBUG_LOG_SEC("Rename mailbox_id [%d] mailbox_name [%s]", target_mailbox_array[i].mailbox_id, target_mailbox_array[i].mailbox_name);
+ EM_DEBUG_LOG_SEC("Rename mailbox_id [%d], mailbox_name [%s], old_mailbox_name [%s]",
+ target_mailbox_array[i].mailbox_id,
+ target_mailbox_array[i].mailbox_name,
+ old_mailbox_name);
+
+ if (old_mailbox_name && strcasecmp(target_mailbox_array[i].mailbox_name, old_mailbox_name)) {
+ if (!strstr(target_mailbox_array[i].mailbox_name, "/")) {
+ EM_DEBUG_LOG("Not folder");
+ continue;
+ }
+ }
- if(input_mailbox_id == target_mailbox_array[i].mailbox_id) {
- if ((err = emstorage_rename_mailbox(target_mailbox_array[i].mailbox_id, new_mailbox_name, input_new_mailbox_alias, input_eas_data, input_eas_data_length, true)) != EMAIL_ERROR_NONE) {
+ if (input_mailbox_id == target_mailbox_array[i].mailbox_id) {
+ if ((err = emstorage_rename_mailbox(multi_user_name,
+ target_mailbox_array[i].mailbox_id,
+ new_mailbox_name,
+ input_new_mailbox_alias,
+ input_eas_data,
+ input_eas_data_length,
+ true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed [%d]", err);
goto FINISH_OFF;
}
}
else {
- EM_DEBUG_LOG_SEC("target_mailbox_array[i].mailbox_name[%s] old_mailbox_name[%s] input_new_mailbox_name [%s]", target_mailbox_array[i].mailbox_name, old_mailbox_name, new_mailbox_name);
- renamed_mailbox_name = em_replace_string(target_mailbox_array[i].mailbox_name, old_mailbox_name, new_mailbox_name);
+ EM_DEBUG_LOG_SEC("target_mailbox_array[i].mailbox_name[%s] "
+ "old_mailbox_name[%s] "
+ "new_mailbox_name [%s]",
+ target_mailbox_array[i].mailbox_name,
+ old_mailbox_name,
+ new_mailbox_name);
+ renamed_mailbox_name = em_replace_string(target_mailbox_array[i].mailbox_name,
+ old_mailbox_name,
+ new_mailbox_name);
EM_DEBUG_LOG_SEC("renamed_mailbox_name[%s]", renamed_mailbox_name);
- if ((err = emstorage_rename_mailbox(target_mailbox_array[i].mailbox_id, renamed_mailbox_name, target_mailbox_array[i].alias, NULL, 0, true)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_rename_mailbox(multi_user_name,
+ target_mailbox_array[i].mailbox_id,
+ renamed_mailbox_name,
+ target_mailbox_array[i].alias,
+ NULL,
+ 0,
+ true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -791,6 +876,7 @@ INTERNAL_FUNC int emcore_rename_mailbox(int input_mailbox_id, char *input_new_ma
}
FINISH_OFF:
+
EM_SAFE_FREE(renamed_mailbox_name);
EM_SAFE_FREE(old_mailbox_name);
EM_SAFE_FREE(new_mailbox_name);
@@ -813,9 +899,11 @@ FINISH_OFF:
extern long smtp_send(SENDSTREAM *stream, char *command, char *args);
#endif /* __FEATURE_KEEP_CONNECTION__ */
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_account_t *account,
- int input_mailbox_id, void **result_stream, /*either MAILSTREAM or SENDSTREAM*/
- int *err_code)
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (char *multi_user_name,
+ email_account_t *account,
+ int input_mailbox_id,
+ /*either MAILSTREAM or SENDSTREAM*/ void **result_stream,
+ int *err_code)
{
EM_PROFILE_BEGIN(emCoreMailboxOpen);
EM_DEBUG_FUNC_BEGIN("account[%p], input_mailbox_id[%d], mail_stream[%p], err_code[%p]", account, input_mailbox_id,
@@ -865,17 +953,16 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
EM_DEBUG_LOG("Stream reuse desired");
#endif
+ /* set current network error as EMAIL_ERROR_NONE before network operation */
session->error = EMAIL_ERROR_NONE;
- emcore_set_network_error (EMAIL_ERROR_NONE); /* set current network error as EMAIL_ERROR_NONE before network operation */
-
+ emcore_set_network_error(EMAIL_ERROR_NONE);
+
if (input_mailbox_id == EMAIL_CONNECT_FOR_SENDING) {
mailbox_name = EM_SAFE_STRDUP(ENCODED_PATH_SMTP);
- }
- else if (input_mailbox_id == 0) {
+ } else if (input_mailbox_id == 0) {
mailbox_name = NULL;
- }
- else {
- if ((error = emstorage_get_mailbox_by_id (input_mailbox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
+ } else {
+ if ((error = emstorage_get_mailbox_by_id (multi_user_name, input_mailbox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", error);
goto FINISH_OFF;
}
@@ -884,7 +971,12 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) {
/* open pop3/imap server */
- if (!emcore_get_long_encoded_path_with_account_info (account, mailbox_name, '/', &mbox_path, &error)) {
+ if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
+ account,
+ mailbox_name,
+ '/',
+ &mbox_path,
+ &error)) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path failed - %d", error);
session->error = error;
goto FINISH_OFF;
@@ -894,32 +986,39 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
session->auth = 0; /* ref_account->receiving_auth ? 1 : 0 */
- if (!(*result_stream = mail_open (*result_stream, mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_EXCEPTION("mail_open failed. session->error[%d], session->network[%d]", session->error, session->network);
- *result_stream = mail_close (*result_stream);
+ if (!(*result_stream = mail_open(*result_stream, mbox_path, IMAP_2004_LOG))) {
+ EM_DEBUG_EXCEPTION("mail_open failed. session->error[%d], session->network[%d]",
+ session->error, session->network);
+ *result_stream = mail_close(*result_stream);
+
+ if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
+ session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
+ error = emcore_refresh_xoauth2_access_token (multi_user_name, account->account_id);
- if(account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST || session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
- if((error = emcore_refresh_xoauth2_access_token (account->account_id)) != EMAIL_ERROR_NONE) {
+ if (error != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_refresh_xoauth2_access_token failed. [%d]", error);
- }
- else {
+ } else {
while (*result_stream == NULL && connection_retry_count < 3) {
sleep(3); /* wait for updating access token */
- if (!(*result_stream = mail_open (*result_stream, mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_LOG("mail_open failed. session->error[%d], session->network[%d]", session->error, session->network);
+ if (!(*result_stream = mail_open(*result_stream, mbox_path, IMAP_2004_LOG))) {
+ EM_DEBUG_LOG("mail_open failed. session->error[%d], session->network[%d]",
+ session->error, session->network);
}
connection_retry_count++;
EM_DEBUG_LOG ("connection_retry_count [%d]", connection_retry_count);
}
}
- } else if ((session->error == EMAIL_ERROR_TLS_SSL_FAILURE || session->error == EMAIL_ERROR_CANNOT_NEGOTIATE_TLS)) {
+ } else if ((session->error == EMAIL_ERROR_TLS_SSL_FAILURE ||
+ session->error == EMAIL_ERROR_CANNOT_NEGOTIATE_TLS)) {
char *replaced_mbox_path = NULL;
replaced_mbox_path = em_replace_string(mbox_path, "}", "/force_tls_v1_0}");
- if (replaced_mbox_path != NULL && !(*result_stream = mail_open (*result_stream, replaced_mbox_path, IMAP_2004_LOG))) {
- EM_DEBUG_EXCEPTION("retry --> mail_open failed. session->error[%d], session->network[%d]", session->error, session->network);
- *result_stream = mail_close (*result_stream);
+ if (replaced_mbox_path != NULL &&
+ !(*result_stream = mail_open(*result_stream, replaced_mbox_path, IMAP_2004_LOG))) {
+ EM_DEBUG_EXCEPTION("retry --> mail_open failed. session->error[%d], session->network[%d]",
+ session->error, session->network);
+ *result_stream = mail_close(*result_stream);
}
EM_SAFE_FREE(replaced_mbox_path);
@@ -932,8 +1031,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
goto FINISH_OFF;
}
}
- }
- else {
+ } else {
/* open smtp server */
char *host_list[2] = {NULL, NULL};
@@ -953,7 +1051,12 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
}
#endif
if (!*result_stream) {
- if (!emcore_get_long_encoded_path_with_account_info (account, mailbox_name, 0, &mbox_path, &error)) {
+ if (!emcore_get_long_encoded_path_with_account_info(multi_user_name,
+ account,
+ mailbox_name,
+ 0,
+ &mbox_path,
+ &error)) {
EM_DEBUG_EXCEPTION(" emcore_get_long_encoded_path failed - %d", error);
session->error = error;
goto FINISH_OFF;
@@ -967,13 +1070,16 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
if (!(*result_stream = smtp_open (host_list, 1))) {
EM_DEBUG_EXCEPTION_SEC("smtp_open error : outgoing_server_secure_connection[%d] "
- "session->error[%d] session->network[%d]",
- account->outgoing_server_secure_connection, session->error, session->network);
+ "session->error[%d] session->network[%d]",
+ account->outgoing_server_secure_connection,
+ session->error, session->network);
if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
- session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
- *result_stream = smtp_close (*result_stream);
- if((error = emcore_refresh_xoauth2_access_token (account->account_id)) != EMAIL_ERROR_NONE) {
+ session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
+ *result_stream = smtp_close(*result_stream);
+
+ error = emcore_refresh_xoauth2_access_token(multi_user_name, account->account_id);
+ if (error != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION ("emcore_refresh_xoauth2_access_token failed. [%d]", error);
if ((session->error == EMAIL_ERROR_UNKNOWN) || (session->error == EMAIL_ERROR_NONE))
session->error = EMAIL_ERROR_CONNECTION_FAILURE;
@@ -982,8 +1088,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
}
sleep(2); /* wait for updating access token */
-
- if (!(*result_stream = smtp_open (host_list, 1))) {
+ if (!(*result_stream = smtp_open(host_list, 1))) {
if (session->network != EMAIL_ERROR_NONE)
session->error = session->network;
if ((session->error == EMAIL_ERROR_UNKNOWN) || (session->error == EMAIL_ERROR_NONE))
@@ -992,8 +1097,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info (email_acco
error = session->error;
goto FINISH_OFF;
}
- }
- else {
+ } else {
error = EMAIL_ERROR_CONNECTION_FAILURE;
goto FINISH_OFF;
}
@@ -1053,7 +1157,7 @@ emcore_close_mailbox uses mail_close inside it.
mail_close is only used in emcore_connect_to_remote_mailbox and emcore_reset_streams as an exception to above rule*/
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, char *mailbox, void **mail_stream, int *err_code)
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name, int account_id, char *mailbox, void **mail_stream, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], mail_stream[%p], err_code[%p]", account_id, mailbox, mail_stream, err_code);
@@ -1061,15 +1165,14 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, char *mailbox
int error = EMAIL_ERROR_NONE;
email_account_t *ref_account = NULL;
- ref_account = emcore_get_account_reference(account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - account id[%d]", account_id);
error = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
-
- ret = emcore_connect_to_remote_mailbox_with_account_info(ref_account, mailbox, mail_stream, &error);
+
+ ret = emcore_connect_to_remote_mailbox_with_account_info(multi_user_name, ref_account, mailbox, mail_stream, &error);
FINISH_OFF:
@@ -1080,6 +1183,7 @@ FINISH_OFF:
if (err_code)
*err_code = error;
+
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
@@ -1124,7 +1228,7 @@ INTERNAL_FUNC void emcore_reset_streams()
#else /* __FEATURE_KEEP_CONNECTION__ */
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, int input_mailbox_id, void **mail_stream, int *err_code)
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name, int account_id, int input_mailbox_id, void **mail_stream, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], mail_stream[%p], err_code[%p]", account_id, input_mailbox_id, mail_stream, err_code);
@@ -1133,8 +1237,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, int input_mai
email_session_t *session = NULL;
email_account_t *ref_account = NULL;
- ref_account = emcore_get_account_reference(account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - account id[%d]", account_id);
error = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -1158,7 +1261,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, int input_mai
goto FINISH_OFF; */
}
- ret = emcore_connect_to_remote_mailbox_with_account_info(ref_account, input_mailbox_id, mail_stream, &error);
+ ret = emcore_connect_to_remote_mailbox_with_account_info(multi_user_name, ref_account, input_mailbox_id, mail_stream, &error);
EM_DEBUG_LOG("ret[%d] incoming_server_type[%d] input_mailbox_id[%d]", ret, ref_account->incoming_server_type, input_mailbox_id);
@@ -1169,8 +1272,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, int input_mai
if (send_stream->protocol.esmtp.size.ok && send_stream->protocol.esmtp.size.limit > 0) {
EM_DEBUG_LOG("Server size limit : %ld", send_stream->protocol.esmtp.size.limit);
if (send_stream->protocol.esmtp.size.limit != ref_account->outgoing_server_size_limit) {
- emstorage_set_field_of_accounts_with_integer_value(account_id, "outgoing_server_size_limit", send_stream->protocol.esmtp.size.limit, true);
- emcore_init_account_reference();
+ emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_id, "outgoing_server_size_limit", send_stream->protocol.esmtp.size.limit, true);
}
}
}
@@ -1188,8 +1290,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, int input_mai
ref_account->retrieval_mode += EMAIL_IMAP4_IDLE_SUPPORTED;
else
ref_account->retrieval_mode -= EMAIL_IMAP4_IDLE_SUPPORTED;
- emstorage_set_field_of_accounts_with_integer_value(account_id, "retrieval_mode", ref_account->retrieval_mode, true);
- emcore_init_account_reference();
+ emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_id, "retrieval_mode", ref_account->retrieval_mode, true);
}
}
}
@@ -1389,14 +1490,14 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(int *is_event_inserted, int *err_code)
+INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(char *multi_user_name, int *is_event_inserted, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int activity_count = 0;
int ret = false;
int error = EMAIL_ERROR_NONE;
- if (false == emstorage_get_pbd_activity_count(&activity_count, false, &error)) {
+ if (false == emstorage_get_pbd_activity_count(multi_user_name, &activity_count, false, &error)) {
EM_DEBUG_LOG("emstorage_get_pbd_activity_count failed [%d]", error);
goto FINISH_OFF;
}
@@ -1436,7 +1537,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_get_mailbox_by_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t *result_mailbox, int *err_code)
+INTERNAL_FUNC int emcore_get_mailbox_by_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t *result_mailbox, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], result_mailbox [%p], err_code [%p]", account_id, result_mailbox, err_code);
int ret = false, err = EMAIL_ERROR_NONE;
@@ -1448,8 +1549,7 @@ INTERNAL_FUNC int emcore_get_mailbox_by_type(int account_id, email_mailbox_type_
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, mailbox_type, &mail_box_tbl_spam, false, &err)) {
-
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, mailbox_type, &mail_box_tbl_spam, false, &err)) {
EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed - %d", err);
}
else {
diff --git a/email-core/email-core-mime.c b/email-core/email-core-mime.c
index 33a1df4..b86a4fd 100755
--- a/email-core/email-core-mime.c
+++ b/email-core/email-core-mime.c
@@ -43,7 +43,6 @@
#include "email-internal-types.h"
#include "lnx_inc.h"
#include "email-utilities.h"
-#include "email-core-global.h"
#include "email-core-utils.h"
#include "email-core-mail.h"
#include "email-core-mime.h"
@@ -53,6 +52,7 @@
#include "email-core-account.h"
#include "email-core-signal.h"
#include "email-core-mailbox-sync.h"
+#include "email-core-container.h"
#include "email-debug-log.h"
#define MIME_MESG_IS_SOCKET
@@ -98,9 +98,6 @@
#define SAVE_TYPE_BUFFER 2 /* save content to buffe */
#define SAVE_TYPE_FILE 3 /* save content to temporary fil */
-#define EML_FOLDER 20 /* save eml content to temporary folder */
-
-
/* ---------------------------------------------------------------------- */
/* Global variable */
static int eml_data_count = 0;
@@ -124,32 +121,6 @@ extern bool only_body_download;
__thread BODY **g_inline_list = NULL;
__thread int g_inline_count = 0;
-/* Function Declaration */
-
-/* parsing the first header (RFC822 Header and Message Header and Etc... */
-static int emcore_mime_parse_header(void *stream, int is_file, struct _rfc822header **rfcheader, struct _m_mesg_header **header, int *err_code);
-
-/* parsing the first bod */
-static int emcore_mime_parse_body(void *stream, int is_file, struct _m_mesg *mmsg, struct _m_content_info *cnt_info, void *callback, int *err_code);
-
-/* parsing the message part header (CONTENT-... header */
-static int emcore_mime_parse_part_header(void *stream, int is_file, struct _m_part_header **header, int *err_code);
-
-/* parsing the message part by boundar */
-static int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *parent_header, struct _m_part *nested, struct _m_content_info *cnt_info, int *end_of_parsing, int *err_code);
-
-/* set RFC822 Header valu */
-static int emcore_mime_set_rfc822_header_value(struct _rfc822header **rfc822header, char *name, char *value, int *err_code);
-
-/* set Message Part Header (Content-... Header */
-static int emcore_mime_set_part_header_value(struct _m_part_header **header, char *name, char *value, int *err_code);
-
-static int emcore_mime_get_param_from_str(char *str, struct _parameter **param, int *err_code);
-
-static int emcore_mime_add_param_to_list(struct _parameter **param_list, struct _parameter *param, int *err_code);
-
-char *emcore_mime_get_header_value(struct _m_part_header *header, int type, int *err_code);
-
void emcore_mime_free_param(struct _parameter *param);
void emcore_mime_free_part_header(struct _m_part_header *header);
void emcore_mime_free_message_header(struct _m_mesg_header *header);
@@ -158,39 +129,6 @@ void emcore_mime_free_part(struct _m_part *part);
void emcore_mime_free_part_body(struct _m_body *body);
void emcore_mime_free_mime(struct _m_mesg *mmsg);
-/* get content data and save buffer or fil */
-/* mode - 1 : get the only siz */
-/* 2 : save content to buffer (holder is buffer */
-/* 3 : save content to file (holder is file name */
-static int emcore_mime_get_content_data(void *stream,
- int is_file,
- char *boundary_str,
- char *content_encoding,
- int *end_of_parsing,
- int mode,
- char **holder,
- int *size,
- void *callback,
- int *err_code);
-
-int emcore_decode_body_text_from_sock(void *stream, char *boundary_str, int encoding, int mode, int fd, char **holder, int *end_of_parsing, int *size);
-int emcore_decode_body_text_from_file(FILE *stream, char *boundary_str, int encoding, int mode, int fd, char **holder, int *end_of_parsing, int *size);
-/* skip content data to boundary_str or end of fil */
-int emcore_mime_skip_content_data(void *stream,
- int is_file,
- char *boundary_str,
- int *end_of_parsing,
- int *size,
- void *callback,
- int *err_code);
-
-static int emcore_get_file_pointer(BODY *body, bool input_check_duplicated_file_name, char *buf, struct _m_content_info *cnt_info , int *err);
-static PARTLIST *emcore_get_body_full(MAILSTREAM *stream, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list);
-static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int account_id, int mail_id, PARTLIST *section_list, struct _m_content_info *cnt_info, int *err_code, int event_handle);
-static PARTLIST *emcore_add_node(PARTLIST *section_list, BODY *body);
-static void emcore_free_section_list(PARTLIST *section_list);
-static int emcore_get_section_body_size(char *response, char *section, int *body_size);
-static void parse_file_path_to_filename(char *src_string, char **out_string);
extern long pop3_reply (MAILSTREAM *stream);
/* ------------------------------------------------------------------------------------------------- */
@@ -204,14 +142,14 @@ char *em_get_escaped_str(const char *str)
if (!str)
return NULL;
len = strlen(str);
- int ret_i = 0;
- const char to_be_escaped[10] = {'\\', '\"', '\0',};
char *ret = calloc(1, 2 * len);
if (ret == NULL) {
- EM_DEBUG_EXCEPTION("calloc failed");
return NULL;
}
+ int ret_i = 0;
+ const char to_be_escaped[10] = {'\\', '\"', '\0',};
+
for (i = 0; i < len; i++) {
for (j = 0; to_be_escaped[j] != '\0'; j++) {
if (str[i] == to_be_escaped[j]) {
@@ -242,11 +180,17 @@ char *em_split_file_path(char *str)
char *temp_cid_data = NULL;
char *temp_cid = NULL;
- temp_str = EM_SAFE_STRDUP(str);
+ if (str == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return NULL;
+ }
+
+ temp_str = g_strdup(str);
buf_length = EM_SAFE_STRLEN(str) + 1024;
buf = em_malloc(buf_length);
if (buf == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
+ EM_SAFE_FREE(temp_str);
return NULL;
}
@@ -261,6 +205,7 @@ char *em_split_file_path(char *str)
temp_cid_data = em_malloc((temp_cid-temp_str)+1);
if (temp_cid_data == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
+ EM_SAFE_FREE(buf);
return temp_str;
}
@@ -302,1434 +247,6 @@ char *em_split_file_path(char *str)
return buf;
}
-
-static char *em_replace_string_with_split_file_path(char *source_string, char *old_string, char *new_string)
-{
- EM_DEBUG_FUNC_BEGIN();
- char *buffer = NULL;
- char *split_str = NULL;
- char *p = NULL;
- char *q = NULL;
- int buf_len = 0;
-
- EM_IF_NULL_RETURN_VALUE(source_string, NULL);
- EM_IF_NULL_RETURN_VALUE(old_string, NULL);
- EM_IF_NULL_RETURN_VALUE(new_string, NULL);
-
- EM_DEBUG_LOG("source_string [%s] ", source_string);
- EM_DEBUG_LOG("old_string [%s] ", old_string);
- EM_DEBUG_LOG("new_string [%s] ", new_string);
-
- p = strstr(source_string, old_string);
-
- if (!p) {
- EM_DEBUG_EXCEPTION("Orig not found in source_string");
- return NULL;
- }
-
- buf_len = EM_SAFE_STRLEN(source_string) + 1024;
- buffer = (char *)em_malloc(buf_len);
- if (buffer == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- return NULL;
- }
-
- if (p - source_string < EM_SAFE_STRLEN(source_string) + 1024 + 1) {
- strncpy(buffer, source_string, p - source_string);
-
- EM_DEBUG_LOG("BUFFER [%s]", buffer);
-
- split_str = em_split_file_path(p);
- if (!split_str) {
- EM_DEBUG_EXCEPTION(">> SPLIT STRING IS NULL ");
- goto FINISH_OFF;
- }
-
- q = strstr(split_str, old_string);
- if (q) {
- EM_DEBUG_LOG("Split string [%s]", split_str);
- snprintf(buffer + EM_SAFE_STRLEN(buffer), buf_len - EM_SAFE_STRLEN(buffer), "%s%s", new_string, q+strlen(old_string)); /*prevent 34353*/
- EM_DEBUG_LOG("BUFFER 1 [%s]", buffer);
- EM_SAFE_FREE(split_str);
- EM_DEBUG_FUNC_END("Suceeded");
- return buffer;
- }
- }
- else {
- EM_DEBUG_EXCEPTION("Buffer is too small.");
- EM_SAFE_FREE(buffer);
- return NULL;
- }
-
-FINISH_OFF:
- EM_SAFE_FREE(split_str);
- EM_SAFE_FREE(buffer);
-
- EM_DEBUG_FUNC_END("Failed");
- return NULL;
-
-}
-
-
-int emcore_mime_flush_receiving_buffer(void *stream, int is_file, char *boundary_string, char *boundary_end_string, int *end_of_parsing, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], is_file[%d], boundary_string[%s], boundary_end_string[%s], end_of_parsing[%p], err_code[%p]", stream, is_file, boundary_string, boundary_end_string, end_of_parsing, err_code);
- int err = EMAIL_ERROR_NONE;
- int local_end_of_parsing = 0;
- char buf[MIME_LINE_LEN] = {0, };
-
- if (!stream) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- if (err_code)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return false;
- }
-
- while (TRUE) {
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- EM_DEBUG_FUNC_END("EMAIL_ERROR_CANCELLED");
- if (err_code)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, &err)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, &err))) {
- if (err != EMAIL_ERROR_NO_MORE_DATA) {
- EM_DEBUG_EXCEPTION("file : [%d], emcore_mime_get_line_from_sock or emcore_mime_get_line_from_file failed", is_file);
- local_end_of_parsing = 0;
- break;
- }
-
- local_end_of_parsing = 1;
- break;
- }
-
- if (boundary_string && boundary_end_string) {
- if (!strcmp(buf, boundary_string)) {
- EM_DEBUG_LOG("found boundary");
- local_end_of_parsing = 0;
- break;
- }
- else if (!strcmp(buf, boundary_end_string)) {
- EM_DEBUG_LOG("found boundary_end");
- local_end_of_parsing = 1;
- break;
- }
- }
- }
-
- if (end_of_parsing)
- *end_of_parsing = local_end_of_parsing;
-
- if (err_code)
- *err_code = err;
-
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-int emcore_parse_mime(void *stream, int is_file, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], is_file[%d], cnt_info[%p], err_code[%p]", stream, is_file, cnt_info, err_code);
-
- struct _m_mesg *mmsg = em_malloc(sizeof(struct _m_mesg));
-
- if (!mmsg) return false;
-
- memset(mmsg, 0x00, sizeof(struct _m_mesg));
-
- /* 1. parse the first found header */
- EM_DEBUG_LOG(">>>>>> 1. parse the first found header");
- if (!emcore_mime_parse_header(stream, is_file, &mmsg->rfc822header, &mmsg->header, err_code)) {
- emcore_mime_free_mime(mmsg);
- return false;
- }
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- emcore_mime_free_mime(mmsg);
- return false;
- }
-*/
- /* 2. parse body */
- EM_DEBUG_LOG(">>>>>> 2. parse body");
- if (mmsg && mmsg->header && mmsg->header->part_header && mmsg->header->part_header->parameter) {
- EM_DEBUG_LOG_SEC("name[%s]", mmsg->header->part_header->parameter->name);
- EM_DEBUG_LOG("value[%s]", mmsg->header->part_header->parameter->value);
- EM_DEBUG_LOG("next : %p", mmsg->header->part_header->parameter->next);
- }
-
- if (!emcore_mime_parse_body(stream, is_file, mmsg, cnt_info, NULL, err_code)) {
- emcore_mime_free_mime(mmsg);
- return false;
- }
-
- /* 3. free memory */
- EM_DEBUG_LOG(">>>>>> 3. free memory");
- if (mmsg && mmsg->header && mmsg->header->part_header && mmsg->header->part_header->parameter) {
- EM_DEBUG_LOG_SEC("name[%s]", mmsg->header->part_header->parameter->name);
- EM_DEBUG_LOG("value[%s]", mmsg->header->part_header->parameter->value);
- EM_DEBUG_LOG("next : %p", mmsg->header->part_header->parameter->next);
- }
- emcore_mime_free_mime(mmsg);
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-int emcore_mime_parse_header(void *stream, int is_file, struct _rfc822header **rfc822header, struct _m_mesg_header **header, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], is_file[%d], rfc822header[%p], header[%p], err_code[%p]", stream, is_file, rfc822header, header, err_code);
-
- struct _m_mesg_header *tmp_header = NULL;
- struct _rfc822header *tmp_rfc822header = NULL;
- char buf[MIME_LINE_LEN] = {0, };
- char *name = NULL;
- char *value = NULL;
- char *pTemp = NULL;
- int is_longheader;
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
-
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, err_code))) {
- return false;
- }
-
- if (!(tmp_header = em_malloc(sizeof(struct _m_mesg_header)))) {
- EM_DEBUG_EXCEPTION("malloc failed...");
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
- return false;
- }
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
-
- while (TRUE) {
- EM_DEBUG_LOG("buf[%s]", buf);
-
- if (!strncmp(buf, CRLF_STRING, 2))
- break;
-
- is_longheader = (buf[0] == ' ' || buf[0] == '\t') ? TRUE : FALSE;
-
-
- if (!is_longheader) { /* Normal header (format : "Name : Value" or "Name : Value; Parameters" */
- if (name) {
- EM_SAFE_FREE(name);
- }
-
- if ((pTemp = strtok(buf, ":")) == NULL)
- break;
-
- name = EM_SAFE_STRDUP(pTemp);
-
- value = strtok(NULL, CRLF_STRING);
-
- if (name) em_upper_string(name);
- }
- else { /* Long header */
- value = strtok(buf, CRLF_STRING);
- em_trim_left(value);
- }
-
- /* --> 2007-05-08 by cy */
- if (!name)
- break;
-
- EM_DEBUG_LOG_SEC("> name[%s]", name);
- EM_DEBUG_LOG("> value[%s]", value);
-
- /* MIME Part Header */
- if (memcmp(name, "CONTENT-", 8) == 0 && value) {
- emcore_mime_set_part_header_value(&tmp_header->part_header, name, value, err_code);
-
- if (tmp_header->part_header && tmp_header->part_header->parameter) {
- EM_DEBUG_LOG_SEC("name[%s]", tmp_header->part_header->parameter->name);
- EM_DEBUG_LOG("value[%s]", tmp_header->part_header->parameter->value);
- EM_DEBUG_LOG("next : %p", tmp_header->part_header->parameter->next);
- }
-
- /* MIME Version Header */
- }
- else if (memcmp(name, "MIME-VERSION", 12) == 0) {
- /* EM_DEBUG_FUNC_BEGIN() */
- /* ignored because we need only contents information */
- /* tmp_header->version = EM_SAFE_STRDUP(value) */
- /* RFC822 Header */
- }
- /*
- else if (strncmp(name, "MESSAGE-CONTEXT", strlen("MESSAGE-CONTEXT")) == 0) {
- em_upper_string(value);
- tmp_header->message_context = EM_SAFE_STRDUP(value);
- }
- else if (strncmp(name, "CONTENT-DURATION", strlen("CONTENT-DURATION")) == 0) {
- tmp_header->content_duration = atoi(value);
- }
- else if (strncmp(name, "X-CONTENT-PAGES", strlen("X-CONTENT-PAGES")) == 0) {
- tmp_header->x_content_pages = atoi(value);
- }
- else if (strncmp(name, "SENSITIVITY", strlen("SENSITIVITY")) == 0) {
- em_upper_string(value);
- tmp_header->sensitivity = EM_SAFE_STRDUP(value);
- }
- */
- else {
- /* in socket stream case, ignored because we need only contents information */
- if (is_file == 1)
- emcore_mime_set_rfc822_header_value(&tmp_rfc822header, name, value, err_code);
- }
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
-
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, err_code))) {
-
- if (tmp_rfc822header)
- emcore_mime_free_rfc822_header(tmp_rfc822header);
-
-
- if (tmp_header) {
- emcore_mime_free_part_header(tmp_header->part_header);
-
- EM_SAFE_FREE(tmp_header->version);
- EM_SAFE_FREE(tmp_header);
- }
- return false;
- }
- }
-
- *header = tmp_header;
- *rfc822header = tmp_rfc822header;
-
- EM_SAFE_FREE(name);
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-int emcore_mime_parse_part_header(void *stream, int is_file, struct _m_part_header **header, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], is_file[%d], header[%p], err_code[%p]", stream, is_file, header, err_code);
-
- struct _m_part_header *tmp_header = NULL;
- char buf[MIME_LINE_LEN] = {0x00};
- char *name = NULL;
- char *value = NULL;
- char *p = NULL;
- int is_longheader = false;
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
-
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, err_code)))
- return false;
-
- tmp_header = em_malloc(sizeof(struct _m_part_header));
- if (!tmp_header) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- return false;
- }
-
- memset(tmp_header, 0, sizeof(struct _m_part_header));
-
- while (true) {
- if (!strncmp(buf, CRLF_STRING, EM_SAFE_STRLEN(CRLF_STRING))) break;
-
- is_longheader = (buf[0] == ' ' || buf[0] == TAB);
-
- if (!is_longheader) { /* Normal header (format : "Name : Value" or "Name : Value; Parameters" */
- EM_SAFE_FREE(name);
- p = strtok(buf , ":");
-
- if (p) {
- name = EM_SAFE_STRDUP(p);
- value = strtok(NULL, CRLF_STRING);
- if (value) em_upper_string(name);
- }
- }
- else /* Long header */
- value = strtok(buf, CRLF_STRING);
-
- if (!name)
- break;
-
- emcore_mime_set_part_header_value(&tmp_header, name, value, err_code);
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
-
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, err_code))) {
- EM_SAFE_FREE(name);
- EM_SAFE_FREE(tmp_header);
-
- return false;
- }
- }
-
- *header = tmp_header;
-
- EM_SAFE_FREE(name);
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-
-int emcore_mime_parse_body(void *stream, int is_file, struct _m_mesg *mmsg, struct _m_content_info *cnt_info, void *callback, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], is_file[%d], mmsg[%p], cnt_info[%p], callback[%p], err_code[%p]", stream, is_file, mmsg, cnt_info, callback, err_code);
-
- if (!mmsg->header) {
- EM_DEBUG_EXCEPTION("Invalid paramter");
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return false;
- }
-
- char *content_type = NULL, *content_encoding = NULL, *holder = NULL, *attachment_name, *t = NULL;
- int type = 0, end_of_parsing = 0, size;
- int err = EMAIL_ERROR_NONE;
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
-
- if (mmsg->header)
- content_type = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_TYPE, err_code);
- if (!content_type)
- content_type = "TEXT/PLAIN";
-
- if (mmsg->header)
- content_encoding = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_ENCODING, err_code);
- if (!content_encoding)
- content_encoding = "7BIT";
-
- if (strstr(content_type, TEXT_STR)) type = TYPE_TEXT;
- else if (strstr(content_type, IMAGE_STR)) type = TYPE_IMAGE;
- else if (strstr(content_type, AUDIO_STR)) type = TYPE_AUDIO;
- else if (strstr(content_type, VIDEO_STR)) type = TYPE_VIDEO;
- else if (strstr(content_type, APPLICATION_STR)) type = TYPE_APPLICATION;
- else if (strstr(content_type, MULTIPART_STR)) type = TYPE_MULTIPART;
- else if (strstr(content_type, MESSAGE_STR)) type = TYPE_MESSAGE;
- else type = TYPE_UNKNOWN;
-
- switch (type) {
- case TYPE_MULTIPART:
- if (mmsg->header && !emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_BOUNDARY, &err)) {
- EM_DEBUG_FUNC_END("false");
- if (err_code != NULL)
- *err_code = err;
- return false;
- }
-
- if (mmsg->header && !emcore_mime_parse_part(stream, is_file, mmsg->header->part_header, &mmsg->nested, cnt_info, &end_of_parsing, &err)) {
- EM_DEBUG_FUNC_END("false");
- if (err_code != NULL)
- *err_code = err;
- return false;
- }
-
- /* after finishing body parsing, make stream empty to get next mail. (get line from sock or file until '.' is read */
- if (end_of_parsing && err != EMAIL_ERROR_NO_MORE_DATA)
- emcore_mime_flush_receiving_buffer(stream, is_file, NULL, NULL, NULL, NULL);
-
- break;
-
- default:
- attachment_name = NULL;
-
- if (mmsg->header && emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_DISPOSITION, err_code)) {
- attachment_name = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_FILENAME, err_code);
- /* if (!attachment_name) attachment_name = "unknown" */
- if (attachment_name) EM_DEBUG_LOG_SEC(" attachment = [%s]", attachment_name);
- }
-
- if (strcasestr(content_type, "PKCS7-MIME")) {
- EM_DEBUG_LOG("Encrypted mail do not include the body");
-
- if (attachment_name == NULL)
- attachment_name = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_NAME, err_code);
-
- EM_DEBUG_LOG_SEC("attachment_name : [%s]", attachment_name);
-
- cnt_info->file = em_malloc(sizeof(struct attachment_info));
- if (cnt_info->file) {
- cnt_info->file->type = ATTACHMENT;
- cnt_info->file->name = EM_SAFE_STRDUP(attachment_name);
- if (!emcore_mime_get_content_data(stream, is_file, NULL, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed : [%d]", err_code);
- return false;
- }
- cnt_info->file->save = holder;
- cnt_info->file->size = size;
- cnt_info->file->attachment_mime_type = EM_SAFE_STRDUP(content_type);
- cnt_info->file->next = NULL;
- }
- break;
- }
-
- if (cnt_info->grab_type & GRAB_TYPE_TEXT) {
- /* EM_DEBUG_LINE */
- /* get content data. content data is saved in file */
- if (!emcore_mime_get_content_data(stream, is_file, NULL, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed : [%d]", err_code);
- return false;
- }
-
- EM_DEBUG_LOG("After emcore_mime_get_content_data");
-
- char *charset = mmsg->header? emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_CHARSET, err_code) : NULL; /* prevent 27453 */
- EM_DEBUG_LOG(">>>> charset [%s]", charset);
-
- if (mmsg->header && mmsg->header->part_header && strstr((t = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_TYPE, err_code)) ? t : "", "HTML")) {
- if (!charset || !strncmp(charset, "X-UNKNOWN", strlen("X-UNKNOWN")))
- cnt_info->text.html_charset = strdup("UTF-8");
- else
- cnt_info->text.html_charset = EM_SAFE_STRDUP(charset);
- EM_DEBUG_LOG(">>>> cnt_info->text.html_charset [%s]", cnt_info->text.html_charset);
-
- cnt_info->text.html = holder;
- EM_DEBUG_LOG(">>>> cnt_info->text.html [%s]", cnt_info->text.html);
- }
- else if (mmsg->header) {
-
- if (!charset || !strncmp(charset, "X-UNKNOWN", strlen("X-UNKNOWN")))
- cnt_info->text.plain_charset = strdup("UTF-8");
- else
- cnt_info->text.plain_charset = EM_SAFE_STRDUP(charset);
- EM_DEBUG_LOG(">>>> cnt_info->text.plain_charset [%s]", cnt_info->text.plain_charset);
-
- cnt_info->text.plain = holder;
- EM_DEBUG_LOG(">>>> cnt_info->text.plain [%s]", cnt_info->text.plain);
- }
- }
-
- break;
- }
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-int emcore_mime_parse_part(void *stream, int is_file, struct _m_part_header *parent_header, struct _m_part *nested, struct _m_content_info *cnt_info, int *eop, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], is_file[%d], parent_header[%p], nested[%p], cnt_info[%p], eop[%p], err_code[%p]", stream, is_file, parent_header, nested, cnt_info, eop, err_code);
-
- struct _m_body *tmp_body = NULL;
- struct _m_part **p = NULL;
- char buf[MIME_LINE_LEN] = {0x00, };
- char boundary[BOUNDARY_LEN] = {0x00, };
- char boundary_end[BOUNDARY_LEN] = {0x00, };
- char temp_inline_attachment_name[20] = {0x00, };
- char *boundary_str = NULL;
- char *content_type = NULL;
- char *content_encoding = NULL;
- char *holder = NULL;
- char *attachment_name = NULL;
- char *content_id = NULL;
- char *content_disposition = NULL;
- char *pTemp = NULL;
- int type = 0;
- int content_disposition_type = 0;
- int end_of_parsing = 0;
- int size = 0, local_err_code = EMAIL_ERROR_NONE;
- int result = 0;
- int inline_attach_index = 0;
-
- boundary_str = emcore_mime_get_header_value(parent_header, CONTENT_BOUNDARY, err_code);
-
- SNPRINTF(boundary, BOUNDARY_LEN, "--%s%s", boundary_str, CRLF_STRING);
- SNPRINTF(boundary_end, BOUNDARY_LEN, "--%s%s", boundary_str, "--\r\n");
-
- nested->body = NULL;
- nested->next = NULL;
-
- /* goto the first found useful mime dat */
- EM_DEBUG_LOG("Before first loop");
- while (true) {
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, err_code))) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_line_from_sock failed.");
- if (eop)
- *eop = true;
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- if (!strcmp(buf, boundary))
- break;
- }
-
- EM_DEBUG_LOG("Before second loop");
- while (true) {
- if (!(tmp_body = em_malloc(sizeof(struct _m_body)))) {
- EM_DEBUG_EXCEPTION("em_malloc failed.");
- if (nested->body)
- emcore_mime_free_part_body(nested->body);
- if (nested->next)
- emcore_mime_free_part(nested->next);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- memset(tmp_body, 0, sizeof(struct _m_body));
-
- /* parsing MIME Header */
- if (!emcore_mime_parse_part_header(stream, is_file, &tmp_body->part_header, err_code)) {
- EM_DEBUG_EXCEPTION("emcore_mime_parse_part_header failed.");
- if (nested->body)
- emcore_mime_free_part_body(nested->body);
- if (nested->next)
- emcore_mime_free_part(nested->next);
-
- emcore_mime_free_part_body(tmp_body);
- return false;
- }
-
- content_type = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_TYPE, err_code);
-
- if (!content_type)
- content_type = "TEXT/PLAIN";
-
- content_encoding = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_ENCODING, err_code);
- if (!content_encoding)
- content_encoding = "7BIT";
-
- if (strstr(content_type, TEXT_STR)) type = TYPE_TEXT;
- else if (strstr(content_type, IMAGE_STR)) type = TYPE_IMAGE;
- else if (strstr(content_type, AUDIO_STR)) type = TYPE_AUDIO;
- else if (strstr(content_type, VIDEO_STR)) type = TYPE_VIDEO;
- else if (strstr(content_type, APPLICATION_STR)) type = TYPE_APPLICATION;
- else if (strstr(content_type, MULTIPART_STR)) type = TYPE_MULTIPART;
- else if (strstr(content_type, MESSAGE_STR)) type = TYPE_MESSAGE;
- else type = TYPE_UNKNOWN;
-
- switch (type) {
- case TYPE_MULTIPART:
- EM_DEBUG_LOG("TYPE_MULTIPART");
- if (!emcore_mime_get_header_value(tmp_body->part_header, CONTENT_BOUNDARY, err_code)) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_header_value failed.");
- emcore_mime_free_part_body(tmp_body);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- emcore_mime_parse_part(stream, is_file, tmp_body->part_header, &tmp_body->nested, cnt_info, &end_of_parsing, &local_err_code);
-
- if (!nested->body)
- nested->body = tmp_body;
- else {
- p = &nested->next;
-
- while (*p && (*p)->next)
- *p = (*p)->next;
-
- if (*p)
- p = &(*p)->next;
-
- if (!(*p = em_malloc(sizeof(struct _m_part)))) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- if (nested->body) emcore_mime_free_part_body(nested->body);
- if (nested->next) emcore_mime_free_part(nested->next);
- emcore_mime_free_part_body(tmp_body);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- (*p)->body = tmp_body;
- (*p)->next = NULL;
- }
-
- if (err_code)
- *err_code = local_err_code;
-
- if (end_of_parsing && local_err_code != EMAIL_ERROR_NO_MORE_DATA) /* working with imap */
- /* if (!end_of_parsing) */ /* working with pop */ {
- EM_DEBUG_LOG("Enter flushing socket buffer.");
- emcore_mime_flush_receiving_buffer(stream, is_file, boundary, boundary_end, &end_of_parsing, err_code);
- }
-
- break;
-
- default:
- EM_DEBUG_LOG("default");
- content_disposition_type = 0;
- attachment_name = NULL;
- content_id = NULL;
- content_disposition = NULL;
-
- /* first check inline content */
- /* if the content id or content location exis */
- content_disposition = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_DISPOSITION, err_code);
- EM_DEBUG_LOG_SEC("content_disposition : [%s]", content_disposition);
-
- content_id = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_ID, err_code);
- EM_DEBUG_LOG_SEC("content_id : [%s]", content_id);
-
- if (content_id) {
- if (emcore_search_string_from_file(cnt_info->text.html, content_id, NULL, &result) == EMAIL_ERROR_NONE && result) {
-
- SNPRINTF(temp_inline_attachment_name, sizeof(temp_inline_attachment_name), "image_%d", ++inline_attach_index);
- attachment_name = temp_inline_attachment_name;
-
- if (emcore_search_string_from_file(cnt_info->text.html, content_id, attachment_name, &result) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_search_string_from file failed");
- }
-
- content_disposition_type = INLINE_ATTACHMENT;
-
- } else if (!strcasecmp(content_disposition ? content_disposition : "", "attachment")) {
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_NAME, err_code);
-
- if (!attachment_name)
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_FILENAME, err_code);
-
- content_disposition_type = ATTACHMENT;
-
- } else if (!strcasecmp(content_disposition ? content_disposition : "", "inline")) {
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_NAME, err_code);
-
- if (!attachment_name)
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_FILENAME, err_code);
-
- content_disposition_type = INLINE_ATTACHMENT;
-
- } else {
- EM_DEBUG_EXCEPTION("Unknown mime type");
- }
- } else {
- if (!strcasecmp(content_disposition ? content_disposition : "", "attachment")) {
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_NAME, err_code);
-
- if (!attachment_name)
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_FILENAME, err_code);
-
- if (!attachment_name && type == TYPE_MESSAGE)
- attachment_name = strdup("unknown_name");
-
- content_disposition_type = ATTACHMENT;
-
- } else if (!strcasecmp(content_disposition ? content_disposition : "", "inline")) {
-
- SNPRINTF(temp_inline_attachment_name, sizeof(temp_inline_attachment_name), "image_%d", ++inline_attach_index);
- attachment_name = temp_inline_attachment_name;
-
- if (emcore_search_string_from_file(cnt_info->text.html, content_id, attachment_name, &result) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_search_string_from file failed");
- } else {
- content_disposition_type = INLINE_ATTACHMENT;
- }
- } else if (strstr(content_type ? content_type : "", "PKCS7")) {
- attachment_name = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_NAME, err_code);
- EM_DEBUG_LOG_MIME(">> attachment = [%s]", attachment_name ? attachment_name : NIL);
-
- content_disposition_type = ATTACHMENT;
-
- } else {
- EM_DEBUG_LOG("No attachment");
- }
- }
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_CANCELLED");
- emcore_mime_free_part_body(tmp_body);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-*/
-
- EM_DEBUG_LOG_SEC("attachment_name : [%s]", attachment_name);
- /* get content and content information */
- if (content_disposition_type != ATTACHMENT && content_disposition_type != INLINE_ATTACHMENT) { /* text */
- /* get content by buffer */
- EM_DEBUG_LOG_MIME("attachment_name is NULL. It's a text message");
- if (!emcore_mime_get_content_data(stream, is_file, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed [%d]", err_code);
- emcore_mime_free_part_body(tmp_body);
- return false;
- }
-
- EM_DEBUG_LOG("After emcore_mime_get_content_data");
-
- if (cnt_info->grab_type & GRAB_TYPE_TEXT) {
- char *charset = emcore_mime_get_header_value(tmp_body->part_header, CONTENT_CHARSET, err_code);
- EM_DEBUG_LOG(" charset [%s]", charset);
-
- if (tmp_body->part_header && strstr(content_type ? content_type : "", "HTML")) {
- if (!charset || !strncmp(charset, "X-UNKNOWN", strlen("X-UNKNOWN")))
- cnt_info->text.html_charset = strdup("UTF-8");
- else
- cnt_info->text.html_charset = EM_SAFE_STRDUP(charset);
- EM_DEBUG_LOG(" cnt_info->text.html_charset [%s]", cnt_info->text.html_charset);
-
- cnt_info->text.html = holder;
- EM_DEBUG_LOG(" cnt_info->text.html [%s]", cnt_info->text.html);
- } else {
- if (!charset || !strncmp(charset, "X-UNKNOWN", strlen("X-UNKNOWN")))
- cnt_info->text.plain_charset = strdup("UTF-8");
- else
- cnt_info->text.plain_charset = EM_SAFE_STRDUP(charset);
- EM_DEBUG_LOG(" cnt_info->text.plain_charset [%s]", cnt_info->text.plain_charset);
-
- cnt_info->text.plain = holder;
- EM_DEBUG_LOG(" cnt_info->text.plain [%s]", cnt_info->text.plain);
- }
- } else {
- EM_SAFE_FREE (holder);
- }
- } else { /* attachment */
- EM_DEBUG_LOG("attachment_name is not NULL. It's a attachment");
- struct attachment_info *file = NULL;
- struct attachment_info *temp_file = cnt_info->file;
-
- file = em_malloc(sizeof(struct attachment_info));
- if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
- emcore_mime_free_part_body(tmp_body);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- file->type = content_disposition_type;
-
- EM_DEBUG_LOG("file->type : %d", file->type);
-
- file->name = EM_SAFE_STRDUP(attachment_name);
- file->content_id = EM_SAFE_STRDUP(tmp_body->part_header->content_id);
- file->attachment_mime_type = EM_SAFE_STRDUP(content_type);
-
-
- /* check if the current file is target file */
- if ((cnt_info->grab_type & GRAB_TYPE_ATTACHMENT) || file->type == INLINE_ATTACHMENT) {
- /* get content by file */
- EM_DEBUG_LOG_MIME("Trying to get content");
- if (!emcore_mime_get_content_data(stream, is_file, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_FILE, &holder, &size, NULL, err_code)) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed [%d]", err_code);
- emcore_mime_free_part_body(tmp_body);
- emcore_free_attachment_info(file);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- file->save = holder;
- } else {
- /* only get content size */
- EM_DEBUG_LOG_MIME("Pass downloading");
- if (!emcore_mime_get_content_data(stream, is_file, boundary_str, content_encoding, &end_of_parsing, SAVE_TYPE_SIZE, NULL, &size, NULL, err_code)) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_content_data failed [%d]", err_code);
- emcore_mime_free_part_body(tmp_body);
- emcore_free_attachment_info(file);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- file->save = NULL;
- }
-
- if (err_code)
- EM_DEBUG_LOG("end_of_parsing [%d], err_code [%d]", end_of_parsing, *err_code);
-
- file->size = size;
- file->attachment_mime_type = strdup(content_type);
-
- switch (end_of_parsing) {
- case 0:
- case 1:
- /* Downloaded */
- file->save_status = 1;
- break;
- case 2:
- file->save_status = 2;
- break;
- }
-
-
- if (strstr(content_type, APPLICATION_STR)) {
- pTemp = content_type + EM_SAFE_STRLEN(APPLICATION_STR);
-
- if (strcasecmp(pTemp, MIME_SUBTYPE_DRM_OBJECT) == 0)
- file->drm = EMAIL_ATTACHMENT_DRM_OBJECT;
- else if (strcasecmp(pTemp, MIME_SUBTYPE_DRM_RIGHTS) == 0)
- file->drm = EMAIL_ATTACHMENT_DRM_RIGHTS;
- else if (strcasecmp(pTemp, MIME_SUBTYPE_DRM_DCF) == 0)
- file->drm = EMAIL_ATTACHMENT_DRM_DCF;
- }
-
- while (temp_file && temp_file->next)
- temp_file = temp_file->next;
-
- if (temp_file == NULL)
- cnt_info->file = file;
- else
- temp_file->next = file;
- }
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_CANCELLED");
- emcore_mime_free_part_body(tmp_body);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-*/
-
- if (!nested->body)
- nested->body = tmp_body;
- else {
- p = &nested->next;
-
- while (*p && (*p)->next)
- p = &(*p)->next;
-
- if (*p)
- p = &(*p)->next;
-
- if (!(*p = em_malloc(sizeof(struct _m_part)))) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- if (nested->body) emcore_mime_free_part_body(nested->body);
- if (nested->next) emcore_mime_free_part(nested->next);
-
- emcore_mime_free_part_body(tmp_body);
- EM_DEBUG_FUNC_END("false");
- return false;
- }
-
- (*p)->body = tmp_body;
- (*p)->next = NULL;
- }
-
- break;
- }
-
- /* End of parsin */
- if (end_of_parsing)
- break;
- }
-
- if (eop != NULL)
- *eop = end_of_parsing;
-
- EM_DEBUG_FUNC_END("end_of_parsing [%d]", end_of_parsing);
- return true;
-}
-
-/* set RFC822 Heade */
-int emcore_mime_set_rfc822_header_value(struct _rfc822header **header, char *name, char *value, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN_SEC("header[%p], name[%s], value[%s], err_code[%p]", header, name, value, err_code);
-
- char **p = NULL;
- char *t = NULL;
-
- if (!value || !*value || !name ) return false; /*prevent 34354*/
-
- if (!*header) {
- *header = em_malloc(sizeof(struct _rfc822header));
- if (!*header) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- return false;
- }
- }
-
-
- em_upper_string(name);
-
- if (strncmp(name, "RETURN-PATH", strlen("RETURN-PATH")) == 0)
- p = &(*header)->return_path;/* Return-Rat */
- else if (strncmp(name, "RECEIVED", strlen("RECEIVED")) == 0)
- p = &(*header)->received; /* Receive */
- else if (strncmp(name, "REPLY-TO", strlen("REPLY-TO")) == 0)
- p = &(*header)->reply_to; /* Reply-T */
- else if (strncmp(name, "DATE", strlen("DATE")) == 0)
- p = &(*header)->date; /* Dat */
- else if (strncmp(name, "FROM", strlen("FROM")) == 0)
- p = &(*header)->from; /* Fro */
- else if (strncmp(name, "SUBJECT", strlen("SUBJECT")) == 0)
- p = &(*header)->subject; /* Subjec */
- else if (strncmp(name, "SENDER", strlen("SENDER")) == 0)
- p = &(*header)->sender; /* Sende */
- else if (strncmp(name, "TO", strlen("TO")) == 0)
- p = &(*header)->to; /* T */
- else if (strncmp(name, "CC", strlen("CC")) == 0)
- p = &(*header)->cc; /* C */
- else if (strncmp(name, "BCC", strlen("BCC")) == 0)
- p = &(*header)->bcc; /* Bc */
- else if (strncmp(name, "X-PRIORITY", strlen("X-PRIORITY")) == 0)
- p = &(*header)->priority; /* Prorit */
- else if (strncmp(name, "X-MSMAIL-PRIORITY", strlen("X-MSMAIL-PRIORITY")) == 0)
- p = &(*header)->ms_priority;/* Prorit */
- else if (strncmp(name, "DISPOSITION-NOTIFICATION-TO", strlen("DISPOSITION-NOTIFICATION-TO")) == 0)
- p = &(*header)->dsp_noti_to;/* Disposition-Notification-T */
- else {
- return false;
- }
-
- em_trim_left(value);
-
- if (!*p)
- *p = EM_SAFE_STRDUP(value);
- else { /* Long Header */
- if (!(t = realloc(*p, strlen(*p) + strlen(value)+1))) /*prevent 34354*/
- return false;
-
- strncat(t, value, strlen(value)); /*prevent 34354*/
- *p = t;
- }
-
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-/* set MIME Part Heade */
-int emcore_mime_set_part_header_value(struct _m_part_header **header, char *name, char *value, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN_SEC("header[%p], name[%s], value[%s], err_code[%p]", header, name, value, err_code);
-
- if (!name || !value) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return false;
- }
-
- struct _parameter *p = NULL;
- struct _parameter *tmp = NULL;
- char *p_val = NULL;
-
- if (!*header) {
- *header = em_malloc(sizeof(struct _m_part_header));
- if (!(*header)) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
- return false;
- }
- }
-
- em_upper_string(name);
-
- em_trim_left(value);
- em_trim_right(value);
-
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
- if (name) {
- if (strncmp(name, "CONTENT-TYPE", strlen("CONTENT-TYPE")) == 0) {
- p_val = strtok(value, ";");
-
- if (p_val) {
- if (!(*header)->type) { /* Content-Type */
- em_upper_string(p_val);
- (*header)->type = EM_SAFE_STRDUP(p_val);
- }
-
- /* Content-Type Parameter (format : "name =value" */
- do {
- if (emcore_mime_get_param_from_str(p_val, &p, err_code)) {
- /* Save the start node */
- tmp = (*header)->parameter;
- /* insert node */
- emcore_mime_add_param_to_list(&((*header)->parameter), p, err_code);
- if (tmp != NULL) {
- (*header)->parameter = tmp;
- tmp = NULL;
- }
- }
- else /* name= CRLF value */ {
- struct _parameter *t = (*header)->parameter;
- while (t && t->next) {
- EM_DEBUG_LOG_SEC("name : [%s]", t->name);
- EM_DEBUG_LOG("value : [%s]", t->value);
- t = t->next;
- }
-
- if (t && t->name) {
- char *pointer = NULL;
-
- if (EM_SAFE_STRLEN(p_val) > 0) {
- /* "=?charset?B?value?= */
- /* "=?charset?B?value.... */
- /* =?charset?B?value" */
- if ((pointer = strchr(p_val, '\"'))) {
- if (!*(pointer + 1)) { /* line end '"' */
- if (*p_val == *pointer) /* Example : '"' */
- return true;
- else
- *pointer = '\0'; /* Example : 'abcde"' */
- }
- else { /* line start '"' */
- p_val = pointer + 1;
- if ((pointer = strchr(p_val, '\"')))
- *pointer = '\0';
- }
- }
-
- /* = ? ENCODING_TYPE ? B(Q) ? ENCODED_STRING ? */
- int err = EMAIL_ERROR_NONE;
- char *utf8_text = NULL;
-
- if (!(utf8_text = emcore_decode_rfc2047_text(p_val, &err))) {
- EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_text failed [%d]", err);
- continue; /*prevent 53050*/
- }
- EM_DEBUG_LOG_SEC("utf8_text : [%s]", utf8_text);
-
- if (t->value == NULL) {
- EM_DEBUG_LOG("value is NULL");
- t->value = EM_SAFE_STRDUP(utf8_text);
- } else {
- EM_DEBUG_LOG("value is not NULL");
- t->value = realloc(t->value, strlen(t->value) + EM_SAFE_STRLEN(utf8_text) + 1);
- strcpy((t->value + strlen(t->value)), utf8_text);
- EM_DEBUG_LOG("long name : [%s]", t->value);
- }
-
- EM_DEBUG_LOG("value : [%s]", t->value);
- EM_SAFE_FREE (utf8_text);
- }
- }
- }
- } while ((p_val = strtok(NULL, ";")));
- }
- }
- else if (strncmp(name, "CONTENT-TRANSFER-ENCODING", strlen("CONTENT-TRANSFER-ENCODING")) == 0) {
- em_upper_string(value);
- (*header)->encoding = EM_SAFE_STRDUP(value);
- }
- else if (strncmp(name, "CONTENT-DESCRPTION", strlen("CONTENT-DESCRPTION")) == 0) {
- em_upper_string(value);
- (*header)->desc = EM_SAFE_STRDUP(value);
- }
- else if (strncmp(name, "CONTENT-DISPOSITION", strlen("CONTENT-DISPOSITION")) == 0) {
- p_val = strtok(value, ";");
-
- if (p_val) {
- if (!(*header)->disp_type) { /* Content-Dispositio */
- em_upper_string(p_val);
- (*header)->disp_type = EM_SAFE_STRDUP(p_val);
- }
- /* Content-Disposition Parameter (format : "name =value" */
- do {
- if (emcore_mime_get_param_from_str(p_val, &p, err_code)) {
- /* Save the start node */
- tmp = (*header)->disp_parameter;
- /* insert node */
- emcore_mime_add_param_to_list(&((*header)->disp_parameter), p, err_code);
- if (tmp != NULL) {
- (*header)->disp_parameter = tmp;
- tmp = NULL;
- }
- }
- else /* name= CRLF value */ {
- struct _parameter *t = (*header)->disp_parameter;
- while (t && t->next) {
-// EM_DEBUG_LOG_SEC("name : [%s]", t->name);
-// EM_DEBUG_LOG("value : [%s]", t->value);
- t = t->next;
- }
-
- if (t && t->name) {
- char *pointer = NULL;
-
- if (EM_SAFE_STRLEN(p_val) > 0) {
- /* "=?charset?B?value?= */
- /* "=?charset?B?value.... */
- /* =?charset?B?value" */
- if ((pointer = strchr(p_val, '\"'))) {
- if (!*(pointer + 1)) { /* line end '"' */
- if (*p_val == *pointer) /* Example : '"' */
- return true;
- else
- *pointer = '\0'; /* Example : 'abcde"' */
- }
- else { /* line start '"' */
- p_val = pointer + 1;
- if ((pointer = strchr(p_val, '\"')))
- *pointer = '\0';
- }
- }
-
- /* = ? ENCODING_TYPE ? B(Q) ? ENCODED_STRING ? */
- int err = EMAIL_ERROR_NONE;
- char *utf8_text = NULL;
-
- if (!(utf8_text = emcore_decode_rfc2047_text(p_val, &err))) {
- EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_text failed [%d]", err);
- continue; /*prevent 53050*/
- }
- EM_DEBUG_LOG("utf8_text : [%s]", utf8_text);
-
- if (t->value == NULL) {
- EM_DEBUG_LOG("value is NULL");
- t->value = EM_SAFE_STRDUP(utf8_text);
- } else {
- EM_DEBUG_LOG("value is not NULL");
- t->value = realloc(t->value, strlen(t->value) + EM_SAFE_STRLEN(utf8_text) + 1);
- if (t->value == NULL) {
- EM_DEBUG_EXCEPTION("realloc failed");
- continue;
- }
- strcpy((t->value + strlen(t->value)), utf8_text);
- EM_DEBUG_LOG("long name : [%s]", t->value);
- }
-
- EM_DEBUG_LOG_SEC("value : [%s]", t->value);
- EM_SAFE_FREE (utf8_text);
- }
- }
- }
- } while ((p_val = strtok(NULL, ";")));
- }
- }
- else if (strncmp(name, "CONTENT-ID", strlen("CONTENT-ID")) == 0) {
- size_t len = 0;
- len = EM_SAFE_STRLEN(value);
- /* em_upper_string(value) */
-
- if ((len) && (value[0] == '<')) {
- ++value;
- --len;
- }
-
- if ((len > 1) && (value[len-1] == '>'))
- value[len-1] = '\0';
-
- (*header)->content_id = EM_SAFE_STRDUP(value);
- }
- else if (strncmp(name, "CONTENT-LOCATION", strlen("CONTENT-LOCATION")) == 0) {
- (*header)->content_location = EM_SAFE_STRDUP(value);
- }
- else if (strncmp(name, "X-PRIORITY", strlen("X-PRIORITY")) == 0) {
- (*header)->priority = EM_SAFE_STRDUP(value);
- }
- else if (strncmp(name, "X-MSMAIL-PRIORITY", strlen("X-MSMAIL-PRIORITY")) == 0) {
- (*header)->ms_priority = EM_SAFE_STRDUP(value);
- }
- }
-
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-/* get header parameter from string */
-int emcore_mime_get_param_from_str(char *str, struct _parameter **param, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("str[%s], param[%p], err_code[%p]", str, param, err_code);
-
- char *p_name, *p_val, *p;
-
- *param = NULL;
-
- if (!(p = strchr(str, '='))) return false;
-
- if (*(p+1) == '?') {
- EM_DEBUG_LOG("The parameter is invalid : [%s]", str);
- return false;
- }
-
- *p = '\0';
-
- p_name = str;
- p_val = p+1;
-
- em_trim_left(p_name);
- em_trim_right(p_name);
-
- if (!*p_name) return false;
-
- if (!(*param = em_malloc(sizeof(struct _parameter)))) return false;
-
- (*param)->next = NULL;
-
- /* Name set */
- /* Check string length */
- if (EM_SAFE_STRLEN(p_name) > 0) {
- em_upper_string(p_name);
- (*param)->name = EM_SAFE_STRDUP(p_name);
- }
-
- em_trim_left(p_val);
- em_trim_right(p_val);
-
- if (!*p_val) {
- EM_DEBUG_LOG("Parameter value is NULL");
- return true;
- }
-
- if (EM_SAFE_STRLEN(p_val) > 0) {
- if ((p = strchr(p_val, '\"'))) {
- p_val = p + 1;
- if (!*p_val) return false;
- }
- if ((p = strchr(p_val, '\"')))
- *p = '\0';
-
- if (strncmp(p_name, "BOUNDARY", strlen("BOUNDARY")) != 0 && !strstr(p_name, "NAME"))
- em_upper_string(p_val);
-
- /* = ? ENCODING_TYPE ? B(Q) ? ENCODED_STRING ? */
- int err = EMAIL_ERROR_NONE;
- char *utf8_text = NULL;
-
- if (!(utf8_text = emcore_decode_rfc2047_text(p_val, &err)))
- EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_text failed [%d]", err);
- (*param)->value = utf8_text;
- }
- EM_DEBUG_FUNC_END();
- return true;
-}
-
-/* add a parameter to parameter lis */
-int emcore_mime_add_param_to_list(struct _parameter **param_list, struct _parameter *param, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("param_list[%p], param[%p]", param_list, *param_list);
- struct _parameter **t = param_list;
-
- while (*t && (*t)->next)
- *t = (*t)->next;
-
- if (*t)
- (*t)->next = param;
- else
- *t = param;
-
- return true;
-}
-
-/* get header value from MIME Part Heade */
-char *emcore_mime_get_header_value(struct _m_part_header *header, int type, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("header[%p], type[%d], err_code[%p]", header, type, err_code);
-
- struct _parameter *p = NULL;
- char *name = NULL;
-
- if (!header) {
- EM_DEBUG_EXCEPTION("header[%p], type[%d]", header, type);
-
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return NULL;
- }
-
- switch (type) {
- case CONTENT_TYPE:
- return header->type;
-
- case CONTENT_SUBTYPE:
- return header->subtype;
-
- case CONTENT_ENCODING:
- return header->encoding;
-
- case CONTENT_CHARSET:
- name = "CHARSET";
- p = header->parameter;
- break;
-
- case CONTENT_DISPOSITION:
- return header->disp_type;
-
- case CONTENT_NAME:
- name = "NAME";
- p = header->parameter;
- break;
-
- case CONTENT_FILENAME:
- name = "FILENAME";
- p = header->disp_parameter;
- break;
-
- case CONTENT_BOUNDARY:
- name = "BOUNDARY";
- p = header->parameter;
- break;
-
- case CONTENT_REPORT_TYPE:
- name = "REPORT-TYPE";
- p = header->parameter;
- break;
-
- case CONTENT_ID:
- return header->content_id;
-
- case CONTENT_LOCATION:
- return header->content_location;
-
- case CONTENT_SMIME_TYPE:
- name = "SMIME-TYPE";
- p = header->parameter;
- break;
-
- case CONTENT_PROTOCOL:
- name = "PROTOCOL";
- p = header->parameter;
- break;
-
- default:
- return NULL;
- }
-
- for (; p; p = p->next) {
- if (strcmp(p->name, name) == 0)
- break;
- }
-
- if (!p)
- return NULL;
- EM_DEBUG_FUNC_END();
- return p->value;
-}
-
/*
* decode body text (quoted-printable, base64)
* enc_type : encoding type (base64/quotedprintable)
@@ -1778,192 +295,6 @@ INTERNAL_FUNC int emcore_decode_body_text(char *enc_buf, int enc_len, int enc_ty
return EMAIL_ERROR_NONE;
}
-/* 1. if boundary is NULL, contnent has not multipart */
-/* 2. if boundary isn't NULL, content is from current line to the next found boundary */
-/* if next found boundary is the other part boundary ("--boundary"), return and set end_of_parsing to 1 */
-/* if next found boundary is the multipart ending boundary ("--boundary--"), return and set end_of_parsing to 0 */
-/* mode - SAVE_TYPE_SIZE : no saving (only hold content size */
-/* SAVE_TYPE_BUFFER : content is saved to buffer (holder is buffer */
-/* SAVE_TYPE_FILE : content is saved to temporary file (holder is file name */
-int emcore_mime_get_content_data(void *stream, int is_file, char *boundary_str, char *content_encoding, int *end_of_parsing, int mode, char **holder, int *size, void *callback, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN_SEC("stream[%p], is_file[%d], boundary_str[%s], content_encoding[%s], end_of_parsing[%p], mode[%d], holder[%p], size[%p], callback[%p], err_code[%p]", stream, is_file, boundary_str, content_encoding, end_of_parsing, mode, holder, size, callback, err_code);
-
- int encoding = ENC7BIT;
- int error = EMAIL_ERROR_NONE, ret = false;
- int fd = 0;
- int sz = 0;
-
- if ((mode == SAVE_TYPE_FILE || mode == SAVE_TYPE_BUFFER) && !holder)
- return false;
-
- if (holder)
- *holder = NULL;
-
- if (size)
- *size = 0;
-
- EM_DEBUG_LOG("get content");
-
- if (content_encoding) {
- switch (content_encoding[0]) {
- case 'Q':
- encoding = ENCQUOTEDPRINTABLE;
- break; /* qutoed-printabl */
- case 'B':
- if (content_encoding[1] == 'A') {
- encoding = ENCBASE64;
- break; /* base6 */
- }
- if (content_encoding[1] == 'I') {
- encoding = ENCBINARY;
- break; /* binar */
- }
- encoding = ENC7BIT;
- break;
- case '7':
- encoding = ENC7BIT;
- break; /* 7bi */
- case '8':
- encoding = ENC8BIT;
- break; /* 8bi */
- default:
- encoding = ENCOTHER;
- break; /* unknow */
- }
- }
-
- /* saving type is file */
- if (mode == SAVE_TYPE_FILE) {
- *holder = emcore_mime_get_save_file_name(&error);
-
- EM_DEBUG_LOG("holder[%s]", *holder);
-
- error = em_open(*holder, O_WRONLY|O_CREAT, 0644, &fd);
- if (error != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("holder em_open failed : holder is a filename that will be saved.");
- goto FINISH_OFF;
- }
- }
-
- if (is_file) {
- EM_DEBUG_LOG("from file");
- error = emcore_decode_body_text_from_file((FILE *)stream, boundary_str, encoding, mode, fd, holder, end_of_parsing, &sz);
- if (error != EMAIL_ERROR_NONE) {
- if (error != EMAIL_ERROR_NO_MORE_DATA) {
- EM_DEBUG_EXCEPTION("emcore_decode_body_text_from_file failed : [%d]", error);
- goto FINISH_OFF;
- }
- }
- } else {
- EM_DEBUG_LOG("from sock");
- error = emcore_decode_body_text_from_sock(stream, boundary_str, encoding, mode, fd, holder, end_of_parsing, &sz);
- if (error != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_decode_body_text_from_sock failed : [%d]", error);
- goto FINISH_OFF;
- }
- }
-
- ret = true;
-FINISH_OFF:
- if (err_code != NULL)
- *err_code = error;
-
- EM_SAFE_CLOSE (fd); /*prevent 32736*/
-
- if (ret) {
- if (size)
- *size = sz;
- }
-
- EM_DEBUG_FUNC_END("ret [%d], sz [%d]", ret, sz);
- return ret;
-}
-
-int emcore_mime_skip_content_data(void *stream,
- int is_file,
- char *boundary_str,
- int *end_of_parsing,
- int *size,
- void *callback,
- int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], is_file[%d], boundary_str[%s], end_of_parsing[%p], size[%p], callback[%p], err_code[%p]", stream, is_file, boundary_str, end_of_parsing, size, callback, err_code);
-
- char buf[MIME_LINE_LEN] = {0x00}, boundary[BOUNDARY_LEN], boundary_end[BOUNDARY_LEN];
- int sz = 0;
-
- if (size)
- *size = 0;
-
- EM_DEBUG_LOG(">>> skip content <<<<<<<<<<<<<");
-
- if (!boundary_str) { /* if no boundary, this content is from current line to end of all multipart */
- while (TRUE) {
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, err_code))) {
- *end_of_parsing = 1;
- if (size)
- *size = sz;
- return false;
- }
- sz += EM_SAFE_STRLEN(buf);
- }
- }
- else { /* if there boundary, this content is from current line to ending boundary */
- memset(boundary, 0x00, BOUNDARY_LEN);
- memset(boundary_end, 0x00, BOUNDARY_LEN);
-
- SNPRINTF(boundary, BOUNDARY_LEN, "--%s%s", boundary_str, CRLF_STRING);
- SNPRINTF(boundary_end, BOUNDARY_LEN, "--%s%s", boundary_str, "--\r\n");
-
- while (TRUE) {
-/* Several threads including event thd call it, don't delete comment
- if (!emcore_check_thread_status()) {
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_CANCELLED;
- return false;
- }
-*/
- if ((is_file == 0 && !emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, err_code)) ||
- (is_file == 1 && !emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, err_code))) {
- /* end of fil */
- *end_of_parsing = 1;
- if (size)
- *size = sz;
- return true;
- }
-
- if (!strcmp(buf, boundary)) { /* the other part started. the parsing of other part will be started */
- *end_of_parsing = 0;
- if (size)
- *size = sz;
- return true;
- }
- else if (!strcmp(buf, boundary_end)) { /* if ending boundary, the parsing of other multipart will be started */
- *end_of_parsing = 1;
- if (size)
- *size = sz;
- return true;
- }
-
- sz += EM_SAFE_STRLEN(buf);
- }
- }
-
- if (size)
- *size = sz;
- EM_DEBUG_FUNC_END();
- return true;
-}
-
/* get temporary file name */
char *emcore_mime_get_save_file_name(int *err_code)
{
@@ -2183,1612 +514,6 @@ void emcore_mime_free_mime(struct _m_mesg *mmsg)
EM_DEBUG_FUNC_END();
}
-/* get body-part in nested part */
-static PARTLIST *emcore_get_allnested_part_full(MAILSTREAM *stream, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- PART *part_child = body->nested.part;
-
- while (part_child) {
- section_list = emcore_get_body_full(stream, msg_uid, &part_child->body, cnt_info, err_code, section_list);
- part_child = part_child->next;
- }
-
- EM_DEBUG_FUNC_END();
- return section_list;
-}
-
-/* get body-part in alternative multiple part */
-static PARTLIST *emcore_get_alternative_multi_part_full(MAILSTREAM *stream, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- PART *part_child = body->nested.part;
-
- /* find the best sub part we can show */
- while (part_child) {
- section_list = emcore_get_body_full(stream, msg_uid, &part_child->body, cnt_info, err_code, section_list);
- part_child = part_child->next;
- }
-
- EM_DEBUG_FUNC_END("section_list[%p]", section_list);
- return section_list;
-}
-
-/* get body part in signed multiple part */
-static PARTLIST *emcore_get_signed_multi_part_full(MAILSTREAM *stream, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- PART *part_child = body->nested.part;
-
- /* find the best sub part we can show */
- while (part_child) {
- section_list = emcore_get_body_full(stream, msg_uid, &part_child->body, cnt_info, err_code, section_list);
- part_child = part_child->next;
- }
-
- EM_DEBUG_FUNC_END();
- return section_list;
-}
-
-/* get body part in encrypted multiple part */
-static PARTLIST *emcore_get_encrypted_multi_part_full(MAILSTREAM *stream, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- /* "protocol" = "application/pgp-encrypted */
- EM_DEBUG_FUNC_END();
- return section_list;
-}
-
-/* get body part in multiple part */
-static PARTLIST *emcore_get_multi_part_full(MAILSTREAM *stream, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- switch (body->subtype[0]) {
- case 'A': /* ALTERNATIV */
- return section_list = emcore_get_alternative_multi_part_full(stream, msg_uid, body, cnt_info, err_code, section_list);
-
- case 'S': /* SIGNE */
- return section_list = emcore_get_signed_multi_part_full(stream, msg_uid, body, cnt_info, err_code, section_list);
-
- case 'E': /* ENCRYPTE */
- return section_list = emcore_get_encrypted_multi_part_full(stream, msg_uid, body, cnt_info, err_code, section_list);
-
- default: /* process all unknown as MIXED (according to the RFC 2047 */
- return section_list = emcore_get_allnested_part_full(stream, msg_uid, body, cnt_info, err_code, section_list);
- }
- EM_DEBUG_FUNC_END();
-}
-
-
-PARTLIST* emcore_get_body_full(MAILSTREAM *stream, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
- char content_type_buffer[512] = { 0, };
-
- if (!stream || !body || !cnt_info) {
- EM_DEBUG_EXCEPTION("stream[%p], msg_uid[%d], body[%p], cnt_info[%p]", stream, msg_uid, body, cnt_info);
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- EM_DEBUG_FUNC_END();
- return NULL;
- }
-
- switch (body->type) {
- case TYPEMULTIPART:
- section_list = emcore_get_multi_part_full(stream, msg_uid, body, cnt_info, err_code, section_list);
- EM_DEBUG_FUNC_END("section_list [%p]", section_list);
- return section_list;
-
- case TYPEMESSAGE:
- break;
-
- case TYPETEXT:
- case TYPEAPPLICATION:
- case TYPEAUDIO:
- case TYPEIMAGE:
- case TYPEVIDEO:
- case TYPEMODEL:
- case TYPEOTHER:
-
- /* Form list of attachment followed by list of inline images */
- if (body->id || body->location || body->disposition.type) {
-
- char filename[512] = {0, };
- struct attachment_info *current_ai = NULL;
- struct attachment_info *prev_ai = NULL;
- struct attachment_info *ai = NULL;
-
- if (emcore_get_file_pointer(body, true, filename, cnt_info, (int*)NULL) < 0)
- EM_DEBUG_EXCEPTION("emcore_get_file_pointer failed");
- else {
- /* To form list of attachment info - Attachment list followed by inline attachment list */
- current_ai = cnt_info->file;
-
- EM_DEBUG_LOG("current_ai - %p", current_ai);
-
- ai = em_malloc(sizeof(struct attachment_info));
- if (ai == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
- if(err_code)
- *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
- return NULL;
- }
-
- if (body->disposition.type != NULL && ((body->disposition.type[0] == 'a') || (body->disposition.type[0] == 'A'))) {
- ai->type = ATTACHMENT; /* attachment */
- } else {
- if ((body->id) || (body->location) || ((body->disposition.type != NULL) && ((body->disposition.type[0] == 'i') || (body->disposition.type[0] == 'I'))))
- ai->type = INLINE_ATTACHMENT; /* inline contents */
- else
- ai->type = ATTACHMENT; /* attachment */
- }
-
- ai->name = EM_SAFE_STRDUP(filename);
- ai->size = body->size.bytes;
- ai->content_id = EM_SAFE_STRDUP(body->id);
- if (emcore_get_content_type_from_mail_bodystruct(body, 512, content_type_buffer) == EMAIL_ERROR_NONE)
- ai->attachment_mime_type = EM_SAFE_STRDUP(content_type_buffer);
-
-#ifdef __ATTACHMENT_OPTI__
- ai->encoding = body->encoding;
- if (body->sparep)
- ai->section = EM_SAFE_STRDUP(body->sparep);
-
- EM_DEBUG_LOG("Encoding - %d Section No - %s ", ai->encoding, ai->section);
-#endif
-
- EM_DEBUG_LOG_SEC("Type[%d], Name[%s], Path[%s] ", ai->type, ai->name, ai->save);
- if (body->type == TYPEAPPLICATION) {
- if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_OBJECT))
- ai->drm = EMAIL_ATTACHMENT_DRM_OBJECT;
- else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_RIGHTS))
- ai->drm = EMAIL_ATTACHMENT_DRM_RIGHTS;
- else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_DCF))
- ai->drm = EMAIL_ATTACHMENT_DRM_DCF;
- else if (!strcasecmp(body->subtype, "pkcs7-mime"))
- cnt_info->grab_type = cnt_info->grab_type | GRAB_TYPE_ATTACHMENT;
- }
-
- if (current_ai == NULL) {
- cnt_info->file = ai;
- } else {
- while(current_ai->next != NULL) {
- if (ai->type == ATTACHMENT) {
- if (current_ai->type == INLINE_ATTACHMENT)
- break;
- }
-
- prev_ai = current_ai;
- current_ai = current_ai->next;
- }
-
- EM_DEBUG_LOG("current_ai:[%p], prev_ai:[%p]", current_ai, prev_ai);
-
- if (ai->type == ATTACHMENT) {
- if (prev_ai == NULL) {
- cnt_info->file = ai;
- ai->next = current_ai;
- } else {
- prev_ai->next = ai;
- ai->next = current_ai;
- }
- } else {
- current_ai->next = ai;
- }
- }
- }
- }
-
- /* if (cnt_info->grab_type == GRAB_TYPE_ATTACHMENT */
- if (cnt_info->grab_type & GRAB_TYPE_ATTACHMENT) {
- if (((body->disposition.type != NULL) && ((body->disposition.type[0] == 'a') || (body->disposition.type[0] == 'A'))) && (cnt_info->file != NULL)) {
- PARAMETER *param = NULL;
- char *fn = NULL;
-
- param = body->parameter;
-
- while (param) {
- if (!strcasecmp(param->attribute, "NAME")) {
- fn = EM_SAFE_STRDUP(param->value);
- break;
- }
- if (!strcasecmp(param->attribute, "FILENAME")) {
- fn = EM_SAFE_STRDUP(param->value);
- break;
- }
- param = param->next;
- }
- if ((fn != NULL)&& (!strcmp(fn, cnt_info->file->name)) && (body->size.bytes == cnt_info->file->size)) /* checks to zero in on particular attachmen */ {
- section_list = emcore_add_node(section_list, body);
- if (section_list == NULL) {
- EM_DEBUG_EXCEPTION("adding node to section list failed");
- if(err_code)
- *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
- EM_SAFE_FREE(fn);
- return NULL;
- }
- else {
- EM_SAFE_FREE(fn);
- EM_DEBUG_FUNC_END("section_list [%p]", section_list);
- return section_list; /* single attachment download, so if a match found break the recursion */
- }
- }
- EM_SAFE_FREE(fn);
- }
- }
- else {
- /* get a section list which has only plain, html and inline */
- if (!((body->disposition.type != NULL) && ((body->disposition.type[0] == 'a') || (body->disposition.type[0] == 'A'))))/* if the body not an attachmen */ {
- section_list = emcore_add_node(section_list, body);
- if (section_list == NULL) {
- EM_DEBUG_EXCEPTION("adding node to section list failed");
- if(err_code)
- *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
- return NULL;
- }
- }
- }
-
- break;
-
- default:
- break;
- }
-
- if(section_list == NULL && err_code != NULL) {
- *err_code = EMAIL_ERROR_ON_PARSING;
- }
-
- EM_DEBUG_FUNC_END("section_list [%p]", section_list);
- return section_list;
-}
-
-INTERNAL_FUNC int emcore_get_body_part_list_full(MAILSTREAM *stream, int msg_uid, int account_id, int mail_id, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST *section_list, int event_handle)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- if (!stream || !body || !cnt_info) {
- EM_DEBUG_EXCEPTION("stream[%p], msg_uid[%d], body[%p], cnt_info[%p]", stream, msg_uid, body, cnt_info);
-
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return FAILURE;
- }
- section_list = emcore_get_body_full(stream, msg_uid, body, cnt_info, err_code, section_list);
-
- if (section_list == NULL) {
- /* assumed at least one body part exist */
- if(err_code)
- EM_DEBUG_EXCEPTION("emcore_get_body_full failed [%d]", *err_code);
- else
- EM_DEBUG_EXCEPTION("emcore_get_body_full failed");
- return FAILURE;
- }
-
- if (emcore_get_body_part_imap_full(stream, msg_uid, account_id, mail_id, section_list, cnt_info, err_code, event_handle) < 0) {
- EM_DEBUG_EXCEPTION("emcore_get_body_part_imap_full failed");
- emcore_free_section_list(section_list);
- return FAILURE;
- }
- emcore_free_section_list(section_list);
- return SUCCESS;
-}
-
-static int emcore_write_response_into_file(char *filename, char *write_mode, char *encoded, int encoding_type, char *subtype, int account_id, int mail_id, int *err)
-{
- EM_DEBUG_FUNC_BEGIN();
- int ret = false;
- int error = EMAIL_ERROR_NONE;
- int not_found = true;
- int encoded_len = 0;
- int written_bytes = 0;
- unsigned long decoded_len = 0;
- char *decoded = NULL;
- char *decoded_temp = NULL;
- char save_file_name[MAX_PATH+1] = {0, };
- char html_cid_path[MAX_PATH+1] = {0, };
- FILE *fp = NULL;
- PARAMETER *param = NULL;
- PARAMETER *param1 = NULL;
-
-
- if (!encoded || !filename || !write_mode) {
- EM_DEBUG_EXCEPTION("Invalid Param ");
- if( err ) *err = EMAIL_ERROR_INVALID_PARAM; /* prevent 28347 */
- return false;
- }
-
-
- EM_DEBUG_LOG("Encoded buffer length [%d]", EM_SAFE_STRLEN(encoded));
- encoded_len = EM_SAFE_STRLEN(encoded);
-
- EM_DEBUG_LOG("encoding_type [%d]", encoding_type);
- switch (encoding_type) {
- case ENCQUOTEDPRINTABLE: {
- unsigned char *orignal = (unsigned char *)g_strdup_printf("%s\r\n", encoded);
- decoded = (char *)rfc822_qprint(orignal, encoded_len + 2, &decoded_len);
- g_free(orignal);
- break;
- }
-
- case ENCBASE64:
- decoded = (char *)rfc822_base64((unsigned char *)encoded, encoded_len, &decoded_len);
- if (!decoded) {
- gsize dlen = 0;
- EM_DEBUG_LOG("rfc822_base64 decode failed");
- decoded = (char *)g_base64_decode(encoded, &dlen);
- decoded_len = (unsigned long)dlen;
- }
- break;
-
- default: {
- unsigned char *orignal = (unsigned char *)g_strdup_printf("%s\r\n", encoded);
- decoded = em_malloc(encoded_len + 3); /*prevent 28347*/
- if(!decoded) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- g_free(orignal);
- goto FINISH_OFF;
- }
- memcpy(decoded, orignal, encoded_len + 3);
- decoded_len = encoded_len + 2;
- g_free(orignal);
- }
- break;
- }
-
- if (decoded != NULL) {
- EM_DEBUG_LOG("Decoded Length [%d] " , decoded_len);
- EM_DEBUG_LOG_SEC("filename [%s] " , filename);
-
- error = em_fopen(filename, write_mode, &fp);
- if (error != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION_SEC("em_fopen failed - %s", filename);
- goto FINISH_OFF;
- }
-
- if (subtype && subtype[0] == 'H') {
- char body_inline_id[512] = {0};
-
- while (strstr(decoded, "cid:")) {
- EM_DEBUG_LOG("Found cid:");
- EM_DEBUG_LOG("g_inline_count : [%d]", g_inline_count);
- not_found = true;
- if (g_inline_count) {
- BODY *body_inline = NULL;
- int inline_count = 0;
- char *decoded_content_id = NULL;
- while (inline_count < g_inline_count && g_inline_list[inline_count]) {
- EM_DEBUG_LOG("inline_count [%d], g_inline_count [%d]", inline_count, g_inline_count);
- body_inline = g_inline_list[inline_count];
- param = body_inline->disposition.parameter;
- param1 = body_inline->parameter;
-
- memset(body_inline_id, 0x00, 512);
-
- if (body_inline->id && EM_SAFE_STRLEN(body_inline->id) > 0) { /*prevent 27454*/
- EM_DEBUG_LOG_SEC("body_inline->id - %s", body_inline->id);
- EM_DEBUG_LOG("param - %p param1 - %p", param, param1);
- decoded_content_id = strstr(decoded, "cid:");
-
- if (body_inline->id[0] == '<')
- memcpy(body_inline_id, body_inline->id + 1, EM_SAFE_STRLEN(body_inline->id) - 2);
- else
- memcpy(body_inline_id, body_inline->id , EM_SAFE_STRLEN(body_inline->id));
-
- /* Handle the 'space__content_id(example : (yahoo : content_id: __abcdefgh__ijkl...) */
- em_trim_left(body_inline_id);
- EM_DEBUG_LOG_SEC("Inline body_inline_id [%s] ", body_inline_id);
-
- if ((param || param1) && (decoded_content_id && 0 == strncmp(body_inline_id , decoded_content_id + strlen("cid:"), EM_SAFE_STRLEN(body_inline_id)))) {
- EM_DEBUG_LOG(" Inline CID Found ");
-
- memset(save_file_name, 0x00, MAX_PATH);
- memset(html_cid_path, 0x00, MAX_PATH);
-
- /* Finding 'filename' attribute from content inf */
- emcore_get_file_pointer(body_inline, true, save_file_name, NULL, &error);
-
- if (EM_SAFE_STRLEN(save_file_name) > 0) {
- /* Content ID will be replaced with its file name in html */
- memcpy(html_cid_path, decoded_content_id , strlen("cid:") + EM_SAFE_STRLEN(body_inline_id));
-
- EM_DEBUG_LOG_SEC("Replacing %s with %s ", html_cid_path, save_file_name);
- if ((decoded_temp = em_replace_string(decoded, html_cid_path, save_file_name))) {
- EM_SAFE_FREE(decoded);
- decoded = decoded_temp;
- decoded_len = EM_SAFE_STRLEN(decoded);
- EM_DEBUG_LOG("Decoded Length [%d] ", decoded_len);
- not_found = false;
- /* only_body_download = false */
- break;
- }
- }
- }
- }
- inline_count++;
- }
- }
-
- if (not_found) {
- EM_DEBUG_LOG("not_found is true");
- memset(body_inline_id, 0x00, sizeof(body_inline_id));
- decoded_temp = em_replace_string_with_split_file_path(decoded, "cid:", body_inline_id);
- if (decoded_temp) {
- /* only_body_download = false */
- /* EM_DEBUG_LOG(">>>> decoded_temp 2 [ %s ] ", decoded_temp) */
- EM_SAFE_FREE(decoded);
- decoded = decoded_temp;
- decoded_len = EM_SAFE_STRLEN(decoded);
- EM_DEBUG_LOG("Decoded Length [%d] ", decoded_len);
- }
- }
- }
- g_inline_count = 0;
- EM_SAFE_FREE(g_inline_list);
- }
-
- EM_DEBUG_LOG("Trying to fwrite. decoded_len [%d]", decoded_len);
-
- if (decoded_len > 0 && fwrite(decoded, decoded_len, 1, fp) == 0) {
- EM_DEBUG_EXCEPTION("Error Occured while writing. fwrite(\"%s\") failed. decoded_len [%d], written_bytes [%d] ", decoded, decoded_len, written_bytes);
- error = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG("fwrite succeed");
- }
- else {
- EM_DEBUG_EXCEPTION("Error Occured while decoding ");
- goto FINISH_OFF;
- }
-
- ret = true;
-
-FINISH_OFF:
-
- if (err)
- *err = error;
-
- EM_SAFE_FREE(decoded);
-
- if (fp != NULL)
- fclose(fp);
-
- EM_DEBUG_FUNC_END();
-
- return ret;
-}
-
-
-static BODY *emcore_select_body_structure_from_section_list(PARTLIST *section_list, char *section)
-{
- PARTLIST *temp = section_list;
- BODY *body = NULL;
-
- while (temp != NULL) {
- body = temp->body;
- if (!strcmp(section, body->sparep))
- return body;
- temp = (PARTLIST *)temp->next;
- }
- return body;
-}
-
-
-#define MAX_WRITE_BUFFER_SIZE 0 /* should be tuned */
-
-static int imap_mail_write_body_to_file(MAILSTREAM *stream, int account_id, int mail_id, int is_attachment, char *filepath, int uid, char *section, int encoding, int *decoded_total, char *section_subtype, int *err_code)
-{
- EM_PROFILE_BEGIN(imapMailWriteBodyToFile);
- EM_DEBUG_FUNC_BEGIN_SEC("stream[%p], filepath[%s], uid[%d], section[%s], encoding[%d], decoded_total[%p], err_code[%p]",
- stream, filepath, uid, section, encoding, decoded_total, err_code);
-
- int ret = false;
- int err = EMAIL_ERROR_NONE;
- FILE *fp = NULL;
- IMAPLOCAL *imaplocal = NULL;
- char tag[16], command[64];
- char *response = NULL;
- char *decoded = NULL;
- int body_size = 0, total = 0;
- char *file_id = NULL;
- char server_uid[129] = { 0, };
- char *filename = NULL;
- int server_response_yn = 0;
- unsigned char encoded[DOWNLOAD_MAX_BUFFER_SIZE] = {0, };
- unsigned char test_buffer[LOCAL_MAX_BUFFER_SIZE] = {0, };
- int flag_first_write = true;
- int preline_len = 0;
- int nskip = 0;
- char *concat_encoded = NULL;
- char *new_response = NULL;
- char *tag_position = NULL;
-
- if (!stream || !filepath || !section) {
- EM_DEBUG_EXCEPTION_SEC("stream[%p], filepath[%s], uid[%d], section[%s], encoding[%d], decoded_total[%p]",
- stream, filepath, uid, section, encoding, decoded_total);
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
-/* don't delete the comment. several threads including event thread call it
- FINISH_OFF_IF_CANCELED;
-*/
-
- err = em_fopen(filepath, "wb+", &fp);
- if (err != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION_SEC("fopen failed - %s : [%d]", filepath, err);
- goto FINISH_OFF;
- }
-
- imaplocal = stream->local;
-
- if (!imaplocal->netstream) {
- EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected... %p", imaplocal->netstream);
- err = EMAIL_ERROR_INVALID_STREAM;
- goto FINISH_OFF;
- }
-
- memset(tag, 0x00, sizeof(tag));
- memset(command, 0x00, sizeof(command));
-
- SNPRINTF(tag, sizeof(tag), "%08lx", 0xffffffff & (stream->gensym++));
- SNPRINTF(command, sizeof(command), "%s UID FETCH %d BODY.PEEK[%s]\015\012", tag, uid, section);
- EM_DEBUG_LOG("[IMAP4] >>> [%s]", command);
-
- /* send command : get msgno/uid for all message */
- if (!net_sout(imaplocal->netstream, command, (int)EM_SAFE_STRLEN(command))) {
- EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMAIL_ERROR_CONNECTION_BROKEN;
- goto FINISH_OFF;
- }
-
- char *p_stream = NULL;
- char *p_content = NULL;
-
- while (imaplocal->netstream) {
-
-/* don't delete the comment. several threads including event thread call this func
- if (!emcore_check_thread_status()) {
- EM_DEBUG_LOG("Canceled...");
- imaplocal->netstream = NULL;
- err = EMAIL_ERROR_CANCELLED;
- goto FINISH_OFF;
- }
-*/
- /* receive response */
- if (!(response = net_getline(imaplocal->netstream))) {
- EM_DEBUG_EXCEPTION("net_getline failed...");
- err = EMAIL_ERROR_INVALID_RESPONSE;
- goto FINISH_OFF;
- }
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG("recv[%s]", response);
-#endif
-
- /* start of response */
- if (response[0] == '*' && !server_response_yn) {
- p_stream = strstr(response, "BODY[");
- if (p_stream) {
- server_response_yn = 1;
- p_stream += strlen("BODY[");
- p_content = p_stream;
-
- while (*p_content != ']')
- p_content++;
-
- *p_content = '\0';
-
- /* check correct section */
- if (strcmp(section, p_stream)) {
- EM_DEBUG_LOG("Invalid response of section");
- err = EMAIL_ERROR_INVALID_RESPONSE;
- goto FINISH_OFF;
- }
-
- /* get body size */
- p_stream = strstr(p_content+1, " {");
- if (p_stream) {
- p_stream += strlen(" {");
- p_content = p_stream;
-
- while (isdigit(*p_content))
- p_content++;
-
- *p_content = '\0';
-
- body_size = atoi(p_stream);
- } else { /* no body length is replied */
- /* seek the termination of double quot */
- p_stream = strstr(p_content+1, " \"");
- if (p_stream) {
- char *t = NULL;
- p_stream += strlen(" \"");
- t = strstr(p_stream, "\"");
- if (t) {
- body_size = t - p_stream;
- *t = '\0';
- EM_DEBUG_LOG("Body : start[%p] end[%p] : body[%s]", p_stream, t, p_stream);
- /* need to decode */
- EM_SAFE_FREE(response);
- response = EM_SAFE_STRDUP(p_stream);
- } else {
- err = EMAIL_ERROR_INVALID_RESPONSE;
- goto FINISH_OFF;
- }
- } else {
- err = EMAIL_ERROR_INVALID_RESPONSE;
- goto FINISH_OFF;
- }
- }
-
- /* sending progress noti to application.
- 1. mail_id
- 2. file_id
- 3. bodysize
- */
- parse_file_path_to_filename(filepath, &file_id);
-
- filename = file_id;
- snprintf(server_uid, sizeof(server_uid), "%d", uid);
-
- EM_DEBUG_LOG_SEC("file_id [%s]", file_id);
- EM_DEBUG_LOG_SEC("filename [%p]-[%s]", filename, filename);
- EM_DEBUG_LOG("body_size [%d]", body_size);
- EM_DEBUG_LOG("server_uid [%s]", server_uid);
- EM_DEBUG_LOG("mail_id [%d]", mail_id);
-
-/* don't delete the comment. several threads including event thread call it
- if (!emcore_check_thread_status()) {
- EM_DEBUG_LOG("Canceled...");
- imaplocal->netstream = NULL;
- err = EMAIL_ERROR_CANCELLED;
- goto FINISH_OFF;
- }
-*/
- if (is_attachment) {
- EM_DEBUG_LOG("Attachment number [%d]", is_attachment);
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, filename, is_attachment, 0))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
- _imap4_download_noti_interval_value = body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
- _imap4_total_body_size = body_size;
- } else {
- if (multi_part_body_size) {
- EM_DEBUG_LOG("Multipart body size is [%d]", multi_part_body_size);
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, filename, multi_part_body_size, 0))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- _imap4_download_noti_interval_value = multi_part_body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
- /* _imap4_total_body_size should be set before calling this functio */
- /* _imap4_total_body_size */
- } else {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, filename, body_size, 0))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- _imap4_download_noti_interval_value = body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
- _imap4_total_body_size = body_size;
- }
- }
-
- /* remove new lines */
- do {
- EM_SAFE_FREE(response);
- if (!(response = net_getline(imaplocal->netstream))) {
- EM_DEBUG_EXCEPTION("net_getline failed...");
- err = EMAIL_ERROR_INVALID_RESPONSE;
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG("response:%s", response);
- if (EM_SAFE_STRLEN(response) == 0) {
- EM_DEBUG_LOG("Skip newline !!");
- nskip++;
- } else {
- EM_SAFE_FREE (new_response); /* detected by valgrind */
- new_response = g_strconcat(response, "\r\n", NULL);
- EM_SAFE_FREE(response);
- break;
- }
- } while(1);
-
- preline_len = EM_SAFE_STRLEN(new_response);
- EM_DEBUG_LOG("preline_len : %d", preline_len);
-
- if (body_size - preline_len - nskip*2 < 0)
- continue;
-
- if ((body_size - preline_len -nskip*2) == 0) {
- /* 1 line content */
- if (!emcore_write_response_into_file(filepath, "wb+", new_response, encoding, section_subtype, account_id, mail_id, &err)) {
- EM_DEBUG_EXCEPTION("write_response_into_file failed [%d]", err);
- goto FINISH_OFF;
- }
-
- total = preline_len;
- EM_DEBUG_LOG("total = %d", total);
- EM_DEBUG_LOG_SEC("write_response_into_file successful %s.....", filename);
-
- /* In some situation, total_encoded_len includes the length of dummy bytes. So it might be greater than body_size */
-
- _imap4_received_body_size += total;
-// EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : received_body[%d] / total_body[%d] = %d %% Completed.",
-// _imap4_received_body_size, _imap4_total_body_size, 100*_imap4_received_body_size/_imap4_total_body_size);
-
- if (((_imap4_last_notified_body_size + _imap4_download_noti_interval_value) <= _imap4_received_body_size)
- || (_imap4_received_body_size >= _imap4_total_body_size)) {
-
- _imap4_last_notified_body_size = _imap4_received_body_size;
-
- if (is_attachment) {
- if (_imap4_total_body_size && !emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, filename, is_attachment, 100 *total/body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
- } else {
- if (multi_part_body_size) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- } else {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- }
- }
- }
- }
- else if (body_size - preline_len - nskip*2 < DOWNLOAD_MAX_BUFFER_SIZE) {
- memset(encoded, 0x00, sizeof(encoded));
- if (net_getbuffer(imaplocal->netstream, body_size - preline_len - nskip*2, (char *)encoded) <= 0) {
- EM_DEBUG_EXCEPTION("net_getbuffer failed...");
- err = EMAIL_ERROR_NO_RESPONSE;
- goto FINISH_OFF;
- }
-
- concat_encoded = g_strconcat(new_response, encoded, NULL);
- memset(encoded, 0x00, sizeof(encoded));
- memcpy(encoded, concat_encoded, EM_SAFE_STRLEN(concat_encoded));
- EM_SAFE_FREE(concat_encoded);
- EM_SAFE_FREE(new_response);
- if (!emcore_write_response_into_file(filepath, "wb+", (char *)encoded, encoding, section_subtype, account_id, mail_id, &err)) {
- EM_DEBUG_EXCEPTION("write_response_into_file failed [%d]", err);
- goto FINISH_OFF;
- }
-
- total = EM_SAFE_STRLEN((char *)encoded);
- EM_DEBUG_LOG("total = %d", total);
- EM_DEBUG_LOG_SEC("write_response_into_file successful %s.....", filename);
-
- /* In some situation, total_encoded_len includes the length of dummy bytes. So it might be greater than body_size */
-
- _imap4_received_body_size += total;
-
- EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : received_body[%d] / total_body[%d] = %d %% Completed.",
- _imap4_received_body_size, _imap4_total_body_size, 100*_imap4_received_body_size/_imap4_total_body_size);
-
- if (((_imap4_last_notified_body_size + _imap4_download_noti_interval_value) <= _imap4_received_body_size)
- || (_imap4_received_body_size >= _imap4_total_body_size)) {
-
- _imap4_last_notified_body_size = _imap4_received_body_size;
-
- if (is_attachment) {
- if (_imap4_total_body_size && !emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, filename, is_attachment, 100 *total/body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
- } else {
- if (multi_part_body_size) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- } else {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- }
- }
- }
- }
- else {
- int remain_body_size = body_size - preline_len - nskip*2;
- int x = 0;
- int nsize = 0;
- total += preline_len + nskip*2;
- _imap4_received_body_size += preline_len + nskip*2;
-
- memset(test_buffer, 0x00, sizeof(test_buffer));
-
- while (remain_body_size > 0 && (total < body_size)) {
-
- memset(test_buffer, 0x00, sizeof(test_buffer));
-
- if (encoding == ENCBASE64)
- x = (sizeof(encoded)/preline_len)*preline_len; /* to solve base64 decoding pro */
- else
- x = sizeof(encoded)-1;
-
- if (new_response) {
- strncat((char *)test_buffer, (char *)new_response, preline_len);
- EM_SAFE_FREE(new_response);
- }
-
- while (remain_body_size > 0 && (total < body_size) && ((EM_SAFE_STRLEN((char *)test_buffer) + x) < sizeof(test_buffer))) {
-
- memset(encoded, 0x00, sizeof(encoded));
-
- if (net_getbuffer(imaplocal->netstream, (long)x, (char *)encoded) <= 0) {
- EM_DEBUG_EXCEPTION("net_getbuffer failed...");
- err = EMAIL_ERROR_NO_RESPONSE;
- goto FINISH_OFF;
- }
-
- nsize = EM_SAFE_STRLEN((char *)encoded);
- remain_body_size = remain_body_size - nsize;
- strncat((char *)test_buffer, (char *)encoded, nsize);
- total = total + nsize;
- _imap4_received_body_size += nsize;
- EM_DEBUG_LOG("nsize : %d", nsize);
- EM_DEBUG_LOG("remain_body_size : %d", remain_body_size);
- EM_DEBUG_LOG("total : %d", total);
- EM_DEBUG_LOG("imap_received_body_size : %d", _imap4_received_body_size);
-
- if (!(remain_body_size/x) && remain_body_size%x)
- x = remain_body_size%x;
-
- /* notify event every 5% increase */
- if (((_imap4_last_notified_body_size + _imap4_download_noti_interval_value) <= _imap4_received_body_size)
- || (_imap4_received_body_size >= _imap4_total_body_size)) {
-
- /* In some situation, total_encoded_len includes the length of dummy bytes.
- * So it might be greater than body_size */
- if (total > body_size)
- _imap4_received_body_size = body_size;
-
-
-/* don't delete the comment. it can be called by several threads
- if (!emcore_check_thread_status()) {
- EM_DEBUG_LOG("Canceled...");
- imaplocal->netstream = NULL;
- err = EMAIL_ERROR_CANCELLED;
- goto FINISH_OFF;
- }
-
-*/ EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY : Total[%d] / [%d] = %d %% Completed.\n", total, body_size, 100*total/body_size);
-
- if (((_imap4_last_notified_body_size + _imap4_download_noti_interval_value) <= _imap4_received_body_size)
- || (_imap4_received_body_size >= _imap4_total_body_size)) {
-
- _imap4_last_notified_body_size = _imap4_received_body_size;
-
- if (is_attachment) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, filename, is_attachment, 100*total/body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
- } else {
- if (multi_part_body_size) {
- /* EM_DEBUG_LOG("DOWNLOADING.......... : Multipart body size is [%d]", multi_part_body_size) */
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- } else {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, filename, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- }
- }
- }
- }
- }
-
- if (flag_first_write == true) {
- if (!emcore_write_response_into_file(filepath, "wb+", (char *)test_buffer, encoding, section_subtype, account_id, mail_id, &err)) {
- EM_DEBUG_EXCEPTION_SEC("write_response_into_file %s failed [%d]", filepath, err);
- goto FINISH_OFF;
- }
- flag_first_write = false;
- } else {
- if (!emcore_write_response_into_file(filepath, "ab+", (char *)test_buffer, encoding, section_subtype, account_id, mail_id, &err)) /* append */ {
- EM_DEBUG_EXCEPTION_SEC("write_response_into_file %s failed [%d]", filepath, err);
- goto FINISH_OFF;
- }
- }
- EM_DEBUG_LOG("%d has been written", EM_SAFE_STRLEN((char *)test_buffer));
- }
- }
- } else {
- err = EMAIL_ERROR_INVALID_RESPONSE;
- goto FINISH_OFF;
- }
- }
- else if ((tag_position = g_strrstr(response, tag))) /* end of response */ {
- if (!strncmp(tag_position + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
- EM_SAFE_FREE(response);
- } else { /* 'NO' or 'BAD */
- err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;
- goto FINISH_OFF;
- }
- break;
- }
- else if (!strcmp(response, ")")) {
- /* The end of response which contains body information */
- }
- } /* while (imaplocal->netstream) */
-
- if (decoded_total != NULL)
- *decoded_total = total;
-
- ret = true;
-
-FINISH_OFF:
- EM_SAFE_FREE(decoded);
- EM_SAFE_FREE(response);
- EM_SAFE_FREE (file_id); /* detected by valgrind */
- EM_SAFE_FREE (new_response); /* detected by valgrind */
-
- if (fp != NULL)
- fclose(fp);
-
- if (ret == false) { /* delete temp file */
- struct stat temp_file_stat;
- if (filepath && stat(filepath, &temp_file_stat) == 0)
- remove(filepath);
- }
-
- if (err_code != NULL)
- *err_code = err;
-
- EM_PROFILE_END(imapMailWriteBodyToFile);
-
- return ret;
-}
-
-static int emcore_get_body_part_imap_full(MAILSTREAM *stream, int msg_uid, int account_id, int mail_id, PARTLIST *section_list, struct _m_content_info *cnt_info, int *err_code, int event_handle)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, section_list, cnt_info, err_code);
-
- int err = EMAIL_ERROR_NONE;
- char sections[IMAP_MAX_COMMAND_LENGTH] = {0,};
- IMAPLOCAL *imaplocal = NULL;
- char tag[16] = {0,};
- char command[IMAP_MAX_COMMAND_LENGTH] = {0,};
- char section[16] = {0,};
- char *response = NULL;
- BODY *body = NULL;
- int server_response_yn = 0;
- int body_size = 0;
- char *buf = NULL;
- char filename[512] = {0,};
- int return_value = 0;
- int encoding = 0;
- unsigned char encoded[DOWNLOAD_MAX_BUFFER_SIZE] = {0,};
- unsigned char test_buffer[LOCAL_MAX_BUFFER_SIZE] = {0,};
- struct attachment_info *ai = NULL;
- int i = 0;
- int total = 0;
- int flag_first_write = 1;
- int imap4_total_body_download_progress = 0;
- char *tag_position = NULL;
-
- if (!(imaplocal = stream->local) || !imaplocal->netstream || !section_list || !cnt_info) {
- EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected...");
- err = EMAIL_ERROR_INVALID_PARAM;
- return_value = -1;
- goto FINISH_OFF;
- }
-
- PARTLIST *temp = section_list;
-
- if (cnt_info->grab_type == GRAB_TYPE_ATTACHMENT) {
- /* to download attachment */
- body = temp->body;
- if (body->sparep != NULL) {
- snprintf(sections, sizeof(sections), "BODY.PEEK[%s]", (char *)body->sparep);
- } else {
- EM_DEBUG_EXCEPTION("body->sparep can not be null. ");
- return_value = -1;
- goto FINISH_OFF;
- }
- } else {
- while (temp != NULL) {
- char t[64] = {0,};
- body = temp->body;
-
- if ((body->type == TYPETEXT) || (body->id != NULL) || ((body->disposition.type != NULL) && ((body->disposition.type[0] == 'i') || (body->disposition.type[0] == 'I')))) {
- snprintf(t, sizeof(t), "BODY.PEEK[%s] ", (char *)body->sparep); /* body parts seperated by period */
- if (EM_SAFE_STRLEN(sections) + EM_SAFE_STRLEN(t) < sizeof(sections))
- strcat(sections, t);
- else {
- EM_DEBUG_EXCEPTION("Too many body parts. IMAP command may cross 2000bytes.");
- break;
- }
- }
- temp = (PARTLIST *)temp->next;
- }
- }
-
- if (EM_SAFE_STRLEN (sections) > 0 && sections[EM_SAFE_STRLEN(sections)-1] == ' ') { /*prevent 32317*/
- sections[EM_SAFE_STRLEN(sections)-1] = '\0';
- }
-
- EM_DEBUG_LOG("sections <%s>", sections);
- SNPRINTF(tag, sizeof(tag), "%08lx", 0xffffffff & (stream->gensym++));
- SNPRINTF(command, sizeof(command), "%s UID FETCH %d (%s)\015\012", tag, msg_uid, sections);
- EM_DEBUG_LOG("command <%s>", command);
-
- /* send command : get msgno/uid for all message */
- if (!net_sout(imaplocal->netstream, command, (int)EM_SAFE_STRLEN(command))) {
- EM_DEBUG_EXCEPTION("net_sout failed...");
- err = EMAIL_ERROR_CONNECTION_BROKEN;
- return_value = -1;
- goto FINISH_OFF;
- }
-
- while (imaplocal->netstream) {
-
- /* receive response */
- if (!(response = net_getline(imaplocal->netstream))) {
- EM_DEBUG_EXCEPTION("net_getline failed...");
- err = EMAIL_ERROR_INVALID_RESPONSE;
- return_value = -1;
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG("response :%s", response);
-
- if (strstr(response, "BODY[")) {
-
- if (!server_response_yn) { /* start of response */
- if (response[0] != '*') {
- err = EMAIL_ERROR_INVALID_RESPONSE;
- EM_DEBUG_EXCEPTION("Start of response doesn't contain *");
- return_value = -1;
- goto FINISH_OFF;
- }
- server_response_yn = 1;
- }
-
- flag_first_write = 1;
- total = 0;
- memset(encoded, 0x00, sizeof(encoded));
-
- if (emcore_get_section_body_size(response, section, &body_size) < 0) {
- EM_DEBUG_EXCEPTION("emcore_get_section_body_size failed [%d]", err);
- err = EMAIL_ERROR_INVALID_RESPONSE;
- return_value = -1;
- goto FINISH_OFF;
- }
- EM_DEBUG_LOG("section :%s, body_size :%d", section, body_size);
-
- /* get body from seciton_list */
- if ((body = emcore_select_body_structure_from_section_list(section_list, section)) == NULL) {
- EM_DEBUG_EXCEPTION("emcore_select_body_structure_from_section_list failed [%d]", err);
- err = EMAIL_ERROR_INVALID_RESPONSE;
- return_value = -1;
- goto FINISH_OFF;
- }
- encoding = body->encoding;
-
- /* if (emcore_get_file_pointer(account_id, mail_id, body, buf, cnt_info , err)<0) {
- EM_DEBUG_EXCEPTION("emcore_get_file_pointer failed [%d]", err);
- goto FINISH_OFF;
- }*/
-
- if (!emcore_get_temp_file_name(&buf, &err)) {
- EM_DEBUG_EXCEPTION("emcore_get_temp_file_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG_SEC("temp filename :%s", buf);
-
- /* notifying UI start */
- /* parse_file_path_to_filename(buf, &file_id); */
- /* EM_DEBUG_LOG(">>>> filename - %p >>>>>>", file_id) */
-
- if (body->type == TYPETEXT && body->subtype && (!body->disposition.type || (body->disposition.type && (body->disposition.type[0] == 'i' || body->disposition.type[0] == 'I')))) {
- if (body->subtype[0] == 'H')
- cnt_info->text.html = buf;
- else
- cnt_info->text.plain = buf;
-
- PARAMETER *param = NULL;
- param = body->parameter;
-
- while (param) {
- if (!strcasecmp(param->attribute, "CHARSET")) {
- EM_SAFE_FREE (cnt_info->text.plain_charset); /* detected by valgrind */
- cnt_info->text.plain_charset = EM_SAFE_STRDUP(param->value);
- break;
- }
- param = param->next;
- }
- } else if (body->subtype && (body->id || body->location || body->disposition.type)) { /*prevent 23712*/ /*refactoring : body->subtype*/
-
- if (emcore_get_file_pointer(body, false, filename, cnt_info , &err) < 0) {
- EM_DEBUG_EXCEPTION("emcore_get_file_pointer failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* Search info from attachment list followed by inline attachment list */
-
- ai = cnt_info->file;
- EM_DEBUG_LOG("ai - %p", (ai));
-
- /* For Inline content append to the end */
- for (i = 1; ai; ai = ai->next, i++) {
- if (ai->save == NULL && (ai->content_id != NULL && EM_SAFE_STRCMP(ai->content_id, body->id) == 0)) {
- EM_DEBUG_LOG("Found matching details");
- ai->save = buf;
- break;
- }
- }
- }
-
- if (event_handle > 0)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-
- if (cnt_info->grab_type == GRAB_TYPE_ATTACHMENT) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, buf, cnt_info->file_no, 0))
- EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
-
- _imap4_download_noti_interval_value = body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
- _imap4_total_body_size = body_size;
- } else {
- if (multi_part_body_size) {
- EM_DEBUG_LOG("Multipart body size is [%d]", multi_part_body_size);
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, buf, multi_part_body_size, 0))
- EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
-
- _imap4_download_noti_interval_value = multi_part_body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
- } else {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, buf, body_size, 0))
- EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
-
- _imap4_download_noti_interval_value = body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
- _imap4_total_body_size = body_size;
- }
- }
-
- if (_imap4_download_noti_interval_value > DOWNLOAD_NOTI_INTERVAL_SIZE) {
- _imap4_download_noti_interval_value = DOWNLOAD_NOTI_INTERVAL_SIZE;
- }
-
- /* EM_SAFE_FREE(file_id) */
- /* notifying UI end */
-
- if (body_size < DOWNLOAD_MAX_BUFFER_SIZE) {
- if (net_getbuffer(imaplocal->netstream, (long)body_size, (char *)encoded) <= 0) {
- EM_DEBUG_EXCEPTION("net_getbuffer failed...");
- err = EMAIL_ERROR_NO_RESPONSE;
- return_value = -1;
- goto FINISH_OFF;
- }
-
- if (!emcore_write_response_into_file(buf, "wb+", (char *)encoded, encoding, body->subtype, account_id, mail_id, &err)) {
- EM_DEBUG_EXCEPTION("write_response_into_file failed [%d]", err);
- return_value = -1;
- goto FINISH_OFF;
- }
-
- total = EM_SAFE_STRLEN((char *)encoded);
- _imap4_received_body_size = _imap4_received_body_size + EM_SAFE_STRLEN((char *)encoded);
-
- EM_DEBUG_LOG("total = %d", total);
- EM_DEBUG_LOG("write_response_into_file successful %s.....", buf);
-
- EM_DEBUG_LOG("_imap4_last_notified_body_size [%d]", _imap4_last_notified_body_size);
- EM_DEBUG_LOG("_imap4_download_noti_interval_value [%d]", _imap4_download_noti_interval_value);
- EM_DEBUG_LOG("_imap4_received_body_size [%d]", _imap4_received_body_size);
- EM_DEBUG_LOG("_imap4_total_body_size [%d] ", _imap4_total_body_size);
-
- /* In some situation, total_encoded_len includes the length of dummy bytes.
- * So it might be greater than body_size */
-
- _imap4_last_notified_body_size = _imap4_received_body_size;
-
- if (_imap4_total_body_size)
- imap4_total_body_download_progress = 100*_imap4_received_body_size/_imap4_total_body_size;
- else
- imap4_total_body_download_progress = _imap4_received_body_size;
-
- EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY :Total[%d] / [%d] = %d %% Completed.", _imap4_received_body_size, _imap4_total_body_size, imap4_total_body_download_progress);
-
- if (cnt_info->grab_type == GRAB_TYPE_ATTACHMENT) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, buf, cnt_info->file_no, imap4_total_body_download_progress))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
- } else {
- if (multi_part_body_size) {
- /* EM_DEBUG_LOG("DOWNLOADING.......... : Multipart body size is [%d]", multi_part_body_size) */
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, buf, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- } else {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, buf, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- }
- }
- } else {
- int remain_body_size = body_size;
- int x = 0;
- int nsize = 0;
- total = 0;
-
- if (encoding == ENCBASE64)
- x = (sizeof(encoded)/78) *78; /* to solve base64 decoding pro */
- else
- x = sizeof(encoded)-1;
-
- memset(test_buffer, 0x00, sizeof(test_buffer));
- while (remain_body_size && (total <body_size)) {
-
- memset(test_buffer, 0x00, sizeof(test_buffer));
- while ((total != body_size) && remain_body_size && ((EM_SAFE_STRLEN((char *)test_buffer) + x) < sizeof(test_buffer))) {
- memset(encoded, 0x00, sizeof(encoded));
-
- if (net_getbuffer (imaplocal->netstream, (long)x, (char *)encoded) <= 0) {
- EM_DEBUG_EXCEPTION("net_getbuffer failed...");
- err = EMAIL_ERROR_NO_RESPONSE;
- return_value = -1;
- goto FINISH_OFF;
- }
-
- nsize = EM_SAFE_STRLEN((char *)encoded);
- remain_body_size = remain_body_size - nsize;
- strncat((char *)test_buffer, (char *)encoded, nsize);
- total = total + nsize;
- _imap4_received_body_size += nsize;
-
- EM_DEBUG_LOG("total = %d", total);
-
- if (!(remain_body_size/x) && remain_body_size%x)
- x = remain_body_size%x;
-
- EM_DEBUG_LOG(" _imap4_last_notified_body_size - %d ", _imap4_last_notified_body_size);
- EM_DEBUG_LOG(" _imap4_download_noti_interval_value - %d ", _imap4_download_noti_interval_value);
- EM_DEBUG_LOG(" _imap4_received_body_size - %d ", _imap4_received_body_size);
- EM_DEBUG_LOG(" _imap4_received_body_size - %d ", _imap4_received_body_size);
- EM_DEBUG_LOG(" _imap4_total_body_size - %d ", _imap4_total_body_size);
-
- if (((_imap4_last_notified_body_size + _imap4_download_noti_interval_value) <= _imap4_received_body_size)
- || (_imap4_received_body_size >= _imap4_total_body_size)) {
- /* In some situation, total_encoded_len includes the length of dummy bytes.
- * So it might be greater than body_size */
-
- if (_imap4_received_body_size > _imap4_total_body_size)
- _imap4_received_body_size = _imap4_total_body_size;
- _imap4_last_notified_body_size = _imap4_received_body_size;
-
- if (_imap4_total_body_size)
- imap4_total_body_download_progress = 100*_imap4_received_body_size/_imap4_total_body_size;
- else
- imap4_total_body_download_progress = _imap4_received_body_size;
-
- EM_DEBUG_LOG("DOWNLOADING STATUS NOTIFY :Total[%d] / [%d] = %d %% Completed.", _imap4_received_body_size, _imap4_total_body_size, imap4_total_body_download_progress);
-
- if (cnt_info->grab_type == GRAB_TYPE_ATTACHMENT) {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, buf, cnt_info->file_no, imap4_total_body_download_progress))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
- } else {
- if (multi_part_body_size) {
- /* EM_DEBUG_LOG("DOWNLOADING.......... : Multipart body size is [%d]", multi_part_body_size) */
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, buf, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- } else {
- if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, buf, _imap4_total_body_size, _imap4_received_body_size))
- EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_BODY_START] Failed >>>>");
- }
- }
- }
- }
-
- if (flag_first_write == 1) {
- if (!emcore_write_response_into_file(buf, "wb+", (char *)test_buffer, encoding, body->subtype, account_id, mail_id, &err)) {
- EM_DEBUG_EXCEPTION("write_response_into_file %s failed [%d]", buf, err);
- return_value = -1;
- goto FINISH_OFF;
- }
- flag_first_write = 0;
- } else {
- if (!emcore_write_response_into_file(buf, "ab+", (char *)test_buffer, encoding, body->subtype, account_id, mail_id, &err)) /* append */ {
- EM_DEBUG_EXCEPTION("write_response_into_file %s failed [%d]", buf, err);
- return_value = -1;
- goto FINISH_OFF;
- }
- }
- EM_DEBUG_LOG("%d has been written", EM_SAFE_STRLEN((char *)test_buffer));
- }
- }
- }
- else if ((tag_position = g_strrstr(response, tag))) /* end of response */ {
- if (!strncmp(tag_position + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
- EM_SAFE_FREE(response);
- } else { /* 'NO' or 'BAD */
- err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;
- return_value = -1;
- goto FINISH_OFF;
- }
- break;
- }
- else if (!strcmp(response, ")")) {
- }
-
- EM_SAFE_FREE (response);
- }
-
- return_value = 0;
-
- FINISH_OFF:
-
- if (err_code)
- *err_code = err;
-
- EM_SAFE_FREE(response);
-
- return return_value;
-}
-
-static int _find_duplicated_inline_content_file(char *input_source_file_name, struct _m_content_info *input_content_info, bool *output_result)
-{
- EM_DEBUG_FUNC_BEGIN("input_source_file_name [%s], input_content_info [%p], output_result [%p]", input_source_file_name,input_content_info, output_result);
- struct attachment_info *cur_attachment_info = NULL;
- int err = EMAIL_ERROR_NONE;
- bool result = false;
-
- if(!input_source_file_name || !input_content_info || !output_result || strlen(input_source_file_name) <= 0) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
- return EMAIL_ERROR_INVALID_PARAM;
- }
-
- cur_attachment_info = input_content_info->file;
-
- while(cur_attachment_info) {
- if(strcmp(input_source_file_name, cur_attachment_info->name) == 0) {
- result = true;
- break;
- }
- cur_attachment_info = cur_attachment_info->next;
- }
-
- *output_result = result;
-
- EM_DEBUG_FUNC_END("err [%d], result [%d]", err, result);
- return err;
-}
-
-static int _modify_file_name_string_for_duplicated_inline_content(char *input_source_file_name, struct _m_content_info *input_content_info)
-{
- EM_DEBUG_FUNC_BEGIN("input_source_file_name [%s], input_content_info [%p]", input_source_file_name,input_content_info);
- int err = EMAIL_ERROR_NONE;
- char temp_file_name[MAX_PATH] = { 0, };
- char *file_name = NULL;
- char *extension = NULL;
-
- if(!input_source_file_name || !input_content_info) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
- return EMAIL_ERROR_INVALID_PARAM;
- }
-
- if ( (err = em_get_file_name_and_extension_from_file_path(input_source_file_name, &file_name, &extension)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("em_get_file_name_and_extension_from_file_path failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if(file_name && extension)
- SNPRINTF(temp_file_name, MAX_PATH, "%s_.%s", file_name, extension);
- else if(!extension)
- SNPRINTF(temp_file_name, MAX_PATH, "%s_", file_name);
-
- EM_SAFE_STRCPY(input_source_file_name, temp_file_name);
- EM_DEBUG_LOG_SEC("temp_file_name [%s]", temp_file_name);
-
-FINISH_OFF:
-
- EM_SAFE_FREE(file_name);
- EM_SAFE_FREE(extension);
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-static int emcore_get_file_pointer(BODY *body, bool input_check_duplicated_file_name, char *output_file_name_string, struct _m_content_info *cnt_info , int *err)
-{
- EM_DEBUG_FUNC_BEGIN();
-
- char *decoded_filename = NULL;
- char attachment_file_name[MAX_PATH] = { 0, };
- char attachment_file_name_source[MAX_PATH] = {0, };
- int error = EMAIL_ERROR_NONE;
- bool file_name_duplicated = false;
-
- if ((body->type == TYPETEXT) && (body->disposition.type == NULL)) {
- EM_DEBUG_LOG("body->type == TYPETEXT");
- if (!cnt_info) {
- EM_DEBUG_EXCEPTION("But, cnt_info is null");
- error = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
- if (body->subtype[0] == 'H') {
- if (cnt_info->text.plain_charset != NULL) {
- memcpy(output_file_name_string, cnt_info->text.plain_charset, EM_SAFE_STRLEN(cnt_info->text.plain_charset));
- strcat(output_file_name_string, HTML_EXTENSION_STRING);
- }
- else {
- memcpy(output_file_name_string, "UTF-8.htm", strlen("UTF-8.htm"));
- }
- cnt_info->text.html = EM_SAFE_STRDUP(output_file_name_string);
- }
- else {
- PARAMETER *param = body->parameter;
- char charset_string[512];
-
- if (emcore_get_attribute_value_of_body_part(param, "CHARSET", charset_string, 512, false, &error)) {
- EM_SAFE_FREE(cnt_info->text.plain_charset); /*valgrind*/
- cnt_info->text.plain_charset = EM_SAFE_STRDUP(charset_string);
- memcpy(output_file_name_string, cnt_info->text.plain_charset, EM_SAFE_STRLEN(cnt_info->text.plain_charset));
- }
- else
- memcpy(output_file_name_string, "UTF-8", strlen("UTF-8"));
-
- cnt_info->text.plain = EM_SAFE_STRDUP(output_file_name_string);
- }
-
- }
- else if ((body->id != NULL) || ((body->disposition.type != NULL) && ((body->disposition.type[0] == 'i') || (body->disposition.type[0] == 'I')))) {
- /* body id is exising or disposition type is inline */
- size_t len = 0;
- if (body->parameter) /* Get actual name of file */ {
- PARAMETER *param_body = body->parameter;
- if (!emcore_get_attribute_value_of_body_part(param_body, "NAME", attachment_file_name_source, MAX_PATH, true, &error))
- emcore_get_attribute_value_of_body_part(param_body, "CHARSET", attachment_file_name_source, MAX_PATH, true, &error);
- if (!emcore_make_attachment_file_name_with_extension(attachment_file_name_source, body->subtype, attachment_file_name, MAX_PATH, &error)) {
- EM_DEBUG_EXCEPTION("emcore_make_attachment_file_name_with_extension failed [%d]", error);
- goto FINISH_OFF;
- }
- }
- else if (body->disposition.type) {
- PARAMETER *param_disposition = body->disposition.parameter;
- EM_DEBUG_LOG("body->disposition.type exist");
- emcore_get_attribute_value_of_body_part(param_disposition, "filename", attachment_file_name_source, MAX_PATH, true, &error);
- if (!emcore_make_attachment_file_name_with_extension(attachment_file_name_source, body->subtype, attachment_file_name, MAX_PATH, &error)) {
- EM_DEBUG_EXCEPTION("emcore_make_attachment_file_name_with_extension failed [%d]", error);
- goto FINISH_OFF;
- }
- }
- else { /* body id is not null but disposition type is null */
- if ((body->id[0] == '<'))
- SNPRINTF(attachment_file_name, MAX_PATH, "%s", body->id+1); /* fname = em_parse_filename(body->id + 1 */
- else
- SNPRINTF(attachment_file_name, MAX_PATH, "%s", body->id); /* fname = em_parse_filename(body->id */
-
- len = EM_SAFE_STRLEN(attachment_file_name);
-
- if ((len > 1) && (attachment_file_name[len-1] == '>'))
- attachment_file_name[len - 1] = '\0';
- decoded_filename = emcore_decode_rfc2047_text(attachment_file_name, &error);
- }
- EM_DEBUG_LOG_SEC("attachment_file_name [%s]", attachment_file_name);
- if (decoded_filename != NULL)
- memcpy(output_file_name_string, decoded_filename, EM_SAFE_STRLEN(decoded_filename));
- else
- memcpy(output_file_name_string, attachment_file_name, EM_SAFE_STRLEN(attachment_file_name));
-
- }
- else if (body->disposition.type != NULL) { /* disposition type is existing and not inline and body_id is nul */
- PARAMETER *param = body->parameter;
- if (!emcore_get_attribute_value_of_body_part(param, "NAME", attachment_file_name, MAX_PATH, true, &error))
- emcore_get_attribute_value_of_body_part(param, "FILENAME", attachment_file_name, MAX_PATH, true, &error);
- memcpy(output_file_name_string, attachment_file_name, EM_SAFE_STRLEN(attachment_file_name));
- }
-
- if(input_check_duplicated_file_name) {
- if ( (error = _find_duplicated_inline_content_file(output_file_name_string, cnt_info, &file_name_duplicated)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("_find_duplicated_inline_content_file failed [%d]", error);
- goto FINISH_OFF;
- }
-
- if (file_name_duplicated == true) {
- if ( ( error = _modify_file_name_string_for_duplicated_inline_content(output_file_name_string, cnt_info)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("_modify_file_name_string_for_duplicated_inline_content failed [%d]", error);
- goto FINISH_OFF;
- }
- }
- }
-
-FINISH_OFF:
-
- EM_SAFE_FREE(decoded_filename);
-
- if (err)
- *err = error;
- EM_DEBUG_LOG_SEC("output_file_name_string[%s]", output_file_name_string);
- EM_DEBUG_FUNC_END("error [%d]", error);
- return SUCCESS;
-}
-
-
-static PARTLIST *emcore_add_node(PARTLIST *section_list, BODY *body)
-{
- PARTLIST *temp = (PARTLIST *)malloc(sizeof(PARTLIST));
-
- if (temp == NULL) {
- EM_DEBUG_EXCEPTION("PARTLIST node creation failed");
- return NULL;
- }
- temp->body = body;
- temp->next = NULL;
-
- if (section_list == NULL)/* first node in list */ {
- section_list = temp;
- }
- else/* has min 1 nod */ {
- PARTLIST *t = section_list;
- while (t->next != NULL) /* go to last nod */ {
- t = (PARTLIST *) t->next;
- }
- t->next = (PART *)temp;/* I think this should be PARTLIST, but why this is PART */
-/*
-in imap-2007e/c-client/mail.h
-PARTLIST{
- BODY *body;
- PART *next;
-};
-*/
- }
- return section_list;
-}
-
-
-static void emcore_free_section_list(PARTLIST *section_list)
-{
- PARTLIST *temp = NULL;
-
- while (section_list != NULL) {
- temp = (PARTLIST *)section_list->next;
- EM_SAFE_FREE(section_list);
- section_list = temp;
- }
-}
-
-static int emcore_get_section_body_size(char *response, char *section, int *body_size)
-{
- char *p = NULL;
- char *s = NULL;
- int size = 0;
-
- if ((p = strstr(response, "BODY[")) /* || (p = strstr(s + 1, "BODY["))*/) {
-
- p += strlen("BODY[");
- s = p;
-
- while (*s != ']')
- s++;
-
- *s = '\0';
- strcpy(section, p);
-
- /* if (strcmp(section, p)) {
- err = EMAIL_ERROR_INVALID_RESPONSE;
- goto FINISH_OFF;
- }*/
- p = strstr(s+1, " {");
- if (p) {
- p += strlen(" {");
- s = p;
-
- while (isdigit(*s))
- s++;
-
- *s = '\0';
-
- size = atoi(p);
- *body_size = size;
-
- /* sending progress noti to application.
- 1. mail_id
- 2. file_id
- 3. bodysize
- */
- } else {
- return FAILURE;
- }
- } else {
- return FAILURE;
- }
-
- return SUCCESS;
-}
-
/*
static char *em_parse_filename(char *filename)
{
@@ -3902,8 +627,8 @@ INTERNAL_FUNC int emcore_get_utf8_address(char **dest, ADDRESS *address, int *er
while (address) {
if (address->personal) {
- if (!(nickname = emcore_decode_rfc2047_text(address->personal, &err))) {
- EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_text failed - %d", err);
+ if (!(nickname = emcore_gmime_get_decoding_text(address->personal))) {
+ EM_DEBUG_EXCEPTION("emcore_gmime_get_decoding_text failed - %d", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG_DEV("nickname[%s]", nickname);
@@ -4030,14 +755,12 @@ INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param
if (!strcasecmp(temp_param->attribute, atribute_name)) {
if (temp_param->value) {
if (with_rfc2047_text) {
- decoded_value = emcore_decode_rfc2047_text(temp_param->value, &err);
- if (decoded_value)
- result_value = decoded_value;
- else
- result_value = decoded_value;
+ decoded_value = emcore_gmime_get_decoding_text(temp_param->value);
+ result_value = EM_SAFE_STRDUP(decoded_value);
+ EM_SAFE_FREE(decoded_value);
}
else
- result_value = temp_param->value;
+ result_value = g_strdup(temp_param->value);
}
else {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_DATA_NOT_FOUND");
@@ -4065,6 +788,7 @@ INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param
FINISH_OFF:
EM_SAFE_FREE(decoded_value);
+ EM_SAFE_FREE(result_value);
if(err_code)
*err_code = err;
@@ -4073,680 +797,6 @@ FINISH_OFF:
return ret;
}
-
-/*
- *download body part of imap mail (body-text and attachment)
- */
-static int emcore_get_body_part_imap(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, char *part_body_type, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- int err = EMAIL_ERROR_NONE, ret = -1;
- struct attachment_info **ai;
- struct attachment_info *prev_ai = NULL;
- struct attachment_info *next_ai = NULL;
- char *savefile = NULL;
- char *o_data = NULL;
- char filename[MAX_PATH + 1] = { 0, };
- char *decoded_filename = NULL;
- int is_attachment = 0;
- int attachment_type = 0;
- int o_data_len = 0;
- char charset_value_buffer[512] = { 0, };
- char content_type_buffer[512] = { 0, };
-/* { is_pb */
- PART *part = NULL;
- int dec_len;
- int i = 0;
- int section_plain = 0;
- int section_html = 0;
- int is_pbd = (account_id == 0 && mail_id == 0) ? true : false;
- int search_result = false;
-/* } is_pb */
-
-
-
- /* unknown type */
- if (body->type > TYPEOTHER) { /* unknown type */
- EM_DEBUG_EXCEPTION("Unknown type.");
- err = EMAIL_ERROR_NOT_SUPPORTED;
- goto FINISH_OFF;
- }
-
- if (NULL == body->subtype) {
- EM_DEBUG_LOG("body->subtype is null. "); /* not exceptional case */
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return FAILURE;
- }
-
- if (is_pbd) {
- if (body->type == TYPETEXT && body->subtype &&
- (!body->disposition.type || (body->disposition.type && (body->disposition.type[0] == 'i' || body->disposition.type[0] == 'I')))) {
-
- if (!emcore_get_temp_file_name(&o_data, &err) || !o_data) {
- EM_DEBUG_EXCEPTION("emcore_get_temp_file_name failed [%d]", err);
- if (err_code != NULL)
- *err_code = err;
- return FAILURE;
- }
-
- if (body->subtype[0] == 'H' || body->subtype[0] == 'h')
- cnt_info->text.html = EM_SAFE_STRDUP(o_data);
- else
- cnt_info->text.plain = EM_SAFE_STRDUP(o_data);
-
- memset(charset_value_buffer, 0, 512);
-
- if (emcore_get_attribute_value_of_body_part(body->parameter, "CHARSET", charset_value_buffer, 512, true, &err)) {
- EM_SAFE_FREE(cnt_info->text.plain_charset);
- cnt_info->text.plain_charset = EM_SAFE_STRDUP(charset_value_buffer);
-
- }
- }
- } /* is_pbd */
-
- if ((body->id) && EM_SAFE_STRLEN(body->id) > 1) { /* if Content-ID or Content-Location exists, it is inline contents */
- EM_DEBUG_LOG("body->id exist");
- size_t len = 0;
- /* Get actual name of file - fix for inline images to be stored with actual names and not .jpeg */
- if (body->parameter) {
- PARAMETER *param1 = body->parameter;
- while (param1) {
- EM_DEBUG_LOG("param1->attribute - %s ", param1->attribute);
- if (!strcasecmp(param1->attribute, "NAME")) { /* attribute is "NAME" */
- char *extcheck = NULL;
-
- if (param1->value) {
- decoded_filename = emcore_decode_rfc2047_text(param1->value, &err);
- strncpy(filename, decoded_filename, MAX_PATH);
- EM_SAFE_FREE(decoded_filename);
- }
- EM_DEBUG_LOG_SEC(">>>>> FILENAME [%s] ", filename);
- extcheck = strchr(filename, '.');
-
- if (extcheck)
- EM_DEBUG_LOG(">>>> Extension Exist in the Attachment [ %s ] ", extcheck);
- else /* No extension attached , So add the Extension based on the subtyp */ {
- if (body->subtype) {
- strcat(filename, ".");
- strcat(filename, body->subtype);
- EM_DEBUG_LOG_SEC(">>>>> FILENAME Identified the Extension [%s] ", filename);
- }
- else
- EM_DEBUG_EXCEPTION("UnKnown Extesnsion : _ (");
-
- }
-
- break;
- }
- param1 = param1->next;
- }
-
- }
- else if (body->disposition.type) {
- PARAMETER *param = body->disposition.parameter;
-
- while (param) {
- EM_DEBUG_LOG(">>>>> body->disposition.parameter->attribute [ %s ] ", param->attribute);
- EM_DEBUG_LOG(">>>>> body->disposition.parameter->value [ %s ] ", param->value);
-
- /* attribute is "filename" */
- if (!strcasecmp(param->attribute, "filename")) {
- decoded_filename = emcore_decode_rfc2047_text(param->value, &err);
- strncpy(filename, decoded_filename, MAX_PATH);
- EM_SAFE_FREE(decoded_filename);
- EM_DEBUG_LOG_SEC(">>>>> FILENAME [%s] ", filename);
- break;
- }
-
- param = param->next;
- }
- }
- else {
- if ((body->id[0] == '<'))
- SNPRINTF(filename, MAX_PATH, "%s", body->id+1);
- else
- SNPRINTF(filename, MAX_PATH, "%s", body->id);
-
- len = EM_SAFE_STRLEN(filename);
-
- if ((len > 1) && (filename[len-1] == '>'))
- filename[len-1] = '\0';
- }
- }
- else if (body->location) {
- EM_DEBUG_LOG("body->location exist");
- decoded_filename = emcore_decode_rfc2047_text(body->location, &err);
- strncpy(filename, decoded_filename, MAX_PATH);
- EM_SAFE_FREE(decoded_filename);
- EM_DEBUG_LOG_SEC("body->location [%s]", body->location);
- }
- else if (is_pbd && (strncmp(body->subtype, "RFC822", strlen("RFC822")) == 0) && (cnt_info->grab_type == 0 || (cnt_info->grab_type & GRAB_TYPE_ATTACHMENT))) {
- EM_DEBUG_LOG("Beause subtype is RFC822. This is ttachment");
-
- if (cnt_info->grab_type == 0) {
- if ((body->nested.msg != NULL) && (body->nested.msg->env != NULL) && (body->nested.msg->env->subject != NULL)) {
- decoded_filename = emcore_decode_rfc2047_text(body->nested.msg->env->subject, &err);
- strncpy(filename, decoded_filename, MAX_PATH);
- EM_SAFE_FREE(decoded_filename);
- }
- else
- strncpy(filename, "Unknown <message/rfc822>", MAX_PATH);
- }
- else if (cnt_info->grab_type & GRAB_TYPE_ATTACHMENT) {
- BODY *temp_body = NULL;
- if (body->nested.msg->env->subject != NULL) {
- int i = 0;
- int subject_count = 0;
- if (g_str_has_prefix(body->nested.msg->env->subject, "= ? ") && g_str_has_suffix(body->nested.msg->env->subject, " ? = "))
- strncpy(filename, "unknown", MAX_PATH);
- else {
- for (subject_count = 0; body->nested.msg->env->subject[subject_count] != '\0' ; subject_count++) {
- if (body->nested.msg->env->subject[subject_count] != ':' &&
- body->nested.msg->env->subject[subject_count] != ';' &&
- body->nested.msg->env->subject[subject_count] != '*' &&
- body->nested.msg->env->subject[subject_count] != '?' &&
- body->nested.msg->env->subject[subject_count] != '\"' &&
- body->nested.msg->env->subject[subject_count] != '<' &&
- body->nested.msg->env->subject[subject_count] != '>' &&
- body->nested.msg->env->subject[subject_count] != '|' &&
- body->nested.msg->env->subject[subject_count] != '/') {
- filename[i] = body->nested.msg->env->subject[subject_count];
- i++;
- }
- else
- continue;
- }
- }
- }
- else
- strncpy(filename, "Unknown", MAX_PATH);
-
- body = ((MESSAGE *)body->nested.msg)->body;
- part = body->nested.part;
-
- if ((body->subtype[0] == 'P') || (body->subtype[0] == 'H'))
- temp_body = body;
- else if (part != NULL) {
- temp_body = &(part->body);
- if ((temp_body->subtype[0] == 'P' || temp_body->subtype[0] == 'H') && part->next != NULL) {
- part = part->next;
- temp_body = &(part->body);
- }
- }
-
- if (temp_body) {
- if (temp_body->subtype[0] == 'P')
- section_plain = 1;
- else if (temp_body->subtype[0] == 'H')
- section_html = 1;
- }
- }
- }
- else if (body->disposition.type) /* if disposition exists, get filename from disposition parameter */ { /* "attachment" or "inline" or etc.. */
- EM_DEBUG_LOG("body->disposition.type exist");
-
- if (emcore_get_attribute_value_of_body_part(body->disposition.parameter, "filename", filename, MAX_PATH, true, &err))
- EM_DEBUG_LOG_SEC(">>>>> FILENAME [%s] ", filename);
-
- if (!*filename) { /* If the part has no filename, it may be report ms */
- if (body->parameter) /* Fix for the MMS attachment File name as unknown */ {
- char *extcheck = NULL;
-
- if (emcore_get_attribute_value_of_body_part(body->parameter, "NAME", filename, MAX_PATH, true, &err))
- EM_DEBUG_LOG_SEC("NAME [%s] ", filename);
-
- extcheck = strchr(filename, '.');
-
- if (extcheck)
- EM_DEBUG_LOG(">>>> Extension Exist in the Attachment [ %s ] ", extcheck);
- else { /* No extension attached , So add the Extension based on the subtype */
- if (body->subtype) {
- if (EM_SAFE_STRLEN(filename) + strlen(body->subtype) + 1 < MAX_PATH) {
- strcat(filename, ".");
- strcat(filename, body->subtype);
- }
- EM_DEBUG_LOG_SEC(">>>>> FILENAME Identified the Extension [%s] ", filename);
- }
- else
- EM_DEBUG_EXCEPTION("UnKnown Extesnsion : _ (");
- }
-
- }
- else
- strncpy(filename, "unknown", MAX_PATH);
- }
- }
- else {
- char *attr_upper = NULL;
- char *decoded_value = NULL;
- PARAMETER *param = body->parameter;
- if (param) {
- do {
- EM_DEBUG_LOG_DEV("BODY-PARAM-ATTRIBUTE:%s", param->attribute);
- EM_DEBUG_LOG_DEV("BODY-PARAM-VALUE:%s", param->value);
-
- EM_SAFE_FREE(attr_upper); /* valgrind */
- attr_upper = g_ascii_strup(param->attribute, -1);
- if (g_strcmp0(attr_upper, "NAME") == 0) {
- decoded_value = emcore_decode_rfc2047_text(param->value, &err);
- if (decoded_value) strncpy(filename, decoded_value, MAX_PATH);
- break;
- }
- param = param->next;
- } while(param);
- }
-
- if (!decoded_value)
- strncpy(filename, "unknown", MAX_PATH);
-
- EM_SAFE_FREE(attr_upper);
- EM_SAFE_FREE(decoded_value);
- }
-
- /* if (!is_pbd) */ {
- EM_DEBUG_LOG_SEC("filename [%s]", filename);
- if (*filename) {
- decoded_filename = emcore_decode_rfc2047_text(filename, &err);
- strncpy(filename, decoded_filename, MAX_PATH);
- EM_SAFE_FREE(decoded_filename);
-
- }
- }
-
- /* the subtype of content-type is related and the dispostion type is attachment or inline, It is inline attachment */
- if (part_body_type != NULL) {
- if ((part_body_type[0] == 'R' || part_body_type[0] == 'r') && body->disposition.type) {
- attachment_type = INLINE_ATTACHMENT;
- is_attachment = 1;
- } else if ((part_body_type[0] == 'M' || part_body_type[0] == 'm') && body->disposition.type) {
- /* the subtype of content-type is mixed and the dispostion type is attachment , It is attachment */
- attachment_type = ATTACHMENT;
- is_attachment = 1;
- }
- }
-
- if (!is_attachment) { /* Text or RFC822 Message */
- if (((cnt_info->grab_type & GRAB_TYPE_TEXT) && (body->type == TYPEMESSAGE || body->type == TYPETEXT || body->type == TYPEIMAGE)) ||
- (cnt_info->grab_type & GRAB_TYPE_ATTACHMENT)) {
- if (is_pbd) {
- EM_SAFE_FREE(o_data);
- return SUCCESS;
- }
- else { /* fetch body */
- if (!emcore_get_temp_file_name(&o_data, &err)) {
- EM_DEBUG_EXCEPTION("emcore_get_temp_file_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!imap_mail_write_body_to_file(stream, account_id, mail_id, 0, o_data, msg_uid, body->sparep, body->encoding, &o_data_len, body->subtype, &err)) {
- EM_DEBUG_EXCEPTION("imap_mail_write_body_to_file failed [%d]", err);
- if(err == EMAIL_ERROR_INVALID_STREAM) {
- email_session_t *session = NULL;
- if (emcore_get_current_session(&session) && session)
- err = session->error;
- }
- goto FINISH_OFF;
- }
- }
- }
-
- switch (body->type) {
- case TYPETEXT:
-
- if (body->subtype[0] == 'H') {
- EM_SAFE_FREE(cnt_info->text.html);
- cnt_info->text.html = EM_SAFE_STRDUP(o_data);
- } else {
- EM_SAFE_FREE(cnt_info->text.plain);
- cnt_info->text.plain = EM_SAFE_STRDUP(o_data);
- memset(charset_value_buffer, 0, 512);
- /*check: cnt_info->text.plain_charset is malloc'd twice */
- if (emcore_get_attribute_value_of_body_part(body->parameter, "CHARSET", charset_value_buffer, 512, true, &err)) {
- EM_SAFE_FREE(cnt_info->text.plain_charset);
- cnt_info->text.plain_charset = EM_SAFE_STRDUP(charset_value_buffer);
- }
- }
- break;
- case TYPEIMAGE:
- case TYPEAPPLICATION:
- case TYPEAUDIO:
- case TYPEVIDEO:
- /* Inline Content - suspect of crash on partial body download */
- /* if (!is_pbd) */ {
- EM_DEBUG_LOG("TYPEIMAGE or TYPEAPPLICATION : inline content");
- ai = &(cnt_info->file);
-
- while(*ai != NULL)
- ai = &(*ai)->next;
-
- dec_len = body->size.bytes;
- if ((cnt_info->grab_type & GRAB_TYPE_ATTACHMENT) &&
- (cnt_info->grab_type & GRAB_TYPE_TEXT)) { /* it is 'download all */
- only_body_download = false;
- cnt_info->file_no = 1;
- }
-
- /* add attachment info to content info */
- if (!(*ai = em_malloc(sizeof(struct attachment_info)))) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
- return FAILURE;
- }
-
- if (((body->id) || (body->location)) && (body->type == TYPEIMAGE || body->type == TYPEAPPLICATION)) /* Some composer writes a content type of gif as application/octet-stream */
- (*ai)->type = INLINE_ATTACHMENT; /* inline */
- else
- (*ai)->type = ATTACHMENT; /* attachment */
-
- (*ai)->name = EM_SAFE_STRDUP(filename);
- (*ai)->size = body->size.bytes;
- (*ai)->save = EM_SAFE_STRDUP(o_data);
- (*ai)->content_id = EM_SAFE_STRDUP(body->id);
-
- if (body->id && (emcore_search_string_from_file(cnt_info->text.html, body->id, NULL, &search_result) == EMAIL_ERROR_NONE && search_result)) {
- (*ai)->type = INLINE_ATTACHMENT;
- EM_DEBUG_LOG("INLINE_ATTACHMENT");
- } else if ((body->disposition.type && g_ascii_strcasecmp(body->disposition.type, "ATTACHMENT") == 0)) {
- (*ai)->type = ATTACHMENT;
- EM_DEBUG_LOG("ATTACHMENT");
- }
-
- memset(content_type_buffer, 0, 512);
- if ( (err = emcore_get_content_type_from_mail_bodystruct(body, 512, content_type_buffer) ) == EMAIL_ERROR_NONE)
- (*ai)->attachment_mime_type = EM_SAFE_STRDUP(content_type_buffer);
-
- EM_DEBUG_LOG_SEC("name[%s], size[%d], save[%s], content_type_buffer [%s]", cnt_info->file->name, cnt_info->file->size, cnt_info->file->save, content_type_buffer);
-#ifdef __ATTACHMENT_OPTI__
- (*ai)->encoding = body->encoding;
- if (body->sparep)
- (*ai)->section = EM_SAFE_STRDUP(body->sparep);
- EM_DEBUG_LOG(" Encoding - %d Section No - %s ", (*ai)->encoding, (*ai)->section);
-#endif
- }
- break;
-
- case TYPEMESSAGE: /* RFC822 Message */
- EM_DEBUG_EXCEPTION("MESSAGE/RFC822");
- err = EMAIL_ERROR_NOT_SUPPORTED;
- goto FINISH_OFF;
-
- default:
- EM_DEBUG_EXCEPTION("Unknown type. body->type [%d]", body->type);
- err = EMAIL_ERROR_NOT_SUPPORTED;
- goto FINISH_OFF;
- }
-
- stream->text.data = NULL; /* ? ? ? ? ? ? ? ? */
- }
- else { /* Attachment */
- prev_ai = NULL;
- next_ai = NULL;
- ai = &cnt_info->file;
- EM_DEBUG_LOG(" ai - %p ", (*ai));
-
- if (attachment_type == INLINE_ATTACHMENT) {
- /* For Inline content append to the end */
- for (i = 1; *ai; ai = &(*ai)->next)
- i++;
- }
- else { /* For attachment - search till Inline content found and insert before inline */
- for (i = 1; *ai; ai = &(*ai)->next) {
- if ((*ai)->type == 1) {
- /* Means inline image */
- EM_DEBUG_LOG("Found Inline Content ");
- next_ai = (*ai);
- break;
- }
- i++;
- prev_ai = (*ai);
- }
- }
-
- EM_DEBUG_LOG("i - %d next_ai - %p prev_ai - %p", i, next_ai, prev_ai);
-
- if ((cnt_info->grab_type & GRAB_TYPE_ATTACHMENT) &&
- (cnt_info->grab_type & GRAB_TYPE_TEXT)) { /* it is 'download all */
- EM_DEBUG_LOG("Download All");
- only_body_download = false;
- cnt_info->file_no = 1;
- i = 1;
- }
- /* meaningless code */
- dec_len = body->size.bytes;
-
- EM_DEBUG_LOG("i : %d, cnt_info->file_no : %d", i, cnt_info->file_no);
-
- if (
- ((cnt_info->grab_type & GRAB_TYPE_ATTACHMENT) && i == cnt_info->file_no) || /* Is it correct attachment */
- ((attachment_type == INLINE_ATTACHMENT) && (cnt_info->grab_type & GRAB_TYPE_TEXT)) /* Is it inline contents */
- ) {
- /* fetch attachment */
- EM_DEBUG_LOG_SEC("attachment (enc) : %s %ld bytes", filename, body->size.bytes);
- EM_DEBUG_LOG(">>>>> ONLY BODY DOWNLOAD [ %d ] ", only_body_download);
-
- if (only_body_download == false) {
- if (!emcore_get_temp_file_name(&savefile, &err)) {
- EM_DEBUG_EXCEPTION("emcore_get_temp_file_name failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!is_pbd && attachment_type == ATTACHMENT) {
- if (!imap_mail_write_body_to_file(stream, account_id, mail_id, cnt_info->file_no, savefile, msg_uid, body->sparep, body->encoding, &dec_len, body->subtype, &err)) {
- EM_DEBUG_EXCEPTION("imap_mail_write_body_to_file failed [%d]", err);
- goto FINISH_OFF;
- }
- }
- }
- }
-
- EM_DEBUG_LOG_SEC("attachment (dec) : %s %d bytes", filename, dec_len);
-
- /* add attachment info to content inf */
- if (!(*ai = em_malloc(sizeof(struct attachment_info)))) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- if (is_pbd) {
- if (savefile != NULL) {
- if (section_plain == 1)
- strcat(filename, ".txt");
- if (section_html == 1)
- strcat(filename, ".html");
- section_plain = 0;
- section_html = 0;
- }
- } /* is_pbd */
- (*ai)->name = EM_SAFE_STRDUP(filename);
- (*ai)->size = dec_len;
- (*ai)->save = EM_SAFE_STRDUP(savefile);
- (*ai)->content_id = EM_SAFE_STRDUP(body->id);
- (*ai)->type = attachment_type;
-
- memset(content_type_buffer, 0, 512);
- if ( (err = emcore_get_content_type_from_mail_bodystruct(body, 512, content_type_buffer) ) == EMAIL_ERROR_NONE)
- (*ai)->attachment_mime_type = EM_SAFE_STRDUP(content_type_buffer);
-#ifdef __ATTACHMENT_OPTI__
- (*ai)->encoding = body->encoding;
- if (body->sparep)
- (*ai)->section = EM_SAFE_STRDUP(body->sparep);
-
- EM_DEBUG_LOG(" Encoding - %d Section No - %s ", (*ai)->encoding, (*ai)->section);
-#endif
- if (body->type == TYPEAPPLICATION) {
- if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_OBJECT))
- (*ai)->drm = EMAIL_ATTACHMENT_DRM_OBJECT;
- else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_RIGHTS))
- (*ai)->drm = EMAIL_ATTACHMENT_DRM_RIGHTS;
- else if (!strcasecmp(body->subtype, MIME_SUBTYPE_DRM_DCF))
- (*ai)->drm = EMAIL_ATTACHMENT_DRM_DCF;
- }
-
- /* All inline images information are stored at the end of list */
- if ((*ai)->type != 1 && next_ai != NULL) {
- /* Means next_ai points to the inline attachment info structure */
- if (prev_ai == NULL) {
- /* First node is inline attachment */
- (*ai)->next = next_ai;
- cnt_info->file = (*ai);
- }
- else {
- prev_ai->next = (*ai);
- (*ai)->next = next_ai;
- }
- }
- }
-
- ret = 0;
-FINISH_OFF:
- if (err_code)
- *err_code = err;
- EM_SAFE_FREE(savefile);
- EM_SAFE_FREE(o_data);
- EM_DEBUG_FUNC_END("ret [%d]", ret);
- return ret;
-}
-/* get body-part in nested part */
-
-static int emcore_get_allnested_part(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
- PART *part_child = body->nested.part;
-
- while (part_child) {
- if (emcore_get_body(stream, account_id, mail_id, msg_uid, &part_child->body, body->subtype, cnt_info, err_code) < 0)
- return FAILURE;
-
- part_child = part_child->next;
- }
-
- EM_DEBUG_FUNC_END();
- return SUCCESS;
-}
-
-/* get body-part in alternative multiple part */
-static int emcore_get_alternative_multi_part(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- PART *part_child = body->nested.part;
-
- /* find the best sub part we can show */
- while (part_child) {
- if (emcore_get_body(stream, account_id, mail_id, msg_uid, &part_child->body, body->subtype, cnt_info, err_code) < 0)
- return FAILURE;
-
- part_child = part_child->next;
- }
- EM_DEBUG_FUNC_END();
- return SUCCESS;
-}
-
-/* get body part in signed multiple part */
-static int emcore_get_signed_multi_part(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- PART *part_child = body->nested.part;
-
- /* find the best sub part we can show */
- while (part_child) {
- if (emcore_get_body(stream, account_id, mail_id, msg_uid, &part_child->body, body->subtype, cnt_info, err_code) < 0)
- return FAILURE;
-
- part_child = part_child->next;
- }
-
- EM_DEBUG_FUNC_END();
- return SUCCESS;
-}
-
-/* get body part in encrypted multiple part */
-static int emcore_get_encrypted_multi_part(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
- EM_DEBUG_FUNC_END();
- return SUCCESS;
-}
-
-/* get body part in multiple part */
-static int emcore_get_multi_part(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- if (!body) {
- EM_DEBUG_EXCEPTION("Invalid Parameter.");
- if (err_code)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return FAILURE;
- }
-
- switch (body->subtype[0]) {
- case 'A': /* ALTERNATIVE */
- EM_DEBUG_LOG("body->subtype[0] = ALTERNATIVE");
- return emcore_get_alternative_multi_part(stream, account_id, mail_id, msg_uid, body, cnt_info, err_code);
-
- case 'S': /* SIGNED */
- EM_DEBUG_LOG("body->subtype[0] = SIGNED");
- return emcore_get_signed_multi_part(stream, account_id, mail_id, msg_uid, body, cnt_info, err_code);
-
- case 'E': /* ENCRYPTED */
- EM_DEBUG_LOG("body->subtype[0] = ENCRYPTED");
- return emcore_get_encrypted_multi_part(stream, account_id, mail_id, msg_uid, body, cnt_info, err_code);
-
- default: /* process all unknown as MIXED (according to the RFC 2047) */
- EM_DEBUG_LOG("body->subtype[0] = [%c].", body->subtype[0]);
- return emcore_get_allnested_part(stream, account_id, mail_id, msg_uid, body, cnt_info, err_code);
- }
- /* Delete the dead code */
-}
-
-/* get body data by body structure */
-/* if POP3, ignored */
-INTERNAL_FUNC int emcore_get_body(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, char *part_body_type, struct _m_content_info *cnt_info, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("stream[%p], msg_uid[%d], body[%p], cnt_info[%p], err_code[%p]", stream, msg_uid, body, cnt_info, err_code);
-
- if (!stream || !body || !cnt_info) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
-
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return FAILURE;
- }
-
-
-
- switch (body->type) {
- case TYPEMULTIPART:
- return emcore_get_multi_part(stream, account_id, mail_id, msg_uid, body, cnt_info, err_code);
-
- case TYPEMESSAGE: /* not support */
- if (strcasecmp(body->subtype, "RFC822") == 0)
- return emcore_get_body_part_imap(stream, account_id, mail_id, msg_uid, body, part_body_type, cnt_info, err_code);
- break;
-
- case TYPETEXT:
- case TYPEAPPLICATION:
- case TYPEAUDIO:
- case TYPEIMAGE:
- case TYPEVIDEO:
- case TYPEMODEL:
- case TYPEOTHER:
- /* exactly, get a pure body part (text and attachment */
- return emcore_get_body_part_imap(stream, account_id, mail_id, msg_uid, body, part_body_type, cnt_info, err_code);
-
- default:
- break;
- }
- EM_DEBUG_FUNC_END();
- return SUCCESS;
-}
-
/* get body structure */
INTERNAL_FUNC int emcore_get_body_structure(MAILSTREAM *stream, int msg_uid, BODY **body, int *err_code)
{
@@ -4884,347 +934,25 @@ int emcore_set_fetch_part_section(BODY *body, char *section_pfx, int section_sub
EM_DEBUG_FUNC_END();
return SUCCESS;
}
-
-
-static void parse_file_path_to_filename(char *src_string, char **out_string)
-{
- char *token = NULL;
- char *filepath = NULL;
- char *str = NULL;
- char *prev1 = NULL;
-
- filepath = EM_SAFE_STRDUP(src_string);
- token = strtok_r(filepath, "/", &str);
-
- do {
- prev1 = token;
- } while ((token = strtok_r(NULL , "/", &str)));
-
- *out_string = EM_SAFE_STRDUP(prev1);
- EM_SAFE_FREE(filepath);
-}
-
-static char *emcore_decode_rfc2047_word(char *encoded_word, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("encoded_word[%p], err_code[%p]", encoded_word, err_code);
-
- int err = EMAIL_ERROR_NONE;
- int base64_encoded = false, length = 0;
- SIZEDTEXT src = { NULL, 0 };
- SIZEDTEXT dst = { NULL, 0 };
- gchar *charset = NULL, *encoded_text = NULL;
- char *decoded_text = NULL, *decoded_word = NULL;
- char *current = NULL, *start = NULL, *end = NULL;
- char *buffer = (char*) em_malloc(EM_SAFE_STRLEN(encoded_word) * 2 + 1);
-
- if (buffer == NULL) {
- EM_DEBUG_EXCEPTION("Memory allocation fail");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- strcpy(buffer, "");
-
- /* encoding format : =?charset?encoding?encoded-text ?= */
- /* charset : UTF-8, EUC-KR, ... */
- /* encoding : b/B (BASE64), q/Q (QUOTED-PRINTABLE) */
- current = encoded_word;
-
- while (*current != NULL_CHAR) {
- /* search next */
- start = strstr(current, "=?"); /* start of encoding */
- end = g_strrstr(current, "?="); /* end of encoding */
-
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG("current[%p][%s], start[%p][%s], end[%p][%s]", current, current, start, start, end, end);
-#endif
- if (start != NULL) {
- if (current != start) { /* copy the string between current and start to buffer */
- strncat(buffer, current, start - current);
- current = start;
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG("1 - Buffer[%s]", buffer);
-#endif
- }
-
- if (end) { /* decode text between start and end */
- char *p = strstr(start, "?b?");
-
- if (p || (p = strstr(start, "?B?"))) /* BASE64 */
- base64_encoded = true;
- else {
- p = strstr(start, "?q?");
-
- if (p || (p = strstr(start, "?Q?"))) /* QUOTED-PRINTABLE */
- base64_encoded = false;
- else {
- EM_DEBUG_EXCEPTION("unknown encoding found...");
-
- err = EMAIL_ERROR_UNKNOWN;
- goto FINISH_OFF;
- }
- }
-
- if (base64_encoded) { /* BASE64 */
- if (p - (start + 2) > 0)
- charset = g_strndup(start + 2, p - (start + 2));
- encoded_text = g_strndup(p + 3, end - (p + 3));
- }
- else { /* QUOTED-PRINTABLE */
- charset = g_strndup(start + 2, p - (start + 2));
- if (*(p+3) == '=') { /* encoded text might start with '='. ex) '?Q?=E0' */
- end = g_strrstr(p+3, "?="); /* find new end flag */
- if (end) {
- encoded_text = g_strndup(p + 3, end - (p + 3));
- }
- else { /* end flag is not found */
- EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_word decoding error : '?=' is not found...");
-
- err = EMAIL_ERROR_UNKNOWN;
- goto FINISH_OFF;
- }
- }
- else {
- encoded_text = g_strndup(p + 3, end - (p + 3));
- }
- }
-
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG("\t >>>>>>>>>>>>>>> CHARSET[%s]", charset);
- EM_DEBUG_LOG("\t >>>>>>>>>>>>>>> ENCODED_TEXT[%s]", encoded_text);
-#endif
-
- unsigned long len = 0;
- if (encoded_text != NULL) {
- if (base64_encoded == true) {
- if (!(decoded_text = (char *)rfc822_base64((unsigned char *)encoded_text, EM_SAFE_STRLEN(encoded_text), &len))) {
- EM_DEBUG_EXCEPTION("rfc822_base64 falied...");
- goto FINISH_OFF;
- }
- }
- else {
- g_strdelimit(encoded_text, "_", ' ');
-
- if (!(decoded_text = (char *)rfc822_qprint((unsigned char *)encoded_text, EM_SAFE_STRLEN(encoded_text), &len))) {
- EM_DEBUG_EXCEPTION("rfc822_base64 falied...");
- goto FINISH_OFF;
- }
- }
-
- src.data = (unsigned char *)decoded_text;
- src.size = EM_SAFE_STRLEN(decoded_text);
-
- if (!utf8_text(&src, charset, &dst, 0)) {
- EM_DEBUG_EXCEPTION("utf8_text falied...");
- if (src.data)
- strncat(buffer, (char *)src.data, src.size); /* Eventhough failed to decode, downloading should go on. Kyuho Jo */
- } else {
- if (dst.data)
- strncat(buffer, (char *)dst.data, dst.size);
- }
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG("2 - Buffer[%s]", buffer);
-#endif
-
- /* free all of the temp variables */
- if (dst.data != NULL && dst.data != src.data)
- EM_SAFE_FREE(dst.data);
-
- EM_SAFE_FREE(decoded_text);
-
- g_free(encoded_text);
- encoded_text = NULL;
- }
- if (charset != NULL) {
- g_free(charset);
- charset = NULL;
- }
-
- if( *(end + 2) == ' ')
- current = end + 3; /* skip '?= ' */
- else
- current = end + 2; /* skip '?=' */
- }
- else {
- /* unencoded text */
- length = EM_SAFE_STRLEN(start);
- strncat(buffer, start, length);
- current = start + length;
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG("3 - Buffer[%s]", buffer);
-#endif
- }
- }
- else {
- /* unencoded text */
- char *tmp_buffer = NULL;
- char *charset_guess = emcore_guess_charset(current);
- length = EM_SAFE_STRLEN(current);
-
- if (charset_guess) {
- SIZEDTEXT extra_src = { NULL, 0 };
- SIZEDTEXT extra_dst = { NULL, 0 };
- extra_src.data = (unsigned char *)current;
- extra_src.size = length;
- if (!utf8_text(&extra_src, charset_guess, &extra_dst, 0)) {
- EM_DEBUG_EXCEPTION("utf8_text falied...");
- if (extra_src.data) {
- tmp_buffer = buffer;
- buffer = g_strconcat(tmp_buffer, (char *)extra_src.data, NULL);
- EM_SAFE_FREE(tmp_buffer);
- }
- } else {
- if (extra_dst.data) {
- tmp_buffer = buffer;
- buffer = g_strconcat(tmp_buffer, (char *)extra_dst.data, NULL);
- EM_SAFE_FREE(tmp_buffer);
- }
- }
-
- EM_SAFE_FREE(charset_guess);
- } else {
- tmp_buffer = buffer;
- buffer = g_strconcat(tmp_buffer, current, NULL);
- EM_SAFE_FREE(tmp_buffer);
- }
-
- current = current + length;
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG("4 - Buffer[%s]", buffer);
-#endif
- }
- }
-
- decoded_word = EM_SAFE_STRDUP(buffer);
-
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG(">>>>>>>>>>>>>>> DECODED_WORD[%s]", decoded_word);
-#endif
-
-FINISH_OFF:
- if (dst.data != NULL && dst.data != src.data)
- EM_SAFE_FREE(dst.data);
- EM_SAFE_FREE(decoded_text);
- EM_SAFE_FREE(buffer);
-
- if (encoded_text != NULL)
- g_free(encoded_text);
- if (charset != NULL)
- g_free(charset);
-
- if (err_code != NULL)
- *err_code = err;
-
- EM_DEBUG_FUNC_END();
- return decoded_word;
-}
-
-INTERNAL_FUNC char *emcore_decode_rfc2047_text(char *rfc2047_text, int *err_code)
+static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, struct _m_mesg *mmsg)
{
- EM_DEBUG_FUNC_BEGIN("rfc2047_text[%s], err_code[%p]", rfc2047_text, err_code);
-
+ EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- char *p = NULL;
- gchar **encoded_words = NULL;
- gchar **decoded_words = NULL;
-
- if (!rfc2047_text) {
- EM_DEBUG_EXCEPTION("rfc2047_text[%p]", rfc2047_text);
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return NULL;
- }
-
- char *p_text = NULL;
- char *text = NULL;
-
- text = strdup(rfc2047_text);
-
- /* Handle the no include charset */
- while (EM_SAFE_STRLEN(text) != 0) {
- if (g_str_has_prefix(text, "=?"))
- encoded_words = g_strsplit_set(text, "\t\r\n ", -1);
- else
- encoded_words = g_strsplit_set(text, "\t\r\n", -1);
- decoded_words = g_new0(char *, g_strv_length(encoded_words) + 1);
-
- EM_DEBUG_LOG_DEV("rfc2047_text [%s]", text);
- EM_DEBUG_LOG_DEV("g_strv_length(encoded_words) [%d]", g_strv_length(encoded_words));
- if (encoded_words != NULL) {
- int i = 0;
-
- while (encoded_words[i] != NULL) {
- EM_DEBUG_LOG_DEV("encoded_words[%d] [%s]", i, encoded_words[i]);
- if (!(decoded_words[i] = emcore_decode_rfc2047_word(encoded_words[i], &err))) {
- EM_DEBUG_EXCEPTION("emcore_decode_rfc2047_word falied [%d]", err);
- goto FINISH_OFF;
- }
- EM_DEBUG_LOG_DEV("decoded_words[%d] [%s]", i, decoded_words[i]);
- i++;
- }
-
- p_text = g_strjoinv("", decoded_words);
- }
- else
- p_text = EM_SAFE_STRDUP(text);
-
-
- if (p_text) {
- p = strstr(p_text, LF_STRING);
- if (p) *p = '\0';
- }
-#ifdef FEATURE_CORE_DEBUG
- EM_DEBUG_LOG(">>>>>>>>>>>>>>>>> TEXT[%s]", p_text);
-#endif /* FEATURE_CORE_DEBUG */
-
- char *charset_guess = NULL;
- charset_guess = emcore_guess_charset(p_text);
- EM_DEBUG_LOG("charset : [%s]", charset_guess);
-
- EM_SAFE_FREE(text);
- text = EM_SAFE_STRDUP(p_text);
- EM_SAFE_FREE(p_text);
-
- if (charset_guess && !strcasecmp(charset_guess, "euc-kr")) {
- EM_SAFE_FREE(charset_guess);
- } else {
- EM_SAFE_FREE(charset_guess);
- break;
- }
+ if (!mmsg || !dst_mail_data) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ return err;
}
-FINISH_OFF:
-
- EM_SAFE_FREE(p_text);
- g_strfreev(decoded_words);
- g_strfreev(encoded_words);
-
- if (err_code != NULL)
- *err_code = err;
- EM_DEBUG_FUNC_END();
- return text;
-}
-
-static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, struct _m_mesg *mmsg)
-{
- EM_DEBUG_FUNC_BEGIN();
- int err = EMAIL_ERROR_NONE;
-
- if (!mmsg || !dst_mail_data) {
- EM_DEBUG_EXCEPTION("Invalid parameter");
- err = EMAIL_ERROR_INVALID_PARAM;
- return err;
- }
-
char *encoded_subject = NULL;
char *first_address = NULL;
char *first_alias = NULL;
struct tm temp_time_info;
- ADDRESS *from = NULL;
- ADDRESS *to = NULL;
- ADDRESS *cc = NULL;
- ADDRESS *bcc = NULL;
+ ADDRESS *from = NULL;
+ ADDRESS *to = NULL;
+ ADDRESS *cc = NULL;
+ ADDRESS *bcc = NULL;
ADDRESS *return_path = NULL;
ADDRESS *reply_to = NULL;
MESSAGECACHE mail_cache_element = {0, };
@@ -5233,17 +961,17 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s
memset((void *)&temp_time_info, 0, sizeof(struct tm));
/* Set the smime_type */
- if (mmsg->rfc822header && mmsg->rfc822header->content_type) {
- if (strcasestr(mmsg->rfc822header->content_type, "pkcs7-mime")) {
+ if (mmsg->rfc822header && mmsg->rfc822header->content_type) {
+ if (strcasestr(mmsg->rfc822header->content_type, "pkcs7-mime")) {
if (strcasestr(mmsg->rfc822header->content_type, "enveloped-data"))
- dst_mail_data->smime_type = EMAIL_SMIME_ENCRYPTED;
+ dst_mail_data->smime_type = EMAIL_SMIME_ENCRYPTED;
else
dst_mail_data->smime_type = EMAIL_SMIME_SIGNED_AND_ENCRYPTED;
} else if (strcasestr(mmsg->rfc822header->content_type, "encrypted")) {
- dst_mail_data->smime_type = EMAIL_PGP_ENCRYPTED;
+ dst_mail_data->smime_type = EMAIL_PGP_ENCRYPTED;
} else if (strcasestr(mmsg->rfc822header->content_type, "signed")) {
if (strcasestr(mmsg->rfc822header->content_type, "pkcs7-signature"))
- dst_mail_data->smime_type = EMAIL_SMIME_SIGNED;
+ dst_mail_data->smime_type = EMAIL_SMIME_SIGNED;
else
dst_mail_data->smime_type = EMAIL_PGP_SIGNED;
@@ -5251,7 +979,7 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s
} else {
dst_mail_data->smime_type = EMAIL_SMIME_NONE;
}
- }
+ }
/* Set the priority */
if (mmsg->rfc822header) {
@@ -5305,87 +1033,85 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s
}
if (!mmsg->rfc822header) {
- EM_DEBUG_LOG("This mail did not have envelop");
- return err;
- }
+ EM_DEBUG_LOG("This mail did not have envelop");
+ return err;
+ }
/* Set the date */
- if (mmsg->rfc822header->date) {
- EM_DEBUG_LOG("date : [%s]", mmsg->rfc822header->date);
- mail_parse_date(&mail_cache_element, (unsigned char *)mmsg->rfc822header->date);
- }
+ if (mmsg->rfc822header->date) {
+ EM_DEBUG_LOG("date : [%s]", mmsg->rfc822header->date);
+ mail_parse_date(&mail_cache_element, (unsigned char *)mmsg->rfc822header->date);
+ }
- temp_time_info.tm_sec = mail_cache_element.seconds;
- temp_time_info.tm_min = mail_cache_element.minutes - mail_cache_element.zminutes;
- temp_time_info.tm_hour = mail_cache_element.hours - mail_cache_element.zhours;
+ temp_time_info.tm_sec = mail_cache_element.seconds;
+ temp_time_info.tm_min = mail_cache_element.minutes - mail_cache_element.zminutes;
+ temp_time_info.tm_hour = mail_cache_element.hours - mail_cache_element.zhours;
- if (mail_cache_element.hours - mail_cache_element.zhours < 0) {
- temp_time_info.tm_mday = mail_cache_element.day - 1;
- temp_time_info.tm_hour += 24;
- } else
- temp_time_info.tm_mday = mail_cache_element.day;
+ if (mail_cache_element.hours - mail_cache_element.zhours < 0) {
+ temp_time_info.tm_mday = mail_cache_element.day - 1;
+ temp_time_info.tm_hour += 24;
+ } else
+ temp_time_info.tm_mday = mail_cache_element.day;
- temp_time_info.tm_mon = mail_cache_element.month - 1;
- temp_time_info.tm_year = mail_cache_element.year + 70;
+ temp_time_info.tm_mon = mail_cache_element.month - 1;
+ temp_time_info.tm_year = mail_cache_element.year + 70;
- dst_mail_data->date_time = timegm(&temp_time_info);
+ dst_mail_data->date_time = timegm(&temp_time_info);
/* Set the subject */
- encoded_subject = emcore_decode_rfc2047_text(mmsg->rfc822header->subject, NULL);
- dst_mail_data->subject = EM_SAFE_STRDUP(encoded_subject);
+ dst_mail_data->subject = EM_SAFE_STRDUP(mmsg->rfc822header->subject);
/* Set the email address(from, to, cc, bcc, received ...) */
- dst_mail_data->email_address_recipient = EM_SAFE_STRDUP(mmsg->rfc822header->received);
-
- if (mmsg->rfc822header->from) {
- rfc822_parse_adrlist(&from, mmsg->rfc822header->from, NULL);
- if (!emcore_get_utf8_address(&dst_mail_data->full_address_from, from, &err)) {
- EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->from);
- }
- }
-
- if (mmsg->rfc822header->to) {
- rfc822_parse_adrlist(&to, mmsg->rfc822header->to, NULL);
- if (!emcore_get_utf8_address(&dst_mail_data->full_address_to, to, &err)) {
- EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->to);
- }
- }
-
- if (mmsg->rfc822header->cc) {
- rfc822_parse_adrlist(&cc, mmsg->rfc822header->cc, NULL);
- if (!emcore_get_utf8_address(&dst_mail_data->full_address_cc, cc, &err)) {
- EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->cc);
- }
- }
-
- if (mmsg->rfc822header->bcc) {
- rfc822_parse_adrlist(&bcc, mmsg->rfc822header->bcc, NULL);
- if (!emcore_get_utf8_address(&dst_mail_data->full_address_bcc, bcc, &err)) {
- EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->bcc);
- }
- }
-
- if (mmsg->rfc822header->return_path) {
- rfc822_parse_adrlist(&return_path, mmsg->rfc822header->return_path, NULL);
- if (!emcore_get_utf8_address(&dst_mail_data->full_address_return, return_path, &err)) {
- EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->return_path);
- }
- }
-
- if (mmsg->rfc822header->reply_to) {
- rfc822_parse_adrlist(&reply_to, mmsg->rfc822header->reply_to, NULL);
- if (!emcore_get_utf8_address(&dst_mail_data->full_address_reply, reply_to, &err)) {
- EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->reply_to);
- }
- }
+ dst_mail_data->email_address_recipient = EM_SAFE_STRDUP(mmsg->rfc822header->received);
+
+ if (mmsg->rfc822header->from) {
+ rfc822_parse_adrlist(&from, mmsg->rfc822header->from, NULL);
+ if (!emcore_get_utf8_address(&dst_mail_data->full_address_from, from, &err)) {
+ EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->from);
+ }
+ }
+
+ if (mmsg->rfc822header->to) {
+ rfc822_parse_adrlist(&to, mmsg->rfc822header->to, NULL);
+ if (!emcore_get_utf8_address(&dst_mail_data->full_address_to, to, &err)) {
+ EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->to);
+ }
+ }
+
+ if (mmsg->rfc822header->cc) {
+ rfc822_parse_adrlist(&cc, mmsg->rfc822header->cc, NULL);
+ if (!emcore_get_utf8_address(&dst_mail_data->full_address_cc, cc, &err)) {
+ EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->cc);
+ }
+ }
+
+ if (mmsg->rfc822header->bcc) {
+ rfc822_parse_adrlist(&bcc, mmsg->rfc822header->bcc, NULL);
+ if (!emcore_get_utf8_address(&dst_mail_data->full_address_bcc, bcc, &err)) {
+ EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->bcc);
+ }
+ }
+
+ if (mmsg->rfc822header->return_path) {
+ rfc822_parse_adrlist(&return_path, mmsg->rfc822header->return_path, NULL);
+ if (!emcore_get_utf8_address(&dst_mail_data->full_address_return, return_path, &err)) {
+ EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->return_path);
+ }
+ }
+
+ if (mmsg->rfc822header->reply_to) {
+ rfc822_parse_adrlist(&reply_to, mmsg->rfc822header->reply_to, NULL);
+ if (!emcore_get_utf8_address(&dst_mail_data->full_address_reply, reply_to, &err)) {
+ EM_DEBUG_EXCEPTION_SEC("emcore_get_utf8_address failed : [%d], [%s]", err, mmsg->rfc822header->reply_to);
+ }
+ }
if (emcore_get_first_address(dst_mail_data->full_address_from, &first_alias, &first_address) == true) {
dst_mail_data->alias_sender = EM_SAFE_STRDUP(first_alias);
dst_mail_data->email_address_sender = EM_SAFE_STRDUP(first_address);
}
-
EM_SAFE_FREE(encoded_subject);
EM_SAFE_FREE(first_alias);
EM_SAFE_FREE(first_address);
@@ -5412,20 +1138,27 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s
return err;
}
-INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, struct _m_content_info *cnt_info, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count, int *err_code)
+INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
+ struct _m_content_info *cnt_info,
+ email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data,
+ int *output_attachment_count,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int i = 0;
int ret = false;
- int eml_mail_id = 0;
+ int eml_mail_id = 0;
int err = EMAIL_ERROR_NONE;
int save_status = EMAIL_BODY_DOWNLOAD_STATUS_NONE;
int attachment_num = 0;
int local_attachment_count = 0;
int local_inline_content_count = 0;
- char buf[512];
+ char move_buf[512];
+ char path_buf[512];
char html_body[MAX_PATH] = {0, };
- struct timeval tv;
+ char *multi_user_name = NULL;
+ struct timeval tv;
struct attachment_info *ai = NULL;
email_attachment_data_t *attachment = NULL;
email_mail_data_t *p_mail_data = NULL;
@@ -5452,35 +1185,43 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, str
p_mail_data->account_id = EML_FOLDER;
p_mail_data->mail_size = cnt_info->total_body_size;
- if ((err = emcore_make_mail_data_from_m_mesg(p_mail_data, mmsg)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_make_mail_data_from_m_mesg failed : [%d]", err);
- }
+ if ((err = emcore_make_mail_data_from_m_mesg(p_mail_data, mmsg)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_make_mail_data_from_m_mesg failed : [%d]", err);
+ }
EM_DEBUG_LOG("cnt_info->text.plain [%s], cnt_info->text.html [%s]", cnt_info->text.plain, cnt_info->text.html);
if (cnt_info->text.plain) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
EM_DEBUG_LOG("cnt_info->text.plain [%s]", cnt_info->text.plain);
- if (!emstorage_create_dir(EML_FOLDER, eml_mail_id, 0, &err)) {
+ if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(EML_FOLDER, eml_mail_id, 0, cnt_info->text.plain_charset ? cnt_info->text.plain_charset : UNKNOWN_CHARSET_PLAIN_TEXT_FILE, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0,
+ cnt_info->text.plain_charset ? cnt_info->text.plain_charset : UNKNOWN_CHARSET_PLAIN_TEXT_FILE,
+ move_buf, path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(cnt_info->text.plain, buf, false, &err)) {
+ if (!emstorage_move_file(cnt_info->text.plain, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
- p_mail_data->file_path_plain = EM_SAFE_STRDUP(buf);
+ p_mail_data->file_path_plain = EM_SAFE_STRDUP(path_buf);
save_status = cnt_info->text.plain_save_status;
}
if (cnt_info->text.html) {
- if (!emstorage_create_dir(EML_FOLDER, eml_mail_id, 0, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
@@ -5491,21 +1232,51 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, str
strcpy(html_body, UNKNOWN_CHARSET_HTML_TEXT_FILE);
}
- if (!emstorage_get_save_name(EML_FOLDER, eml_mail_id, 0, html_body, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id,
+ 0, html_body, move_buf, path_buf,
+ sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(cnt_info->text.html, buf, false, &err)) {
+ if (!emstorage_move_file(cnt_info->text.html, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
- p_mail_data->file_path_html = EM_SAFE_STRDUP(buf);
+ p_mail_data->file_path_html = EM_SAFE_STRDUP(path_buf);
save_status = cnt_info->text.html_save_status;
}
- if ((err = emcore_get_preview_text_from_file(p_mail_data->file_path_plain, p_mail_data->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &p_mail_data->preview_text)) != EMAIL_ERROR_NONE)
+ if (cnt_info->text.mime_entity) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id,
+ 0, "mime_entity", move_buf, path_buf,
+ sizeof(path_buf), &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (!emstorage_move_file(cnt_info->text.mime_entity, move_buf, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ p_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(path_buf);
+ }
+
+ if ((err = emcore_get_preview_text_from_file(multi_user_name,
+ p_mail_data->file_path_plain,
+ p_mail_data->file_path_html,
+ MAX_PREVIEW_TEXT_LENGTH,
+ &p_mail_data->preview_text)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file error [%d]", err);
for (ai = cnt_info->file; ai; ai = ai->next, local_attachment_count++) {}
@@ -5542,29 +1313,36 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, str
EM_DEBUG_LOG_SEC("attachment[%d].attachment_name[%s]", i, attachment[i].attachment_name);
EM_DEBUG_LOG("attachment[%d].drm_status[%d]", i, attachment[i].drm_status);
EM_DEBUG_LOG("attachment[%d].inline_content_status[%d]", i, attachment[i].inline_content_status);
- EM_DEBUG_LOG("attachment[%d].attachment_mime_type : [%s]", i, attachment[i].attachment_mime_type);
+ EM_DEBUG_LOG("attachment[%d].attachment_mime_type : [%s]", i, attachment[i].attachment_mime_type);
if (ai->save) {
- if (!emstorage_create_dir(EML_FOLDER, eml_mail_id, i + 1, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, i + 1, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(EML_FOLDER, eml_mail_id, i + 1, attachment[i].attachment_name, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id,
+ i + 1, attachment[i].attachment_name, move_buf,
+ path_buf, sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(ai->save, buf, false, &err)) {
+ if (!emstorage_move_file(ai->save, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
/* delete all created files. */
- if (!emstorage_get_save_name(EML_FOLDER, eml_mail_id, 0, NULL, buf, sizeof(buf), NULL)) {
+ if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id,
+ 0, NULL, move_buf, path_buf,
+ sizeof(path_buf), NULL)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed...");
/* goto FINISH_OFF; */
}
- if (!emstorage_delete_dir(buf, NULL)) {
+ if (!emstorage_delete_dir(move_buf, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_delete_dir failed...");
/* goto FINISH_OFF; */
}
@@ -5573,7 +1351,7 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, str
goto FINISH_OFF;
}
- attachment[i].attachment_path = EM_SAFE_STRDUP(buf);
+ attachment[i].attachment_path = EM_SAFE_STRDUP(path_buf);
}
EM_DEBUG_LOG_SEC("attachment[%d].attachment_path[%s]", i, attachment[i].attachment_path);
@@ -5598,29 +1376,35 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, str
EM_DEBUG_LOG_SEC("attachment[%d].attachment_name[%s]", i, attachment[i].attachment_name);
EM_DEBUG_LOG("attachment[%d].drm_status[%d]", i, attachment[i].drm_status);
EM_DEBUG_LOG("attachment[%d].inline_content_status[%d]", i, attachment[i].inline_content_status);
- EM_DEBUG_LOG("attachment[%d].attachment_mime_type : [%s]", i, attachment[i].attachment_mime_type);
+ EM_DEBUG_LOG("attachment[%d].attachment_mime_type : [%s]", i, attachment[i].attachment_mime_type);
if (ai->save) {
- if (!emstorage_create_dir(EML_FOLDER, eml_mail_id, 0, &err)) {
+ memset(move_buf, 0x00, sizeof(move_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(EML_FOLDER, eml_mail_id, 0, attachment[i].attachment_name, buf, sizeof(buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0,
+ attachment[i].attachment_name, move_buf, path_buf,
+ sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(ai->save, buf, false, &err)) {
+ if (!emstorage_move_file(ai->save, move_buf, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
/* delete all created files. */
- if (!emstorage_get_save_name(EML_FOLDER, eml_mail_id, 0, NULL, buf, sizeof(buf), NULL)) {
+ if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0,
+ NULL, move_buf, path_buf, sizeof(path_buf), NULL)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed...");
/* goto FINISH_OFF; */
}
- if (!emstorage_delete_dir(buf, NULL)) {
+ if (!emstorage_delete_dir(move_buf, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_delete_dir failed...");
/* goto FINISH_OFF; */
}
@@ -5629,7 +1413,7 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, str
goto FINISH_OFF;
}
- attachment[i].attachment_path = EM_SAFE_STRDUP(buf);
+ attachment[i].attachment_path = EM_SAFE_STRDUP(path_buf);
}
EM_DEBUG_LOG_SEC("attachment[%d].attachment_path[%s]", i, attachment[i].attachment_path);
@@ -5675,13 +1459,16 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count, int *err_code)
+INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path,
+ email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data,
+ int *output_attachment_count,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("eml_file_path : [%s], output_mail_data : [%p]", eml_file_path, output_mail_data);
int err = EMAIL_ERROR_NONE;
int ret = false;
- char buf[512];
char *mime_entity = NULL;
struct _m_content_info *cnt_info = NULL;
struct _m_mesg *mmsg = NULL;
@@ -5718,37 +1505,24 @@ INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path, email_mail
emcore_gmime_init();
if (!emcore_gmime_eml_parse_mime(eml_file_path, mmsg->rfc822header, cnt_info, &err)) {
+ emcore_gmime_shutdown();
EM_DEBUG_EXCEPTION("emcore_gmime_parse_mime failed : [%d]", err);
err = EMAIL_ERROR_INVALID_DATA;
- emcore_gmime_shutdown();
goto FINISH_OFF;
}
- emcore_gmime_shutdown();
- if (!emcore_make_mail_data_from_mime_data(mmsg, cnt_info, output_mail_data, output_attachment_data, output_attachment_count, &err)) {
+ if (!emcore_make_mail_data_from_mime_data(mmsg,
+ cnt_info,
+ output_mail_data,
+ output_attachment_data,
+ output_attachment_count,
+ &err)) {
+ emcore_gmime_shutdown();
EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_mime failed : [%d]", err);
goto FINISH_OFF;
}
-
- if ((*output_mail_data)->smime_type == EMAIL_SMIME_SIGNED || (*output_mail_data)->smime_type == EMAIL_PGP_SIGNED) {
- if (!emcore_get_mime_entity(eml_file_path, &mime_entity, &err)) {
- EM_DEBUG_EXCEPTION("emcore_get_mime_entity failed: [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_get_save_name((*output_mail_data)->account_id, (*output_mail_data)->mail_id, 0, "mime_entity", buf, sizeof(buf), &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_save_name failed : [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!emstorage_move_file(mime_entity, buf, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
- goto FINISH_OFF;
- }
-
- (*output_mail_data)->file_path_mime_entity = EM_SAFE_STRDUP(buf);
- }
+ emcore_gmime_shutdown();
ret = true;
@@ -5771,12 +1545,13 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_delete_parsed_data(email_mail_data_t *input_mail_data, int *err_code)
+INTERNAL_FUNC int emcore_delete_parsed_data(char *multi_user_name, email_mail_data_t *input_mail_data, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p]", input_mail_data);
int err = EMAIL_ERROR_NONE;
int ret = false;
- char buf[512];
+ char buf[MAX_PATH] = {0};
+ char *prefix_path = NULL;
if (!input_mail_data) {
EM_DEBUG_EXCEPTION("Invliad parameter");
@@ -5790,25 +1565,41 @@ INTERNAL_FUNC int emcore_delete_parsed_data(email_mail_data_t *input_mail_data,
goto FINISH_OFF;
}
- eml_data_count = eml_data_count - 1;
-
- if (eml_data_count == 0) {
- SNPRINTF(buf, sizeof(buf), "%s%s%d", MAILHOME, DIR_SEPERATOR, input_mail_data->account_id);
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err);
+ goto FINISH_OFF;
+ }
} else {
- SNPRINTF(buf, sizeof(buf), "%s%s%d%s%d", MAILHOME, DIR_SEPERATOR, input_mail_data->account_id, DIR_SEPERATOR, input_mail_data->mail_id);
+ prefix_path = strdup("");
}
- EM_DEBUG_LOG("Directory : [%s]", buf);
+ if (!input_mail_data->mail_id) {
+ SNPRINTF(buf, sizeof(buf), "%s%s%s%d", prefix_path, MAILHOME, DIR_SEPERATOR, input_mail_data->account_id);
+ } else {
+ SNPRINTF(buf, sizeof(buf), "%s%s%s%d%s%d", prefix_path, MAILHOME, DIR_SEPERATOR, input_mail_data->account_id, DIR_SEPERATOR, input_mail_data->mail_id);
+ }
if (!emstorage_delete_dir(buf, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_delete_dir failed");
- goto FINISH_OFF;
+ EM_DEBUG_LOG("emstorage_delete_dir failed : buf[%s]", buf);
+ memset(buf, 0x00, sizeof(buf));
+ SNPRINTF(buf, sizeof(buf), "%s%s%d", MAILHOME, DIR_SEPERATOR, input_mail_data->account_id);
+
+ if (!emstorage_delete_dir(buf, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_delete_dir failed : buf[%s]", buf);
+ goto FINISH_OFF;
+ }
+
+ err = EMAIL_ERROR_NONE;
}
ret = true;
FINISH_OFF:
+ EM_SAFE_FREE(prefix_path);
+
if (err_code)
*err_code = err;
@@ -5818,22 +1609,10 @@ FINISH_OFF:
INTERNAL_FUNC int emcore_get_mime_entity(char *mime_path, char **output_path, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mime_path : [%s], output_path : [%p]", mime_path, output_path);
- int ret = false;
int err = EMAIL_ERROR_NONE;
- int is_file = 1;
- int search = 0;
- long start_mime_entity = 0;
- long end_mime_entity = 0;
- char buf[MIME_LINE_LEN] = {0x00, };
- char *mime_entity_path = NULL;
- char *content_type = NULL;
- char boundary[BOUNDARY_LEN] = {0x00,};
- char *boundary_string = NULL;
- char *p_mime_entity = NULL;
- FILE *fp_read = NULL;
- FILE *fp_write = NULL;
- struct _m_mesg *mmsg = NULL;
- char errno_buf[ERRNO_BUF_SIZE] = {0};
+ int ret = false;
+ int fd = 0;
+ char *tmp_path = NULL;
if (!mime_path) {
EM_DEBUG_EXCEPTION("Invalid parameter");
@@ -5841,385 +1620,38 @@ INTERNAL_FUNC int emcore_get_mime_entity(char *mime_path, char **output_path, in
goto FINISH_OFF;
}
- /* Get the header info */
- mmsg = (struct _m_mesg *)em_malloc(sizeof(struct _m_mesg));
- if (mmsg == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- err = em_fopen(mime_path, "r", &fp_read);
+ err = em_open(mime_path, O_RDONLY, 0, &fd);
if (err != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION_SEC("File em_fopen(read) is failed : filename [%s][%d]", mime_path, err);
- goto FINISH_OFF;
- }
-
- if (!emcore_mime_parse_header(fp_read, is_file, &mmsg->rfc822header, &mmsg->header, &err)) {
- EM_DEBUG_EXCEPTION("emcore_mime_parse_header failed : [%d]", err);
- err = EMAIL_ERROR_INVALID_DATA;
- goto FINISH_OFF;
- }
-
- /* Parsing the mime header */
- content_type = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_TYPE, NULL);
- EM_DEBUG_LOG_SEC("Content_type : [%s]", content_type);
- if (content_type && strcasestr(content_type, "signed")==NULL) {
- EM_DEBUG_EXCEPTION("Invalid parameter : No signed mail");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- /* Create mime_entity file */
- if (!emcore_get_temp_file_name(&mime_entity_path, &err)) {
- EM_DEBUG_EXCEPTION("emcore_get_temp_file_name failed[%d]", err);
- goto FINISH_OFF;
- }
- EM_DEBUG_LOG("mime_entity_path = %s", mime_entity_path);
-
- err = em_fopen(mime_entity_path, "w", &fp_write);
- if (err != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION_SEC("File em_fopen(write) is failed : filename [%s][%d]", mime_entity_path, err);
- goto FINISH_OFF;
- }
-
- boundary_string = emcore_mime_get_header_value(mmsg->header->part_header, CONTENT_BOUNDARY, NULL);
- SNPRINTF(boundary, BOUNDARY_LEN, "--%s%s", boundary_string, CRLF_STRING);
-
- while (TRUE) {
- if (!emcore_get_line_from_file((void *)fp_read, buf, MIME_LINE_LEN, &err)) {
- if (err == EMAIL_ERROR_NO_MORE_DATA) {
- EM_DEBUG_LOG("this mail is partial body");
- end_mime_entity = ftell(fp_read);
- if ( end_mime_entity < 0 ) {
- EM_DEBUG_EXCEPTION("ftell failed [%s]", EM_STRERROR(errno_buf));
- goto FINISH_OFF;
- }
- err = EMAIL_ERROR_NONE;
- break;
- }
- EM_DEBUG_EXCEPTION("emcore_mime_get_line_from_file failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if (!strcmp(buf, boundary)) {
- search++;
- if (search == 1) {
- start_mime_entity = ftell(fp_read);
- if( start_mime_entity < 0 ) { /*prevent 24473*/
- EM_DEBUG_EXCEPTION("ftell failed [%s]", EM_STRERROR(errno_buf));
- goto FINISH_OFF;
- }
- } else if (search == 2) {
- end_mime_entity = ftell(fp_read);
- if( end_mime_entity < 0 ) { /*prevent 24473*/
- EM_DEBUG_EXCEPTION("ftell failed [%s]", EM_STRERROR(errno_buf));
- goto FINISH_OFF;
- }
- break;
- }
- }
- }
-
- p_mime_entity = em_malloc(end_mime_entity - start_mime_entity);
- if (p_mime_entity == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
+ EM_DEBUG_EXCEPTION("em_open failed");
goto FINISH_OFF;
}
- if (fseek(fp_read, start_mime_entity, SEEK_SET) < 0) {
- EM_DEBUG_EXCEPTION("fseek failed");
- err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
+ emcore_gmime_init();
+ tmp_path = emcore_gmime_get_mime_entity(fd);
+ emcore_gmime_shutdown();
- /* +2 : CRLF line */
- if ((ret = fread(p_mime_entity, 1, end_mime_entity - (start_mime_entity + EM_SAFE_STRLEN(boundary) + 2), fp_read)) < 0) {
- EM_DEBUG_EXCEPTION("fread failed");
- err = EMAIL_ERROR_SYSTEM_FAILURE;
+ if (tmp_path == NULL) {
+ EM_DEBUG_EXCEPTION("emcore_gmime_get_mime_entity failed");
+ err = EMAIL_ERROR_INVALID_DATA;
goto FINISH_OFF;
}
- fprintf(fp_write, "%s", p_mime_entity);
-
ret = true;
FINISH_OFF:
-
- if (fp_read)
- fclose(fp_read);
-
- if (fp_write)
- fclose(fp_write);
-
- if (mmsg)
- emcore_mime_free_mime(mmsg);
-
- if (output_path)
- *output_path = EM_SAFE_STRDUP(mime_entity_path);
- EM_SAFE_FREE(mime_entity_path);
+
+ EM_SAFE_CLOSE(fd);
if (err_code)
*err_code = err;
- EM_SAFE_FREE(p_mime_entity);
+ if (output_path)
+ *output_path = tmp_path;
EM_DEBUG_FUNC_END();
return ret;
}
-int emcore_decode_body_text_from_file(FILE *stream, char *boundary_str, int encoding, int mode, int fd, char **holder, int *end_of_parsing, int *size)
-{
- EM_DEBUG_FUNC_BEGIN();
- int error = EMAIL_ERROR_NONE;
- int p_size = 0;
- int partial_body = 0;
- int dec_len = 0;
- long start_location = 0;
- long end_location = 0;
- char boundary[BOUNDARY_LEN] = {0x00, };
- char boundary_end[BOUNDARY_LEN] = {0x00, };
- char buf[MIME_LINE_LEN] = {0x00, };
- char *body = NULL;
- int modified_body_size = 0;
- char *modified_body = NULL;
- char errno_buf[ERRNO_BUF_SIZE] = {0};
-
- if (boundary_str) {
- /* if there boundary, this content is from current line to ending boundary */
- memset(boundary, 0x00, BOUNDARY_LEN);
- memset(boundary_end, 0x00, BOUNDARY_LEN);
-
- SNPRINTF(boundary, BOUNDARY_LEN, "--%s%s", boundary_str, CRLF_STRING);
- SNPRINTF(boundary_end, BOUNDARY_LEN, "--%s%s", boundary_str, "--");
- }
-
- start_location = ftell(stream);
- if(start_location < 0 ) { /*prevent 35555*/
- error = EMAIL_ERROR_INVALID_PARAM;
- EM_DEBUG_EXCEPTION("ftell failed : %s", EM_STRERROR(errno_buf));
- goto FINISH_OFF;
- }
-
- while (TRUE) {
- if (!emcore_get_line_from_file(stream, buf, MIME_LINE_LEN, &error)) {
- if (error != EMAIL_ERROR_NO_MORE_DATA) {
- EM_DEBUG_EXCEPTION("emcore_get_line_from_file failed");
- error = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
- }
-
- if (boundary_str) {
- if (!strcmp(buf, boundary)) { /* the other part started. the parsing of other part will be started */
- *end_of_parsing = 0;
- break;
- }
- else if (strcasestr(buf, boundary_end)) { /* if ending boundary, the parsing of other multipart will be started */
- *end_of_parsing = 1;
- break;
- }
- }
-
- if (error != EMAIL_ERROR_NONE) {
- partial_body = 1;
- *end_of_parsing = 2;
- break;
- }
- }
-
- EM_DEBUG_LOG("partial_body : [%d], buf:[%s]", partial_body, buf);
- end_location = ftell(stream);
- if(end_location < 0 ) { /*prevent 35555*/
- error = EMAIL_ERROR_INVALID_PARAM;
- EM_DEBUG_EXCEPTION("ftell failed : %s", EM_STRERROR(errno_buf));
- goto FINISH_OFF;
- }
-
- if (partial_body)
- p_size = end_location - start_location;
- else
- p_size = end_location - start_location - EM_SAFE_STRLEN(buf);
-
- body = em_malloc(p_size + 1);
- if (body == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- fseek(stream, start_location, SEEK_SET);
- if (fread(body, sizeof(char), p_size, stream) != p_size) {
- EM_DEBUG_EXCEPTION("fread failed");
- error = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
-
- if (mode > SAVE_TYPE_SIZE) { /* decode content */
- emcore_decode_body_text(body, p_size, encoding, &dec_len, &error);
-
- modified_body = em_malloc(dec_len + 1);
- if (modified_body == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- memcpy(modified_body, body, dec_len); /*prevent 35585 */
- modified_body_size = dec_len;
-
- if (mode == SAVE_TYPE_BUFFER) { /* save content to buffer */
- *holder = EM_SAFE_STRDUP(modified_body);
- } else if (mode == SAVE_TYPE_FILE) { /* save content to file */
- EM_DEBUG_LOG("Before write : size[%d]", modified_body_size);
- if (write(fd, modified_body, modified_body_size) != modified_body_size) {
- EM_DEBUG_EXCEPTION("write failed");
- error = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
- }
- }
-
- fseek((FILE *)stream, end_location, SEEK_SET);
-
-FINISH_OFF:
-
- if (size)
- *size = modified_body_size;
-
- EM_SAFE_FREE(modified_body);
- EM_SAFE_FREE(body); /*prevent 35585 */
- return error;
-}
-
-int emcore_decode_body_text_from_sock(void *stream, char *boundary_str, int encoding, int mode, int fd, char **holder, int *end_of_parsing, int *size)
-{
- EM_DEBUG_FUNC_BEGIN();
- int error = EMAIL_ERROR_NONE;
- int sz = 0;
- int dec_len = 0;
- char boundary[BOUNDARY_LEN] = {0x00, };
- char boundary_end[BOUNDARY_LEN] = {0x00, };
- char buf[MIME_LINE_LEN] = {0x00, };
- char *result_buffer = NULL;
- int result_buffer_size = 0;
- char *pTemp = NULL;
-
- if (boundary_str) {
- /* if there boundary, this content is from current line to ending boundary */
- memset(boundary, 0x00, BOUNDARY_LEN);
- memset(boundary_end, 0x00, BOUNDARY_LEN);
-
- SNPRINTF(boundary, BOUNDARY_LEN, "--%s%s", boundary_str, CRLF_STRING);
- SNPRINTF(boundary_end, BOUNDARY_LEN, "--%s%s", boundary_str, "--\r\n");
- }
-
- while (TRUE) {
-/* don't delete the comment. several threads including event thread call it
- if (!emcore_check_thread_status()) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_CANCELLED");
- error = EMAIL_ERROR_CANCELLED;
- goto FINISH_OFF;
- }
-*/
- if (!emcore_mime_get_line_from_sock(stream, buf, MIME_LINE_LEN, &error)) {
- if (error != EMAIL_ERROR_NO_MORE_DATA) {
- EM_DEBUG_EXCEPTION("emcore_mime_get_line_from_sock failed");
- error = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
-
- EM_DEBUG_LOG("This mail is partial body");
-
- *end_of_parsing = 2;
-
- error = EMAIL_ERROR_NONE;
-
- break;
- }
-
- if (boundary_str) {
- if (!strcmp(buf, boundary)) { /* the other part started. the parsing of other part will be started */
- *end_of_parsing = 0;
- break;
- }
- else if (!strcmp(buf, boundary_end)) { /* if ending boundary, the parsing of other multipart will be started */
- *end_of_parsing = 1;
- break;
- }
- }
-
- /* parsing string started by '.' in POP3 */
- if ((buf[0] == '.' && buf[1] == '.') && (encoding == ENCQUOTEDPRINTABLE || encoding == ENC7BIT)) {
- strncpy(buf, buf+1, MIME_LINE_LEN-1);
- buf[EM_SAFE_STRLEN(buf)] = NULL_CHAR;
- }
-
- if (encoding == ENCBASE64) {
- if (EM_SAFE_STRLEN(buf) >= 2)
- buf[EM_SAFE_STRLEN(buf)-2] = NULL_CHAR;
- } else if (encoding == ENCQUOTEDPRINTABLE) {
-/* if (strcmp(buf, CRLF_STRING) == 0 */
-/* continue */
- }
-
- dec_len = EM_SAFE_STRLEN(buf);
-
- if (mode > SAVE_TYPE_SIZE) { /* decode content */
- emcore_decode_body_text(buf, dec_len, encoding, &dec_len, &error);
-
- result_buffer = em_malloc(dec_len + 1);
- if (result_buffer == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- error = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- memcpy(result_buffer, buf, dec_len); /*prevent 35499*/
- result_buffer_size = dec_len;
-
- if (mode == SAVE_TYPE_BUFFER) { /* save content to buffer */
- pTemp = realloc(*holder, sz + result_buffer_size + 2);
- if (!pTemp) {
- EM_DEBUG_EXCEPTION("realloc failed...");
- error = EMAIL_ERROR_OUT_OF_MEMORY;
-
- EM_SAFE_FREE(*holder);
- EM_SAFE_FREE(result_buffer);
- goto FINISH_OFF;
- }
- else
- *holder = pTemp;
-
- memcpy(*holder + sz, result_buffer, result_buffer_size);
- (*holder)[sz + EM_SAFE_STRLEN(result_buffer) + 1] = NULL_CHAR;
- } else if (mode == SAVE_TYPE_FILE) { /* save content to file */
- if (write(fd, result_buffer, result_buffer_size) != result_buffer_size) {
- EM_DEBUG_EXCEPTION("write failed");
- error = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
- }
-
- EM_SAFE_FREE(result_buffer);
- }
- sz += dec_len;
- }
-
-FINISH_OFF:
-
- EM_SAFE_FREE(result_buffer); /*prevent 35499*/
-
- if (error == EMAIL_ERROR_NONE) {
- if (size)
- *size = sz;
- }
-
- EM_DEBUG_FUNC_END("error [%d], sz[%d]", error, sz);
- return error;
-}
-
INTERNAL_FUNC int emcore_get_digest_type(char *micalg_value)
{
EM_DEBUG_FUNC_BEGIN();
diff --git a/email-core/email-core-mm-callbacks.c b/email-core/email-core-mm-callbacks.c
index 5bbb5ea..8990b9f 100755
--- a/email-core/email-core-mm-callbacks.c
+++ b/email-core/email-core-mm-callbacks.c
@@ -210,16 +210,26 @@ INTERNAL_FUNC void mm_login(NETMBX *mb, char *user, char *pwd, long trial)
char *password = NULL;
char *token = NULL;
char *save_ptr = NULL;
+ char *user_info = NULL;
+ char *temp = NULL;
+ char *multi_user_name = NULL;
if (!mb->user[0]) {
EM_DEBUG_EXCEPTION("invalid account_id...");
goto FINISH_OFF;
}
- account_id = atoi(mb->user);
+ user_info = EM_SAFE_STRDUP(mb->user);
- ref_account = emcore_get_account_reference(account_id);
+ token = strtok_r(user_info, TOKEN_FOR_MULTI_USER, &temp);
+ EM_DEBUG_LOG_SEC("Token : [%s], multi_user_name:[%s][%d]", token, temp, EM_SAFE_STRLEN(temp));
+ account_id = atoi(token);
+ token = NULL;
+ if (temp != NULL && EM_SAFE_STRLEN(temp) > 0)
+ multi_user_name = EM_SAFE_STRDUP(temp);
+
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, true);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed");
goto FINISH_OFF;
@@ -240,7 +250,6 @@ INTERNAL_FUNC void mm_login(NETMBX *mb, char *user, char *pwd, long trial)
EM_DEBUG_LOG("incoming_server_authentication_method [%d]", ref_account->incoming_server_authentication_method);
if(ref_account->incoming_server_authentication_method == EMAIL_AUTHENTICATION_METHOD_XOAUTH2) {
-
token = strtok_r(ref_account->incoming_server_password, "\001", &save_ptr);
EM_DEBUG_LOG_SEC("token [%s]", token);
password = EM_SAFE_STRDUP(token);
@@ -263,8 +272,10 @@ FINISH_OFF:
EM_SAFE_FREE(ref_account);
}
+ EM_SAFE_FREE(user_info);
EM_SAFE_FREE(username);
EM_SAFE_FREE(password);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -280,7 +291,7 @@ INTERNAL_FUNC void mm_dlog(char *string)
INTERNAL_FUNC void mm_log(char *string, long errflg)
{
- switch ((short)errflg) {
+ switch (errflg) {
case NIL:
EM_DEBUG_LOG("IMAP_TOOLKIT_LOG [%s]", string);
break;
diff --git a/email-core/email-core-pgp.c b/email-core/email-core-pgp.c
index 4367af9..17afa56 100644
--- a/email-core/email-core-pgp.c
+++ b/email-core/email-core-pgp.c
@@ -61,7 +61,9 @@
static char *passphrase = NULL;
-static gboolean request_passwd(GMimeCryptoContext *ctx, const char *user_id, const char *prompt_ctx, gboolean reprompt, GMimeStream *response, GError **err)
+static gboolean request_passwd(GMimeCryptoContext *ctx, const char *user_id,
+ const char *prompt_ctx, gboolean reprompt,
+ GMimeStream *response, GError **err)
{
EM_DEBUG_FUNC_BEGIN();
EM_DEBUG_LOG("passpharse : [%s]", passphrase);
@@ -128,12 +130,11 @@ static int emcore_pgp_get_gmime_digest_algo(email_digest_type digest_type)
static int get_stack_of_recipients(char *recipients, GPtrArray **output_recipients_array) {
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- int i, j = 0;
- char *temp_recipients = NULL;
- char *email_address = NULL;
-
- ADDRESS *token_address = NULL;
+ char *temp_key = NULL;
+ char *keys = NULL;
GPtrArray *p_recipients_array = NULL;
+ gchar **strings = NULL;
+ gchar **ptr = NULL;
p_recipients_array = g_ptr_array_new();
if (p_recipients_array == NULL) {
@@ -142,22 +143,18 @@ static int get_stack_of_recipients(char *recipients, GPtrArray **output_recipien
goto FINISH_OFF;
}
- temp_recipients = EM_SAFE_STRDUP(recipients);
- for (i = 0, j = EM_SAFE_STRLEN(temp_recipients); i < j ; i++)
- if (temp_recipients[i] == ';') temp_recipients[i] = ',';
+ keys = EM_SAFE_STRDUP(recipients);
+ strings = g_strsplit(keys, ",", -1);
- rfc822_parse_adrlist(&token_address, temp_recipients, NULL);
+ for (ptr = strings; *ptr; ptr++){
+ temp_key = NULL;
+ temp_key = g_strdup_printf("0x%s",*(ptr));
+ g_ptr_array_add(p_recipients_array, temp_key);
+ }
- while (token_address) {
- email_address = NULL;
- email_address = g_strdup_printf("%s@%s", token_address->mailbox, token_address->host);
-
- g_ptr_array_add(p_recipients_array, email_address);
- token_address = token_address->next;
- }
-
FINISH_OFF:
-
+ g_strfreev(strings);
+ EM_SAFE_FREE(keys);
if (err != EMAIL_ERROR_NONE)
g_ptr_array_free(p_recipients_array, true);
else
@@ -171,25 +168,30 @@ static GMimeSignatureStatus get_signature_status(GMimeSignatureList *signatures)
{
EM_DEBUG_FUNC_BEGIN();
- int i = 0;
+ int i = 0;
- GMimeSignature *sig = NULL;
- GMimeSignatureStatus status = GMIME_SIGNATURE_STATUS_GOOD;
-
- if (!signatures || signatures->array->len == 0)
- return GMIME_SIGNATURE_STATUS_ERROR;
-
- for (i = 0; i < g_mime_signature_list_length(signatures); i++) {
- sig = g_mime_signature_list_get_signature(signatures, i);
- if (sig) status = MAX(status, sig->status);
- }
+ GMimeSignature *sig = NULL;
+ GMimeSignatureStatus status = GMIME_SIGNATURE_STATUS_GOOD;
+
+ if (!signatures || signatures->array->len == 0)
+ return GMIME_SIGNATURE_STATUS_ERROR;
+
+ for (i = 0; i < g_mime_signature_list_length(signatures); i++) {
+ sig = g_mime_signature_list_get_signature(signatures, i);
+ if (sig) status = MAX(status, sig->status);
+ }
EM_DEBUG_FUNC_END();
return status;
}
-INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate, char *password, char *mime_entity, char *user_id, email_digest_type digest_type, char **file_path)
+INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate,
+ char *password,
+ char *mime_entity,
+ char *user_id,
+ email_digest_type digest_type,
+ char **file_path)
{
EM_DEBUG_FUNC_BEGIN_SEC("Certificate path : [%s], mime_entity : [%s]", certificate, mime_entity);
@@ -258,7 +260,12 @@ INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate, char *passwor
p_digest_type = emcore_pgp_get_gmime_digest_algo(digest_type);
/* Set the signed message */
- if ((g_mime_crypto_context_sign(ctx, user_id, p_digest_type, clear_text, signed_text, &g_err) < 0) && (g_err != NULL)) {
+ if ((g_mime_crypto_context_sign(ctx,
+ user_id,
+ p_digest_type,
+ clear_text,
+ signed_text,
+ &g_err) < 0) && (g_err != NULL)) {
EM_DEBUG_EXCEPTION("g_mime_crypto_context_sign failed : [%s]", g_err->message);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
@@ -294,7 +301,13 @@ FINISH_OFF:
#endif
}
-INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list, char *certificate, char *password, char *mime_entity, char *user_id, email_digest_type digest_type, char **file_path)
+INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list,
+ char *certificate,
+ char *password,
+ char *mime_entity,
+ char *user_id,
+ email_digest_type digest_type,
+ char **file_path)
{
EM_DEBUG_FUNC_BEGIN_SEC("Certificate path : [%s], mime_entity : [%s]", certificate, mime_entity);
@@ -312,16 +325,13 @@ INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list, char *c
GMimeStream *encrypted_text = NULL;
GError *g_err = NULL;
- if (!recipient_list || !password || !mime_entity || !user_id) {
+ if (!recipient_list || !mime_entity || !user_id) {
EM_DEBUG_EXCEPTION("Invalid param");
err = EMAIL_ERROR_INVALID_PARAM;
return err;
}
/* Initialized the output stream (signed stream) */
- EM_SAFE_FREE(passphrase);
- passphrase = EM_SAFE_STRDUP(password);
-
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#endif
@@ -371,7 +381,14 @@ INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list, char *c
}
/* Set the signed message */
- if ((g_mime_crypto_context_encrypt(ctx, false, user_id, p_digest_type, recipients, clear_text, encrypted_text, &g_err) < 0) && (g_err != NULL)) {
+ if ((g_mime_crypto_context_encrypt(ctx,
+ false,
+ user_id,
+ p_digest_type,
+ recipients,
+ clear_text,
+ encrypted_text,
+ &g_err) < 0) && (g_err != NULL)) {
EM_DEBUG_EXCEPTION("NO signature : g_mime_crypto_context_encrypt failed : [%s]", g_err->message);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
@@ -410,7 +427,13 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_list, char *certificate, char *password, char *mime_entity, char *user_id, email_digest_type digest_type, char **file_path)
+INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_list,
+ char *certificate,
+ char *password,
+ char *mime_entity,
+ char *user_id,
+ email_digest_type digest_type,
+ char **file_path)
{
EM_DEBUG_FUNC_BEGIN_SEC("mime_entity : [%s]", mime_entity);
@@ -422,7 +445,6 @@ INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_li
char temp_pgp_filepath[512] = {0, };
GPtrArray *recipients = NULL;
-
GMimeCryptoContext *ctx = NULL;
GMimeStream *clear_text = NULL;
GMimeStream *encrypted_text = NULL;
@@ -487,7 +509,14 @@ INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_li
}
/* Set the signed message */
- if ((g_mime_crypto_context_encrypt(ctx, true, user_id, p_digest_type, recipients, clear_text, encrypted_text, &g_err) < 0) && (g_err != NULL)) {
+ if ((g_mime_crypto_context_encrypt(ctx,
+ true,
+ user_id,
+ p_digest_type,
+ recipients,
+ clear_text,
+ encrypted_text,
+ &g_err) < 0) && (g_err != NULL)) {
EM_DEBUG_EXCEPTION("Signature : g_mime_crypto_context_encrypt failed : [%s]", g_err->message);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
@@ -526,7 +555,10 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_pgp_get_verify_signature(char *signature_path, char *mime_entity, email_digest_type digest_type, int *verify)
+INTERNAL_FUNC int emcore_pgp_get_verify_signature(char *signature_path,
+ char *mime_entity,
+ email_digest_type digest_type,
+ int *verify)
{
EM_DEBUG_FUNC_BEGIN_SEC("signature path : [%s], mime_entity : [%s]", signature_path, mime_entity);
@@ -640,7 +672,11 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_pgp_get_decrypted_message(char *encrypted_message, char *password, int sign, char **decrypted_file, int *verify)
+INTERNAL_FUNC int emcore_pgp_get_decrypted_message(char *encrypted_message,
+ char *password,
+ int sign,
+ char **decrypted_file,
+ int *verify)
{
EM_DEBUG_FUNC_BEGIN_SEC("Encrypted message : [%s], password : [%s]", encrypted_message, password);
@@ -714,12 +750,14 @@ INTERNAL_FUNC int emcore_pgp_get_decrypted_message(char *encrypted_message, char
goto FINISH_OFF;
}
- if (sign) {
- if (!result->signatures || get_signature_status(result->signatures) != GMIME_SIGNATURE_STATUS_GOOD)
+ if (result->signatures) {
+ if (get_signature_status(result->signatures) != GMIME_SIGNATURE_STATUS_GOOD)
p_verify = false;
else
p_verify = true;
- }
+ } else {
+ p_verify = -1;
+ }
FINISH_OFF:
@@ -744,7 +782,7 @@ FINISH_OFF:
close(decrypted_fd);
if (verify)
- *verify = p_verify;
+ *verify = p_verify;
if (decrypted_file)
*decrypted_file = EM_SAFE_STRDUP(temp_decrypt_filepath);
diff --git a/email-core/email-core-signal.c b/email-core/email-core-signal.c
index 8964cb6..b9756b2 100755
--- a/email-core/email-core-signal.c
+++ b/email-core/email-core-signal.c
@@ -163,8 +163,6 @@ FINISH_OFF:
return ret;
}
-
-
INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNotiData *data)
{
EM_DEBUG_FUNC_BEGIN("subType [%d], data [%p]", subType, data);
@@ -175,6 +173,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
int i = 0;
dbus_uint32_t error = 0;
int ret = true;
+ const char *null_string = "";
ENTER_CRITICAL_SECTION(_dbus_noti_lock);
@@ -199,6 +198,11 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.handle), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.account_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.mail_id), DBUS_TYPE_INVALID);
+ if (data->send_mail.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_SEND_SAVED: /* publish a send notification to ASE (active sync engine) */
EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_SAVED]", subType);
@@ -214,6 +218,11 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.handle ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.account_id ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.mailbox_id ), DBUS_TYPE_INVALID);
+ if (data->sync_header.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->sync_header.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_DOWNLOAD_BODY: /* publish a download body notification to ASE */
EM_DEBUG_LOG("handle:[%d]", data->download_body.handle);
@@ -225,6 +234,13 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.account_id ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.mail_id ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.with_attachment ), DBUS_TYPE_INVALID);
+ if (data->download_body.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_body.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
+ break;
+
break;
case ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT:
EM_DEBUG_LOG("handle:[%d]", data->download_attachment.handle);
@@ -236,10 +252,17 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.account_id ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.mail_id ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.attachment_order), DBUS_TYPE_INVALID);
+ if (data->download_attachment.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_attachment.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
+
case ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT:
EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT]", subType);
break;
+
case ACTIVE_SYNC_NOTI_CANCEL_JOB:
EM_DEBUG_LOG("account_id:[%d]", data->cancel_job.account_id );
EM_DEBUG_LOG("handle to cancel:[%d]", data->cancel_job.handle);
@@ -248,7 +271,13 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.account_id ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.handle ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.cancel_type ), DBUS_TYPE_INVALID);
+ if (data->cancel_job.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->cancel_job.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
+
case ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER:
EM_DEBUG_LOG("account_id:[%d]", data->search_mail_on_server.account_id );
EM_DEBUG_LOG("mailbox_id:[%d]", data->search_mail_on_server.mailbox_id );
@@ -288,6 +317,8 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
case EMAIL_SEARCH_FILTER_TYPE_TO :
case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.string_type_key_value), DBUS_TYPE_INVALID);
break;
@@ -302,11 +333,21 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
}
}
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.handle), DBUS_TYPE_INVALID);
+ if (data->search_mail_on_server.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER :
EM_DEBUG_LOG("account_id:[%d]", data->clear_result_of_search_mail_on_server.account_id );
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID);
+ if (data->search_mail_on_server.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED :
@@ -314,18 +355,33 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.mailbox_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.on_server), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.handle), DBUS_TYPE_INVALID);
+ if (data->expunge_mails_deleted_flagged.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->expunge_mails_deleted_flagged.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_RESOLVE_RECIPIENT :
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->get_resolve_recipients.account_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->get_resolve_recipients.email_address), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->get_resolve_recipients.handle), DBUS_TYPE_INVALID);
+ if (data->get_resolve_recipients.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->get_resolve_recipients.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_VALIDATE_CERTIFICATE :
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->validate_certificate.account_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->validate_certificate.email_address), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->validate_certificate.handle), DBUS_TYPE_INVALID);
+ if (data->validate_certificate.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->validate_certificate.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_ADD_MAILBOX :
@@ -340,6 +396,11 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args (signal, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &(data->add_mailbox.eas_data),\
data->add_mailbox.eas_data_length,DBUS_TYPE_INVALID);
} */
+ if (data->add_mailbox.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_RENAME_MAILBOX :
@@ -355,12 +416,22 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args (signal, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &(data->rename_mailbox.eas_data),\
data->rename_mailbox.eas_data_length, DBUS_TYPE_INVALID);
}*/
+ if (data->rename_mailbox.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_DELETE_MAILBOX :
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox.account_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox.mailbox_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox.handle), DBUS_TYPE_INVALID);
+ if (data->delete_mailbox.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->delete_mailbox.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_DELETE_MAILBOX_EX :
@@ -369,12 +440,22 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
for(i = 0; i <data->delete_mailbox_ex.mailbox_id_count; i++)
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox_ex.mailbox_id_array[i]), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox_ex.handle), DBUS_TYPE_INVALID);
+ if (data->delete_mailbox_ex.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->delete_mailbox_ex.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_SEND_MAIL_WITH_DOWNLOADING_OF_ORIGINAL_MAIL:
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail_with_downloading_attachment_of_original_mail.handle), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail_with_downloading_attachment_of_original_mail.mail_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail_with_downloading_attachment_of_original_mail.account_id), DBUS_TYPE_INVALID);
+ if (data->send_mail_with_downloading_attachment_of_original_mail.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail_with_downloading_attachment_of_original_mail.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_SCHEDULE_SENDING_MAIL:
@@ -382,12 +463,22 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->schedule_sending_mail.account_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->schedule_sending_mail.mail_id), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->schedule_sending_mail.scheduled_time), DBUS_TYPE_INVALID);
+ if (data->schedule_sending_mail.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->schedule_sending_mail.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
case ACTIVE_SYNC_NOTI_CANCEL_SENDING_MAIL:
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.handle), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.account_id ), DBUS_TYPE_INVALID);
dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.mail_id), DBUS_TYPE_INVALID);
+ if (data->cancel_sending_mail.multi_user_name)
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->cancel_sending_mail.multi_user_name), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(null_string), DBUS_TYPE_INVALID);
+
break;
default:
diff --git a/email-core/email-core-smime.c b/email-core/email-core-smime.c
index 19aa539..8dc102b 100755
--- a/email-core/email-core-smime.c
+++ b/email-core/email-core-smime.c
@@ -126,7 +126,10 @@ static const EVP_CIPHER *emcore_get_cipher_algorithm(email_cipher_type cipher_ty
return cipher;
}
-static int get_x509_stack_of_recipient_certs(char *recipients, STACK_OF(X509) **output_recipient_certs, int *err_code)
+static int get_x509_stack_of_recipient_certs(char *multi_user_name,
+ char *recipients,
+ STACK_OF(X509) **output_recipient_certs,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN("recipients : [%s], STACK_OF(X509) : [%p]", recipients, output_recipient_certs);
@@ -156,7 +159,7 @@ static int get_x509_stack_of_recipient_certs(char *recipients, STACK_OF(X509) **
/* Initialize the variable */
temp_recipient_certs = sk_X509_new_null();
- temp_recipients = EM_SAFE_STRDUP(recipients);
+ temp_recipients = g_strdup(recipients);
for (i = 0, j = EM_SAFE_STRLEN(temp_recipients); i < j; i++)
if (temp_recipients[i] == ';') temp_recipients[i] = ',';
@@ -170,10 +173,11 @@ static int get_x509_stack_of_recipient_certs(char *recipients, STACK_OF(X509) **
goto FINISH_OFF;
}
- EM_DEBUG_LOG_SEC("email_address_mailbox : [%s], email_address_host : [%s]", token_address->mailbox, token_address->host);
+ EM_DEBUG_LOG_SEC("email_address_mailbox : [%s], email_address_host : [%s]", token_address->mailbox,
+ token_address->host);
email_address = g_strdup_printf("<%s@%s>", token_address->mailbox, token_address->host);
- if (!emstorage_get_certificate_by_email_address(email_address, &cert, false, 0, &err)) {
+ if (!emstorage_get_certificate_by_email_address(multi_user_name, email_address, &cert, false, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_certificate_by_email_address failed : [%d]", err);
goto FINISH_OFF;
}
@@ -183,11 +187,11 @@ static int get_x509_stack_of_recipient_certs(char *recipients, STACK_OF(X509) **
goto FINISH_OFF;
}
-
SNPRINTF(file_name, sizeof(file_name), "%s", cert->filepath);
EM_DEBUG_LOG_SEC("file_name : [%s]", file_name);
- if (cert_svc_load_file_to_context(context, file_name) != CERT_SVC_ERR_NO_ERROR) {
- EM_DEBUG_EXCEPTION("cert_svc_load_file_to_context failed");
+ int cert_err = cert_svc_load_file_to_context(context, file_name);
+ if (cert_err != CERT_SVC_ERR_NO_ERROR) {
+ EM_DEBUG_EXCEPTION("cert_svc_load_file_to_context failed : [%d]", err);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -246,13 +250,19 @@ FINISH_OFF:
if (err_code)
*err_code = err;
- EM_DEBUG_FUNC_END();
+ EM_DEBUG_FUNC_END("err : [%d]", err);
return ret;
}
/* Opaque signed and encrypted method */
/*
-static PKCS7 *opaque_signed_and_encrypt(STACK_OF(X509) *recipients_cert, X509 *signer, EVP_PKEY *private_key, BIO *mime_entity, const EVP_CIPHER *cipher, const EVP_MD *md, int flags)
+static PKCS7 *opaque_signed_and_encrypt(STACK_OF(X509) *recipients_cert,
+ X509 *signer,
+ EVP_PKEY *private_key,
+ BIO *mime_entity,
+ const EVP_CIPHER *cipher,
+ const EVP_MD *md,
+ int flags)
{
EM_DEBUG_FUNC_BEGIN();
int i = 0;
@@ -306,7 +316,11 @@ FINISH_OFF:
}
*/
-INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, char *mime_entity, email_digest_type digest_type, char **file_path, int *err_code)
+INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate,
+ char *mime_entity,
+ email_digest_type digest_type,
+ char **file_path,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("certificate path : [%s], mime_entity : [%s]", certificate, mime_entity);
int err, ret = false;
@@ -345,7 +359,8 @@ INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, char *mime_
signed_message = PKCS7_sign(NULL, NULL, other_certs, bio_mime_entity, flags);
if (!signed_message) {
- EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -354,19 +369,22 @@ INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, char *mime_
digest = emcore_get_digest_algorithm(digest_type);
if (!PKCS7_sign_add_signer(signed_message, cert, private_key, digest, flags)) {
- EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!PKCS7_final(signed_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("PKCS7_final failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_final failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!i2d_PKCS7_bio_stream(smime_attachment, signed_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -375,7 +393,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, char *mime_
FINISH_OFF:
if (file_path && ret)
- *file_path = EM_SAFE_STRDUP(temp_smime_filepath);
+ *file_path = g_strdup(temp_smime_filepath);
X509_free(cert);
sk_X509_pop_free(other_certs, X509_free);
@@ -394,7 +412,12 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *recipient_list, char *mime_entity, email_cipher_type cipher_type, char **file_path, int *err_code)
+INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *multi_user_name,
+ char *recipient_list,
+ char *mime_entity,
+ email_cipher_type cipher_type,
+ char **file_path,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN("certificate path : [%p], mime_entity : [%p]", recipient_list, mime_entity);
char temp_smime_filepath[512];
@@ -422,7 +445,7 @@ INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *recipient_list, char *m
goto FINISH_OFF;
}
- if (!get_x509_stack_of_recipient_certs(recipient_list, &recipient_certs, &err)) {
+ if (!get_x509_stack_of_recipient_certs(multi_user_name, recipient_list, &recipient_certs, &err)) {
EM_DEBUG_EXCEPTION("get_x509_stack_of_recipient_certs failed [%d]", err);
goto FINISH_OFF;
}
@@ -438,13 +461,15 @@ INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *recipient_list, char *m
encrypt_message = PKCS7_encrypt(recipient_certs, bio_mime_entity, cipher, flags);
if (encrypt_message == NULL) {
- EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld]", ERR_get_error());
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
if (!i2d_PKCS7_bio_stream(smime_attachment, encrypt_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -454,7 +479,7 @@ INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *recipient_list, char *m
FINISH_OFF:
if (file_path && ret)
- *file_path = EM_SAFE_STRDUP(temp_smime_filepath);
+ *file_path = g_strdup(temp_smime_filepath);
PKCS7_free(encrypt_message);
@@ -473,7 +498,14 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_list, char *certificate, char *mime_entity, email_cipher_type cipher_type, email_digest_type digest_type, char **file_path, int *err_code)
+INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_name,
+ char *recipient_list,
+ char *certificate,
+ char *mime_entity,
+ email_cipher_type cipher_type,
+ email_digest_type digest_type,
+ char **file_path,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("certificate path : [%s], mime_entity : [%s]", recipient_list, mime_entity);
char temp_smime_filepath[512];
@@ -523,7 +555,8 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_li
/* 3. signing */
signed_message = PKCS7_sign(NULL, NULL, other_certs, bio_mime_entity, flags);
if (!signed_message) {
- EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("Error creating PKCS#7 structure : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -533,7 +566,8 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_li
/* 5. Apply a digest algorithm */
if (!PKCS7_sign_add_signer(signed_message, cert, private_key, digest, flags)) {
- EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_sign_add_signer failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -549,8 +583,10 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_li
goto FINISH_OFF;
}
- if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity, flags | SMIME_OLDMIME | SMIME_CRLFEOL)) {
- EM_DEBUG_EXCEPTION("SMIME_write_PKCS7 error");
+ if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity,
+ flags | SMIME_OLDMIME | SMIME_CRLFEOL)) {
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("SMIME_write_PKCS7 error : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -559,7 +595,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_li
/* Encrypting the mail */
/* 1. Get the recipient certs */
- if (!get_x509_stack_of_recipient_certs(recipient_list, &recipient_certs, &err)) {
+ if (!get_x509_stack_of_recipient_certs(multi_user_name, recipient_list, &recipient_certs, &err)) {
EM_DEBUG_EXCEPTION("get_x509_stack_of_recipient_certs failed [%d]", err);
goto FINISH_OFF;
}
@@ -579,14 +615,16 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_li
encrypt_message = PKCS7_encrypt(recipient_certs, bio_signed_message, cipher, flags);
if (encrypt_message == NULL) {
- EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld]", ERR_get_error());
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("PKCS7_encrypt failed [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
/* 4. Write the encrypt message in file */
if (!i2d_PKCS7_bio_stream(smime_attachment, encrypt_message, bio_mime_entity, flags)) {
- EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("i2d_PKCS7_bio_stream failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -596,7 +634,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_li
FINISH_OFF:
if (file_path && ret)
- *file_path = EM_SAFE_STRDUP(temp_smime_filepath);
+ *file_path = g_strdup(temp_smime_filepath);
emstorage_delete_file(temp_mime_entity_path, NULL);
@@ -620,7 +658,10 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message, char *certificate, char **decrypt_message, int *err_code)
+INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message,
+ char *certificate,
+ char **decrypt_message,
+ int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("encrypt_file : [%s], certificate : [%s]", encrypt_message, certificate);
int ret = false;
@@ -666,7 +707,8 @@ INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message, char *
}
if (!PKCS7_decrypt(p7_encrypt_message, private_key, cert, out_buf, 0)) {
- EM_DEBUG_EXCEPTION("Decrpyt failed");
+ unsigned long error = ERR_get_error();
+ EM_DEBUG_EXCEPTION("Decrpyt failed : [%ld][%s]", error, ERR_error_string(error, NULL));
err = EMAIL_ERROR_DECRYPT_FAILED;
goto FINISH_OFF;
}
@@ -676,7 +718,7 @@ INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message, char *
FINISH_OFF:
if (decrypt_message && ret)
- *decrypt_message = EM_SAFE_STRDUP(temp_decrypt_filepath);
+ *decrypt_message = g_strdup(temp_decrypt_filepath);
X509_free(cert);
EVP_PKEY_free(private_key);
@@ -771,14 +813,22 @@ FINISH_OFF:
}
*/
-INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t *account_tbl_item, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data_list, int *output_attachment_count)
+INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
+ emstorage_account_tbl_t *account_tbl_item,
+ email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data_list,
+ int input_attachment_count,
+ email_mail_data_t **output_mail_data,
+ email_attachment_data_t **output_attachment_data_list,
+ int *output_attachment_count)
{
- EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list [%p], input_attachment_count [%d], output_mail_data [%p], output_attachment_data_list [%p]", input_mail_data, input_attachment_data_list, input_attachment_count, output_mail_data, output_attachment_data_list);
+ EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list [%p], input_attachment_count [%d], output_mail_data [%p], output_attachment_data_list [%p]",
+ input_mail_data, input_attachment_data_list, input_attachment_count,
+ output_mail_data, output_attachment_data_list);
int i = 0;
int err = EMAIL_ERROR_NONE;
int smime_type = EMAIL_SMIME_NONE;
- int address_length = 0;
int attachment_count = input_attachment_count;
int file_size = 0;
char *name = NULL;
@@ -802,7 +852,11 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t
/* Signed and Encrypt the message */
switch (smime_type) {
case EMAIL_SMIME_SIGNED: /* Clear signed message */
- if (!emcore_smime_set_signed_message(account_tbl_item->certificate_path, input_mail_data->file_path_mime_entity, account_tbl_item->digest_type, &smime_file_path, &err)) {
+ if (!emcore_smime_set_signed_message(account_tbl_item->certificate_path,
+ input_mail_data->file_path_mime_entity,
+ account_tbl_item->digest_type,
+ &smime_file_path,
+ &err)) {
EM_DEBUG_EXCEPTION("em_core_smime_set_clear_signed_message is failed : [%d]", err);
goto FINISH_OFF;
}
@@ -810,21 +864,26 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t
EM_DEBUG_LOG_SEC("smime_file_path : %s", smime_file_path);
name = strrchr(smime_file_path, '/');
- new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
- new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
+ new_attachment_data.attachment_name = g_strdup(name + 1);
+ new_attachment_data.attachment_path = g_strdup(smime_file_path);
new_attachment_data.attachment_mime_type = strdup("pkcs7-signature");
attachment_count += 1;
break;
- case EMAIL_SMIME_ENCRYPTED: /* Encryption message */
- address_length = EM_SAFE_STRLEN(input_mail_data->full_address_from) + EM_SAFE_STRLEN(input_mail_data->full_address_to) + EM_SAFE_STRLEN(input_mail_data->full_address_cc) + EM_SAFE_STRLEN(input_mail_data->full_address_bcc);
-
- other_certificate_list = em_malloc(address_length + 4);
-
- SNPRINTF(other_certificate_list, address_length + 2, "%s;%s;%s;%s", input_mail_data->full_address_from, input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc);
- if (!emcore_smime_set_encrypt_message(other_certificate_list, input_mail_data->file_path_mime_entity, account_tbl_item->cipher_type, &smime_file_path, &err)) {
+ case EMAIL_SMIME_ENCRYPTED: /* Encryption message */
+ other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
+ input_mail_data->full_address_to, ";",
+ input_mail_data->full_address_cc, ";",
+ input_mail_data->full_address_bcc, NULL);
+
+ if (!emcore_smime_set_encrypt_message(multi_user_name,
+ other_certificate_list,
+ input_mail_data->file_path_mime_entity,
+ account_tbl_item->cipher_type,
+ &smime_file_path,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_smime_set_encrypt_message is failed : [%d]", err);
goto FINISH_OFF;
}
@@ -832,21 +891,28 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t
EM_DEBUG_LOG_SEC("smime_file_path : %s", smime_file_path);
name = strrchr(smime_file_path, '/');
- new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
- new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
+ new_attachment_data.attachment_name = g_strdup(name + 1);
+ new_attachment_data.attachment_path = g_strdup(smime_file_path);
new_attachment_data.attachment_mime_type = strdup("pkcs7-mime");
attachment_count = 1;
break;
- case EMAIL_SMIME_SIGNED_AND_ENCRYPTED: /* Signed and Encryption message */
- address_length = EM_SAFE_STRLEN(input_mail_data->full_address_from) + EM_SAFE_STRLEN(input_mail_data->full_address_to) + EM_SAFE_STRLEN(input_mail_data->full_address_cc) + EM_SAFE_STRLEN(input_mail_data->full_address_bcc);
-
- other_certificate_list = em_malloc(address_length + 4);
-
- SNPRINTF(other_certificate_list, address_length + 2, "%s;%s;%s;%s", input_mail_data->full_address_from, input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc);
- if (!emcore_smime_set_signed_and_encrypt_message(other_certificate_list, account_tbl_item->certificate_path, input_mail_data->file_path_mime_entity, account_tbl_item->cipher_type, account_tbl_item->digest_type, &smime_file_path, &err)) {
+ case EMAIL_SMIME_SIGNED_AND_ENCRYPTED: /* Signed and Encryption message */
+ other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
+ input_mail_data->full_address_to, ";",
+ input_mail_data->full_address_cc, ";",
+ input_mail_data->full_address_bcc, NULL);
+
+ if (!emcore_smime_set_signed_and_encrypt_message(multi_user_name,
+ other_certificate_list,
+ account_tbl_item->certificate_path,
+ input_mail_data->file_path_mime_entity,
+ account_tbl_item->cipher_type,
+ account_tbl_item->digest_type,
+ &smime_file_path,
+ &err)) {
EM_DEBUG_EXCEPTION("em_core_smime_set_signed_and_encrypt_message is failed : [%d]", err);
goto FINISH_OFF;
}
@@ -854,79 +920,98 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t
EM_DEBUG_LOG_SEC("smime_file_path : %s", smime_file_path);
name = strrchr(smime_file_path, '/');
- new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
- new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
+ new_attachment_data.attachment_name = g_strdup(name + 1);
+ new_attachment_data.attachment_path = g_strdup(smime_file_path);
new_attachment_data.attachment_mime_type = strdup("pkcs7-mime");
attachment_count = 1;
break;
+
case EMAIL_PGP_SIGNED:
- if ((err = emcore_pgp_set_signed_message(NULL, input_mail_data->pgp_password, input_mail_data->file_path_mime_entity, account_tbl_item->user_email_address, account_tbl_item->digest_type, &smime_file_path)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("em_core_smime_set_clear_signed_message is failed : [%d]", err);
+ if ((err = emcore_pgp_set_signed_message(NULL,
+ input_mail_data->pgp_password,
+ input_mail_data->file_path_mime_entity,
+ input_mail_data->key_id,
+ account_tbl_item->digest_type,
+ &smime_file_path)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_pgp_set_signed_message is failed : [%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG_SEC("smime_file_path : %s", smime_file_path);
name = strrchr(smime_file_path, '/');
- new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
- new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
+ new_attachment_data.attachment_name = g_strdup(name + 1);
+ new_attachment_data.attachment_path = g_strdup(smime_file_path);
new_attachment_data.attachment_mime_type = strdup("pgp-signature");
attachment_count += 1;
break;
- case EMAIL_PGP_ENCRYPTED:
- address_length = EM_SAFE_STRLEN(input_mail_data->full_address_from) + EM_SAFE_STRLEN(input_mail_data->full_address_to) + EM_SAFE_STRLEN(input_mail_data->full_address_cc) + EM_SAFE_STRLEN(input_mail_data->full_address_bcc);
-
- other_certificate_list = em_malloc(address_length + 4);
-
- SNPRINTF(other_certificate_list, address_length + 2, "%s;%s;%s;%s", input_mail_data->full_address_from, input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc);
- if ((err = emcore_pgp_set_encrypted_message(other_certificate_list, NULL, input_mail_data->pgp_password, input_mail_data->file_path_mime_entity, account_tbl_item->user_email_address, input_mail_data->digest_type, &smime_file_path)) != EMAIL_ERROR_NONE) {
+ case EMAIL_PGP_ENCRYPTED:
+/*
+ other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
+ input_mail_data->full_address_to, ";",
+ input_mail_data->full_address_cc, ";",
+ input_mail_data->full_address_bcc, NULL);
+*/
+ other_certificate_list = g_strdup(input_mail_data->key_list);
+ if ((err = emcore_pgp_set_encrypted_message(other_certificate_list,
+ NULL,
+ input_mail_data->pgp_password,
+ input_mail_data->file_path_mime_entity,
+ account_tbl_item->user_email_address,
+ input_mail_data->digest_type,
+ &smime_file_path)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_pgp_set_encrypted_message failed : [%d]", err);
goto FINISH_OFF;
}
name = strrchr(smime_file_path, '/');
- new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
- new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
+ new_attachment_data.attachment_name = g_strdup(name + 1);
+ new_attachment_data.attachment_path = g_strdup(smime_file_path);
new_attachment_data.attachment_mime_type = strdup("octet-stream");
attachment_count = 1;
break;
- case EMAIL_PGP_SIGNED_AND_ENCRYPTED:
- address_length = EM_SAFE_STRLEN(input_mail_data->full_address_from) + EM_SAFE_STRLEN(input_mail_data->full_address_to) + EM_SAFE_STRLEN(input_mail_data->full_address_cc) + EM_SAFE_STRLEN(input_mail_data->full_address_bcc);
-
- other_certificate_list = em_malloc(address_length + 4);
- if (other_certificate_list == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
- SNPRINTF(other_certificate_list, address_length + 2, "%s;%s;%s;%s", input_mail_data->full_address_from, input_mail_data->full_address_to, input_mail_data->full_address_cc, input_mail_data->full_address_bcc);
- if ((err = emcore_pgp_set_signed_and_encrypted_message(other_certificate_list, NULL, input_mail_data->pgp_password, input_mail_data->file_path_mime_entity, account_tbl_item->user_email_address, input_mail_data->digest_type, &smime_file_path)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_pgp_set_encrypted_message failed : [%d]", err);
+ case EMAIL_PGP_SIGNED_AND_ENCRYPTED:
+/*
+ other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
+ input_mail_data->full_address_to, ";",
+ input_mail_data->full_address_cc, ";",
+ input_mail_data->full_address_bcc, NULL);
+*/
+ other_certificate_list = g_strdup(input_mail_data->key_list);
+ if ((err = emcore_pgp_set_signed_and_encrypted_message(other_certificate_list,
+ NULL,
+ input_mail_data->pgp_password,
+ input_mail_data->file_path_mime_entity,
+ input_mail_data->key_id,
+ input_mail_data->digest_type,
+ &smime_file_path)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_pgp_set_signed_and_encrypted_message failed : [%d]", err);
goto FINISH_OFF;
}
name = strrchr(smime_file_path, '/');
- new_attachment_data.attachment_name = EM_SAFE_STRDUP(name + 1);
- new_attachment_data.attachment_path = EM_SAFE_STRDUP(smime_file_path);
+ new_attachment_data.attachment_name = g_strdup(name + 1);
+ new_attachment_data.attachment_path = g_strdup(smime_file_path);
new_attachment_data.attachment_mime_type = strdup("octet-stream");
attachment_count = 1;
break;
+
default:
EM_DEBUG_LOG("MIME none");
break;
+
}
if (!emcore_get_file_size(smime_file_path, &file_size, NULL)) {
@@ -947,9 +1032,9 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t
if (smime_type == EMAIL_SMIME_SIGNED) {
for (i = 0; i < input_attachment_count; i++) {
new_attachment_list[i].attachment_id = input_attachment_data_list[i].attachment_id;
- new_attachment_list[i].attachment_name = EM_SAFE_STRDUP(input_attachment_data_list[i].attachment_name);
- new_attachment_list[i].attachment_path = EM_SAFE_STRDUP(input_attachment_data_list[i].attachment_path);
- new_attachment_list[i].content_id = EM_SAFE_STRDUP(input_attachment_data_list[i].content_id);
+ new_attachment_list[i].attachment_name = g_strdup(input_attachment_data_list[i].attachment_name);
+ new_attachment_list[i].attachment_path = g_strdup(input_attachment_data_list[i].attachment_path);
+ new_attachment_list[i].content_id = g_strdup(input_attachment_data_list[i].content_id);
new_attachment_list[i].attachment_size = input_attachment_data_list[i].attachment_size;
new_attachment_list[i].mail_id = input_attachment_data_list[i].mail_id;
new_attachment_list[i].account_id = input_attachment_data_list[i].account_id;
@@ -957,14 +1042,14 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t
new_attachment_list[i].save_status = input_attachment_data_list[i].save_status;
new_attachment_list[i].drm_status = input_attachment_data_list[i].drm_status;
new_attachment_list[i].inline_content_status = input_attachment_data_list[i].inline_content_status;
- new_attachment_list[i].attachment_mime_type = EM_SAFE_STRDUP(input_attachment_data_list[i].attachment_mime_type);
+ new_attachment_list[i].attachment_mime_type = g_strdup(input_attachment_data_list[i].attachment_mime_type);
}
}
new_attachment_list[attachment_count - 1].attachment_id = new_attachment_data.attachment_id;
- new_attachment_list[attachment_count - 1].attachment_name = EM_SAFE_STRDUP(new_attachment_data.attachment_name);
- new_attachment_list[attachment_count - 1].attachment_path = EM_SAFE_STRDUP(new_attachment_data.attachment_path);
- new_attachment_list[attachment_count - 1].content_id = EM_SAFE_STRDUP(new_attachment_data.content_id);
+ new_attachment_list[attachment_count - 1].attachment_name = g_strdup(new_attachment_data.attachment_name);
+ new_attachment_list[attachment_count - 1].attachment_path = g_strdup(new_attachment_data.attachment_path);
+ new_attachment_list[attachment_count - 1].content_id = g_strdup(new_attachment_data.content_id);
new_attachment_list[attachment_count - 1].attachment_size = new_attachment_data.attachment_size;
new_attachment_list[attachment_count - 1].mail_id = new_attachment_data.mail_id;
new_attachment_list[attachment_count - 1].account_id = new_attachment_data.account_id;
@@ -972,7 +1057,7 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t
new_attachment_list[attachment_count - 1].save_status = new_attachment_data.save_status;
new_attachment_list[attachment_count - 1].drm_status = new_attachment_data.drm_status;
new_attachment_list[attachment_count - 1].inline_content_status = new_attachment_data.inline_content_status;
- new_attachment_list[attachment_count - 1].attachment_mime_type = EM_SAFE_STRDUP(new_attachment_data.attachment_mime_type);
+ new_attachment_list[attachment_count - 1].attachment_mime_type = g_strdup(new_attachment_data.attachment_mime_type);
input_mail_data->smime_type = smime_type;
input_mail_data->digest_type = account_tbl_item->digest_type;
diff --git a/email-core/email-core-smtp.c b/email-core/email-core-smtp.c
index b1d2e13..fbf8000 100755
--- a/email-core/email-core-smtp.c
+++ b/email-core/email-core-smtp.c
@@ -54,16 +54,18 @@
#include "email-convert.h"
#include "email-debug-log.h"
#include "email-core-gmime.h"
+#include "email-core-container.h"
+#include "email-network.h"
#undef min
#ifdef __FEATURE_SUPPORT_REPORT_MAIL__
-static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body, int *err_code);
+static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope, BODY **multipart_body, int *err_code);
#endif
-static int emcore_make_envelope_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, ENVELOPE **output_envelope);
-static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_file, int account_id, int mail_id, int *err_code);
+static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_tbl_t *input_mail_tbl_data, ENVELOPE **output_envelope);
+static int emcore_send_mail_smtp(char *multi_user_name, SENDSTREAM *stream, ENVELOPE *env, char *data_file, int account_id, int mail_id, int *err_code);
char *emcore_generate_content_id_string(const char *hostname, int *err);
/* Functions from uw-imap-toolkit */
@@ -268,7 +270,6 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
if (body->type == TYPETEXT && body->subtype && toupper(body->subtype[0]) == 'H') {
EM_DEBUG_LOG ("HTML Part");
-
struct stat st_buf;
unsigned int byte_read = 0;
@@ -415,8 +416,6 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
if (body->encoding == ENCQUOTEDPRINTABLE || body->encoding == ENCBASE64)
fprintf(fp, CRLF_STRING);
- fprintf(fp, CRLF_STRING);
-
FINISH_OFF: /* prevent 34226 */
/* cleanup local vars */
@@ -463,26 +462,27 @@ static int emcore_write_rfc822_body(BODY *body, BODY *root_body, FILE *fp, int *
rfc822_write_body_header(&p, &part->body);
- fprintf(fp, "--%s"CRLF_STRING, bndry);
+ fprintf(fp, CRLF_STRING"--%s"CRLF_STRING, bndry);
if (body->subtype && (body->subtype[0] == 'S' || body->subtype[0] == 's')) {
if ((error = emcore_write_body (body, root_body, fp)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
return false;
}
- fprintf(fp, "--%s"CRLF_STRING, bndry);
+ fprintf(fp, CRLF_STRING"--%s"CRLF_STRING, bndry);
}
- fprintf(fp, "%s"CRLF_STRING, buf);
-
+ fprintf(fp, "%s", buf);
emcore_write_rfc822_body(&part->body, root_body, fp, err_code);
+
} while ((part = part->next));
- fprintf(fp, "--%s--"CRLF_STRING, bndry);
+ fprintf(fp, CRLF_STRING"--%s--"CRLF_STRING, bndry);
break;
default:
EM_DEBUG_LOG_DEV("body->type is not TYPEMULTIPART");
+ fprintf(fp, CRLF_STRING);
if ((error = emcore_write_body (body, root_body, fp)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
return false;
@@ -553,7 +553,6 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
rfc822_output_header(&buf, env, body, NIL, NIL); /* Excluding BCC */
EM_DEBUG_LOG("header_buffer [%d]", strlen(header_buffer));
-
{
gchar **tokens = g_strsplit(header_buffer, "CHARSET=X-UNKNOWN", 2);
@@ -634,8 +633,7 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
}
}
- SNPRINTF(header_buffer + EM_SAFE_STRLEN(header_buffer), header_buffer_lenth-(EM_SAFE_STRLEN(header_buffer)), CRLF_STRING);
-
+// SNPRINTF(header_buffer + EM_SAFE_STRLEN(header_buffer), header_buffer_lenth-(EM_SAFE_STRLEN(header_buffer)), CRLF_STRING);
if (data && EM_SAFE_STRLEN(*data) > 0) {
fname = EM_SAFE_STRDUP(*data);
file_exist = 1;
@@ -685,7 +683,7 @@ FINISH_OFF:
return error;
}
-INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas, int move_flag)
+INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas, int move_flag)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list [%p], input_attachment_count [%d], input_meeting_request [%p], input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
@@ -715,10 +713,11 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
int mailbox_id_spam = 0, mailbox_id_target = 0;
int mail_smime_flag = 0;
char name_buf[MAX_PATH] = {0x00, };
+ char path_buf[MAX_PATH] = {0, };
char *body_text_file_name = NULL;
char *dl_error = NULL;
void *dl_handle = NULL;
- int (*convert_mail_data_to_smime)(emstorage_account_tbl_t*, email_mail_data_t*, email_attachment_data_t*, int, email_mail_data_t**, email_attachment_data_t**, int*);
+ int (*convert_mail_data_to_smime)(char*, emstorage_account_tbl_t*, email_mail_data_t*, email_attachment_data_t*, int, email_mail_data_t**, email_attachment_data_t**, int*);
int attachment_count = 0;
email_mail_data_t *mail_data = NULL;
@@ -732,6 +731,8 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
char mailbox_id_param_string[10] = {0,};
char errno_buf[ERRNO_BUF_SIZE] = {0};
int updated_thread_id = 0;
+ char *prefix_path = NULL;
+ char real_file_path[MAX_PATH] = {0};
#ifdef __FEATURE_BODY_SEARCH__
char *stripped_text = NULL;
@@ -749,7 +750,7 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(input_mail_data->account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_OPTIONS, &account_tbl_item, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, input_mail_data->account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_OPTIONS, &account_tbl_item, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed. account_id[%d] err[%d]", input_mail_data->account_id, err);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -771,8 +772,8 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
goto FINISH_OFF;
}
- if ((err = convert_mail_data_to_smime(account_tbl_item, input_mail_data, input_attachment_data_list, input_attachment_count, &mail_data, &attachment_data_list, &attachment_count)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("S/MIME failed : [%d]", err);
+ if ((err = convert_mail_data_to_smime(multi_user_name, account_tbl_item, input_mail_data, input_attachment_data_list, input_attachment_count, &mail_data, &attachment_data_list, &attachment_count)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("S/MIME failed");
goto FINISH_OFF;
}
@@ -785,11 +786,24 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
mailbox_id_target = mail_data->mailbox_id;
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
if (input_from_eas == 0 &&
!(input_mail_data->message_class & EMAIL_MESSAGE_CLASS_SMART_REPLY) &&
!(input_mail_data->message_class & EMAIL_MESSAGE_CLASS_SMART_FORWARD) ) {
if (mail_data->file_path_plain) {
- if (stat(mail_data->file_path_plain, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail_data->file_path_plain);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("mail_data->file_path_plain, stat(\"%s\") failed...", mail_data->file_path_plain);
EM_DEBUG_EXCEPTION("%s", EM_STRERROR(errno_buf));
err = EMAIL_ERROR_INVALID_MAIL;
@@ -798,7 +812,10 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
}
if (mail_data->file_path_html) {
- if (stat(mail_data->file_path_html, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail_data->file_path_html);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("mail_data->file_path_html, stat(\"%s\") failed...", mail_data->file_path_html);
EM_DEBUG_EXCEPTION("%s", EM_STRERROR(errno_buf) );
err = EMAIL_ERROR_INVALID_MAIL;
@@ -809,7 +826,10 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
if (attachment_count && attachment_data_list) {
for (i = 0; i < attachment_count; i++) {
if (attachment_data_list[i].save_status) {
- if (!attachment_data_list[i].attachment_path || stat(attachment_data_list[i].attachment_path, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, attachment_data_list[i].attachment_path);
+
+ if (!attachment_data_list[i].attachment_path || stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", attachment_data_list[i].attachment_path);
err = EMAIL_ERROR_INVALID_ATTACHMENT;
goto FINISH_OFF;
@@ -836,7 +856,7 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
}
/* Create report mail body */
/*
- if (!emcore_make_rfc822_file_from_mail(mail_src, NULL, NULL, NULL, &err)) {
+ if (!emcore_make_rfc822_file_from_mail(multi_user_name, mail_src, NULL, NULL, NULL, &err)) {
EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -847,47 +867,47 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
email_option_t *opt = &account_tbl_item->options;
EM_DEBUG_LOG_SEC("block_address [%d], block_subject [%d]", opt->block_address, opt->block_subject);
- /* For eas moving from spambox to other mailbox */
- if (mail_data->save_status != EMAIL_MAIL_STATUS_SAVED) {
- if (opt->block_address || opt->block_subject) {
- int is_completed = false;
- int type = 0;
-
- if (!opt->block_address)
- type = EMAIL_FILTER_SUBJECT;
- else if (!opt->block_subject)
- type = EMAIL_FILTER_FROM;
-
- if (!emstorage_get_rule(ALL_ACCOUNT, type, 0, &rule_len, &is_completed, &rule, true, &err) || !rule)
- EM_DEBUG_LOG("No proper rules. emstorage_get_rule returns [%d]", err);
-
- if (rule && !emcore_check_rule(mail_data->full_address_from, mail_data->subject, rule, rule_len, &priority_sender, &blocked, &err)) {
- EM_DEBUG_EXCEPTION("emcore_check_rule failed [%d]", err);
- }
-
- if (priority_sender)
- mail_data->tag_id = PRIORITY_SENDER_TAG_ID;
-
- if (blocked && (mail_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
- EM_DEBUG_LOG("mail[%d] added to spambox", mail_data->mail_id);
- if (!emstorage_get_mailbox_id_by_mailbox_type(mail_data->account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &mailbox_id_spam, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
- mailbox_id_spam = 0;
- }
-
- if (mailbox_id_spam)
- mailbox_id_target = mailbox_id_spam;
- }
- }
+ /* For eas moving from spambox to other mailbox */
+ if (mail_data->save_status != EMAIL_MAIL_STATUS_SAVED) {
+ if (opt->block_address || opt->block_subject) {
+ int is_completed = false;
+ int type = 0;
+
+ if (!opt->block_address)
+ type = EMAIL_FILTER_SUBJECT;
+ else if (!opt->block_subject)
+ type = EMAIL_FILTER_FROM;
+
+ if (!emstorage_get_rule(multi_user_name, ALL_ACCOUNT, type, 0, &rule_len, &is_completed, &rule, true, &err) || !rule)
+ EM_DEBUG_LOG("No proper rules. emstorage_get_rule returns [%d]", err);
+
+ if (rule && !emcore_check_rule(mail_data->full_address_from, mail_data->subject, rule, rule_len, &priority_sender, &blocked, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_check_rule failed [%d]", err);
}
+
+ if (priority_sender)
+ mail_data->tag_id = PRIORITY_SENDER_TAG_ID;
+
+ if (blocked && (mail_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
+ EM_DEBUG_LOG("mail[%d] added to spambox", mail_data->mail_id);
+ if (!emstorage_get_mailbox_id_by_mailbox_type(multi_user_name, mail_data->account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &mailbox_id_spam, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
+ mailbox_id_spam = 0;
+ }
+
+ if (mailbox_id_spam)
+ mailbox_id_target = mailbox_id_spam;
+ }
+ }
+ }
}
- if ((err = emstorage_get_mailbox_by_id(mailbox_id_target, (emstorage_mailbox_tbl_t**)&mailbox_tbl)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id_target, (emstorage_mailbox_tbl_t**)&mailbox_tbl)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_increase_mail_id(&mail_data->mail_id, true, &err)) {
+ if (!emstorage_increase_mail_id(multi_user_name, &mail_data->mail_id, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_increase_mail_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -895,21 +915,26 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
EM_DEBUG_LOG("mail_data->mail_size [%d]", mail_data->mail_size);
if(mail_data->mail_size == 0)
- emcore_calc_mail_size(mail_data, attachment_data_list, attachment_count, &(mail_data->mail_size)); /* Getting file size before file moved. */
+ emcore_calc_mail_size(multi_user_name, mail_data, attachment_data_list, attachment_count, &(mail_data->mail_size)); /* Getting file size before file moved. */
EM_DEBUG_LOG("input_from_eas [%d] mail_data->body_download_status [%d]", input_from_eas, mail_data->body_download_status);
if (input_from_eas == 0|| mail_data->body_download_status) {
- if (!emstorage_create_dir(mail_data->account_id, mail_data->mail_id, 0, &err)) {
+ if (!emstorage_create_dir(multi_user_name, mail_data->account_id, mail_data->mail_id, 0, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
goto FINISH_OFF;
}
if (mail_data->file_path_plain) {
+ memset(name_buf, 0x00, sizeof(name_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail_data->file_path_plain);
+
EM_DEBUG_LOG_SEC("mail_data->file_path_plain [%s]", mail_data->file_path_plain);
/* EM_SAFE_STRNCPY(body_text_file_name, "UTF-8", MAX_PATH); */
- if ( (err = em_get_file_name_from_file_path(mail_data->file_path_plain, &body_text_file_name)) != EMAIL_ERROR_NONE) {
+ if ( (err = em_get_file_name_from_file_path(real_file_path, &body_text_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
err = EMAIL_ERROR_INVALID_FILE_PATH;
goto FINISH_OFF;
@@ -922,12 +947,14 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
EM_SAFE_STRNCPY(body_text_file_name, "UTF-8", MAX_PATH);
*/
- if (!emstorage_get_save_name(mail_data->account_id, mail_data->mail_id, 0, body_text_file_name, name_buf, sizeof(name_buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, mail_data->account_id, mail_data->mail_id,
+ 0, body_text_file_name, name_buf, path_buf,
+ sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(mail_data->file_path_plain, name_buf, input_from_eas, &err)) {
+ if (!emstorage_move_file(real_file_path, name_buf, input_from_eas, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
@@ -935,16 +962,21 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
mail_data->body_download_status = EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED;
EM_SAFE_FREE(mail_data->file_path_plain);
- mail_data->file_path_plain = EM_SAFE_STRDUP(name_buf);
+ mail_data->file_path_plain = EM_SAFE_STRDUP(path_buf);
}
if (mail_data->file_path_html) {
+ memset(name_buf, 0x00, sizeof(name_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail_data->file_path_html);
+
EM_DEBUG_LOG_SEC("mail_data->file_path_html [%s]", mail_data->file_path_html);
/* EM_SAFE_STRNCPY(body_text_file_name, "UTF-8.htm", MAX_PATH); */
EM_SAFE_FREE(body_text_file_name);
- if ( (err = em_get_file_name_from_file_path(mail_data->file_path_html, &body_text_file_name)) != EMAIL_ERROR_NONE) {
+ if ( (err = em_get_file_name_from_file_path(real_file_path, &body_text_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
err = EMAIL_ERROR_INVALID_FILE_PATH;
goto FINISH_OFF;
@@ -956,12 +988,14 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
EM_SAFE_STRNCPY(body_text_file_name, "UTF-8.htm", MAX_PATH);
*/
- if (!emstorage_get_save_name(mail_data->account_id, mail_data->mail_id, 0, body_text_file_name, name_buf, sizeof(name_buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, mail_data->account_id, mail_data->mail_id,
+ 0, body_text_file_name, name_buf, path_buf,
+ sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(mail_data->file_path_html, name_buf, input_from_eas, &err)) {
+ if (!emstorage_move_file(real_file_path, name_buf, input_from_eas, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
@@ -970,25 +1004,32 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
mail_data->body_download_status = EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED;
EM_SAFE_FREE(mail_data->file_path_html);
- mail_data->file_path_html = EM_SAFE_STRDUP(name_buf);
+ mail_data->file_path_html = EM_SAFE_STRDUP(path_buf);
}
}
if (mail_data->file_path_mime_entity) {
+ memset(name_buf, 0x00, sizeof(name_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail_data->file_path_mime_entity);
+
EM_DEBUG_LOG_SEC("mail_data->file_path_mime_entity [%s]", mail_data->file_path_mime_entity);
- if (!emstorage_get_save_name(mail_data->account_id, mail_data->mail_id, 0, "mime_entity", name_buf, sizeof(name_buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name, mail_data->account_id, mail_data->mail_id,
+ 0, "mime_entity", name_buf, path_buf,
+ sizeof(path_buf), &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_move_file(mail_data->file_path_mime_entity, name_buf, input_from_eas, &err)) {
+ if (!emstorage_move_file(real_file_path, name_buf, input_from_eas, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
goto FINISH_OFF;
}
EM_SAFE_FREE(mail_data->file_path_mime_entity);
- mail_data->file_path_mime_entity = EM_SAFE_STRDUP(name_buf);
+ mail_data->file_path_mime_entity = EM_SAFE_STRDUP(path_buf);
}
if (!mail_data->date_time) {
@@ -1024,7 +1065,11 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
EM_DEBUG_LOG("preview_text[%p]", mail_data->preview_text);
if (mail_data->preview_text == NULL) {
- if ( (err = emcore_get_preview_text_from_file(mail_data->file_path_plain, mail_data->file_path_html, MAX_PREVIEW_TEXT_LENGTH, &(mail_data->preview_text))) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_get_preview_text_from_file(multi_user_name,
+ mail_data->file_path_plain,
+ mail_data->file_path_html,
+ MAX_PREVIEW_TEXT_LENGTH,
+ &(mail_data->preview_text))) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file failed[%d]", err);
if (err != EMAIL_ERROR_EMPTY_FILE)
@@ -1040,11 +1085,11 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
converted_mail_tbl->mailbox_id = mailbox_tbl->mailbox_id;
/* Fill address information */
- emcore_fill_address_information_of_mail_tbl(converted_mail_tbl);
+ emcore_fill_address_information_of_mail_tbl(multi_user_name, converted_mail_tbl);
/* Fill thread id */
if(mail_data->thread_id == 0) {
- if (emstorage_get_thread_id_of_thread_mails(converted_mail_tbl, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
+ if (emstorage_get_thread_id_of_thread_mails(multi_user_name, converted_mail_tbl, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed");
if (thread_id == -1) {
@@ -1061,14 +1106,14 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
}
mail_data->thread_id = converted_mail_tbl->thread_id;
-
- emstorage_begin_transaction(NULL, NULL, NULL);
+ converted_mail_tbl->user_name = EM_SAFE_STRDUP(account_tbl_item->user_name);
+ emstorage_begin_transaction(multi_user_name, NULL, NULL, NULL);
/* insert mail to mail table */
- if (!emstorage_add_mail(converted_mail_tbl, 0, false, &err)) {
+ if (!emstorage_add_mail(multi_user_name, converted_mail_tbl, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]", err);
/* ROLLBACK TRANSACTION; */
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
@@ -1076,9 +1121,19 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
EM_DEBUG_LOG("thread_item_count [%d]", thread_item_count);
if (thread_item_count > 1) {
- if (!emstorage_update_latest_thread_mail(mail_data->account_id, mail_data->mailbox_id, converted_mail_tbl->thread_id, &updated_thread_id, 0, 0, NOTI_THREAD_ID_CHANGED_BY_ADD, false, &err)) {
+ if (!emstorage_update_latest_thread_mail(multi_user_name,
+ mail_data->account_id,
+ mail_data->mailbox_id,
+ mail_data->mailbox_type,
+ converted_mail_tbl->thread_id,
+ &updated_thread_id,
+ 0,
+ 0,
+ NOTI_THREAD_ID_CHANGED_BY_ADD,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_latest_thread_mail failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
@@ -1089,43 +1144,56 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
/* Insert attachment information to DB */
for (i = 0; i < attachment_count; i++) {
+ memset(name_buf, 0x00, sizeof(name_buf));
+ memset(path_buf, 0x00, sizeof(path_buf));
+
+ /* set attachment size */
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, attachment_data_list[i].attachment_path);
+
if (attachment_data_list[i].attachment_size == 0) {
- /* set attachment size */
- if(attachment_data_list[i].attachment_path && stat(attachment_data_list[i].attachment_path, &st_buf) < 0)
+ if(attachment_data_list[i].attachment_path && stat(real_file_path, &st_buf) < 0)
attachment_data_list[i].attachment_size = st_buf.st_size;
}
if (!attachment_data_list[i].inline_content_status) {
- if (!emstorage_get_new_attachment_no(&attachment_id, &err)) {
+ if (!emstorage_get_new_attachment_no(multi_user_name, &attachment_id, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_new_attachment_no failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
- if (!emstorage_create_dir(mail_data->account_id, mail_data->mail_id, attachment_data_list[i].inline_content_status ? 0 : attachment_id, &err)) {
+ if (!emstorage_create_dir(multi_user_name, mail_data->account_id, mail_data->mail_id, attachment_data_list[i].inline_content_status ? 0 : attachment_id, &err)) {
EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
- if (!emstorage_get_save_name(mail_data->account_id, mail_data->mail_id, attachment_data_list[i].inline_content_status ? 0 : attachment_id, attachment_data_list[i].attachment_name, name_buf, sizeof(name_buf), &err)) {
+ if (!emstorage_get_save_name(multi_user_name,
+ mail_data->account_id,
+ mail_data->mail_id, attachment_data_list[i].inline_content_status ? 0 : attachment_id,
+ attachment_data_list[i].attachment_name,
+ name_buf,
+ path_buf,
+ sizeof(path_buf),
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
/* if (input_from_eas == 0 || attachment_data_list[i].save_status) { */
if (attachment_data_list[i].save_status) {
if (attachment_data_list[i].attachment_mime_type && strcasestr(attachment_data_list[i].attachment_mime_type, "PKCS7")) {
- if (!emstorage_move_file(attachment_data_list[i].attachment_path, name_buf, input_from_eas, &err)) {
+ if (!emstorage_move_file(real_file_path, name_buf, input_from_eas, &err)) {
EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
} else {
- if (!emstorage_copy_file(attachment_data_list[i].attachment_path, name_buf, input_from_eas, &err)) {
+ if (!emstorage_copy_file(real_file_path, name_buf, input_from_eas, &err)) {
EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
@@ -1133,7 +1201,7 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
memset(&attachment_tbl, 0, sizeof(emstorage_attachment_tbl_t));
attachment_tbl.attachment_name = attachment_data_list[i].attachment_name;
- attachment_tbl.attachment_path = name_buf;
+ attachment_tbl.attachment_path = path_buf;
attachment_tbl.attachment_size = attachment_data_list[i].attachment_size;
attachment_tbl.mail_id = mail_data->mail_id;
attachment_tbl.account_id = mail_data->account_id;
@@ -1144,10 +1212,9 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
attachment_tbl.attachment_mime_type = attachment_data_list[i].attachment_mime_type;
attachment_tbl.content_id = attachment_data_list[i].content_id;
- if (!emstorage_add_attachment(&attachment_tbl, 0, false, &err)) {
+ if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
-
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
@@ -1158,13 +1225,13 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
#ifdef __FEATURE_BODY_SEARCH__
/* Insert mail_text to DB */
- if (!emcore_strip_mail_body_from_file(converted_mail_tbl, &stripped_text, &err) || stripped_text == NULL) {
+ if (!emcore_strip_mail_body_from_file(multi_user_name, converted_mail_tbl, &stripped_text, &err) || stripped_text == NULL) {
EM_DEBUG_EXCEPTION("emcore_strip_mail_body_from_file failed [%d]", err);
}
- if (!emcore_add_mail_text(mailbox_tbl, converted_mail_tbl, stripped_text, &err)) {
+ if (!emcore_add_mail_text(multi_user_name, mailbox_tbl, converted_mail_tbl, stripped_text, &err)) {
EM_DEBUG_EXCEPTION("emcore_add_mail_text failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
#endif
@@ -1175,16 +1242,17 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
|| mail_data->meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
EM_DEBUG_LOG("This mail has the meeting request");
input_meeting_request->mail_id = mail_data->mail_id;
- if (!emstorage_add_meeting_request(mail_data->account_id, mailbox_tbl->mailbox_id, input_meeting_request, false, &err)) {
+
+ if (!emstorage_add_meeting_request(multi_user_name, mail_data->account_id, mailbox_tbl->mailbox_id, input_meeting_request, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_add_meeting_request failed [%d]", err);
- emstorage_rollback_transaction(NULL, NULL, NULL);
+ emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
goto FINISH_OFF;
}
}
- emstorage_commit_transaction(NULL, NULL, NULL);
+ emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL);
- if (emstorage_get_thread_id_of_thread_mails(converted_mail_tbl, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
+ if (emstorage_get_thread_id_of_thread_mails(multi_user_name, converted_mail_tbl, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed.");
SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl->mailbox_id);
@@ -1192,7 +1260,7 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
EM_DEBUG_LOG("emcore_notify_storage_event [NOTI_MAIL_ADD] failed.");
if (account_tbl_item->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC && !move_flag) {
- if (!emcore_remove_overflowed_mails(mailbox_tbl, &err)) {
+ if (!emcore_remove_overflowed_mails(multi_user_name, mailbox_tbl, &err)) {
if (err == EMAIL_ERROR_MAIL_NOT_FOUND || err == EMAIL_ERROR_NOT_SUPPORTED)
err = EMAIL_ERROR_NONE;
else
@@ -1203,7 +1271,7 @@ INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_atta
if ( input_from_eas && (mail_data->flags_seen_field == 0)) {
// && mail_data->mailbox_type != EMAIL_MAILBOX_TYPE_TRASH
// && mail_data->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX) {
- if ((err = emcore_update_sync_status_of_account(mail_data->account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING | SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name, mail_data->account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING | SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG("emcore_update_sync_status_of_account failed [%d]", err);
}
@@ -1212,6 +1280,7 @@ FINISH_OFF:
dlclose(dl_handle);
EM_SAFE_FREE(body_text_file_name);
+ EM_SAFE_FREE(prefix_path);
#ifdef __FEATURE_BODY_SEARCH__
EM_SAFE_FREE(stripped_text);
@@ -1233,7 +1302,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id)
+INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_mail_id, int *output_receipt_mail_id)
{
EM_DEBUG_FUNC_BEGIN("input_read_mail_id [%d], output_receipt_mail_id [%p]", input_read_mail_id, output_receipt_mail_id);
int err = EMAIL_ERROR_NONE;
@@ -1246,7 +1315,7 @@ INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_re
emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
BODY *root_body = NULL;
- if( (err = emcore_get_mail_data(input_read_mail_id, &read_mail_data)) != EMAIL_ERROR_NONE) {
+ if( (err = emcore_get_mail_data(multi_user_name, input_read_mail_id, &read_mail_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
goto FINISH_OFF;
}
@@ -1275,7 +1344,7 @@ INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_re
SNPRINTF(receipt_mail_data->subject, EM_SAFE_STRLEN(read_mail_data->subject) + 7, "Read: %s", read_mail_data->subject);
}
- if (!emstorage_get_mailbox_by_mailbox_type(receipt_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_tbl, true, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, receipt_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
@@ -1293,14 +1362,14 @@ INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_re
goto FINISH_OFF;
}
- if ( (err = emcore_make_envelope_from_mail(receipt_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_make_envelope_from_mail(multi_user_name, receipt_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_make_envelope_from_mail failed [%d]", err);
goto FINISH_OFF;
}
envelope->references = EM_SAFE_STRDUP(read_mail_data->message_id);
- if (!emcore_get_report_mail_body(envelope, &root_body, &err)) {
+ if (!emcore_get_report_mail_body(multi_user_name, envelope, &root_body, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_report_mail_body failed [%d]", err);
goto FINISH_OFF;
}
@@ -1334,7 +1403,7 @@ INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_re
attachment_data->attachment_name = cpystr(p);
*/
- if ( (err = emcore_add_mail(receipt_mail_data, attachment_data, attachment_count, NULL, 0, false)) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_add_mail(multi_user_name, receipt_mail_data, attachment_data, attachment_count, NULL, 0, false)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -1342,24 +1411,23 @@ INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_re
*output_receipt_mail_id = receipt_mail_data->mail_id;
FINISH_OFF:
-
- if (receipt_mail_data) {
+ if(receipt_mail_data) {
EM_SAFE_FREE(receipt_mail_data->full_address_to);
EM_SAFE_FREE(receipt_mail_data->message_id);
EM_SAFE_FREE(receipt_mail_data->subject);
EM_SAFE_FREE(receipt_mail_data);
}
- if (mailbox_tbl)
+ if(mailbox_tbl)
emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
- if (read_mail_data)
+ if(read_mail_data)
emcore_free_mail_data_list(&read_mail_data, 1);
- if (attachment_data)
+ if(attachment_data)
emcore_free_attachment_data(&attachment_data, 1, NULL);
- if (receipt_mail_tbl_data)
+ if(receipt_mail_tbl_data)
emstorage_free_mail(&receipt_mail_tbl_data, 1, NULL);
if (root_body)
@@ -1369,7 +1437,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int *err_code)
+INTERNAL_FUNC int emcore_add_meeting_request(char *multi_user_name, int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], meeting_req[%p], err_code[%p]", account_id, input_mailbox_id, meeting_req, err_code);
int ret = false;
@@ -1383,9 +1451,8 @@ INTERNAL_FUNC int emcore_add_meeting_request(int account_id, int input_mailbox_i
goto FINISH_OFF;
}
- if (!emstorage_add_meeting_request(account_id, input_mailbox_id, meeting_req, 1, &err)) {
+ if (!emstorage_add_meeting_request(multi_user_name, account_id, input_mailbox_id, meeting_req, 1, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_add_meeting_request failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -1400,7 +1467,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_query_mail_size_limit(int account_id, int handle, int *err_code)
+INTERNAL_FUNC int emcore_query_mail_size_limit(char *multi_user_name, int account_id, int handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], err_code[%p]", account_id, err_code);
int ret = false;
@@ -1418,7 +1485,7 @@ INTERNAL_FUNC int emcore_query_mail_size_limit(int account_id, int handle, int *
goto FINISH_OFF;
}
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -1431,13 +1498,13 @@ INTERNAL_FUNC int emcore_query_mail_size_limit(int account_id, int handle, int *
}
if (ref_account->pop_before_smtp != FALSE) {
- if (!emcore_connect_to_remote_mailbox(account_id, 0, (void **)&mail_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, 0, (void **)&mail_stream, &err)) {
EM_DEBUG_EXCEPTION(" POP before SMTP Authentication failed [%d]", err);
goto FINISH_OFF;
}
}
- if (!emcore_connect_to_remote_mailbox(account_id, EMAIL_CONNECT_FOR_SENDING, (void **)&tmp_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, EMAIL_CONNECT_FOR_SENDING, (void **)&tmp_stream, &err)) {
EM_DEBUG_EXCEPTION(" emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -1517,7 +1584,7 @@ INTERNAL_FUNC void emcore_close_smtp_stream_list ()
if threads exit after calling the function, emcore_close_smtp_stream_list should be called.
Otherwise, memory leaks
*/
-INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (int account_id, int *error)
+INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (char *multi_user_name, int account_id, int *error)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
GList* cur = g_send_stream_list;
@@ -1556,7 +1623,7 @@ INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (int account_id, int *error)
goto FINISH_OFF;
}
- if (!emcore_connect_to_remote_mailbox(account_id, EMAIL_CONNECT_FOR_SENDING, (void **)ret, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, EMAIL_CONNECT_FOR_SENDING, (void **)ret, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
EM_SAFE_FREE(ret);
@@ -1595,14 +1662,13 @@ mainloop (by alarm),
thread_func_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL,
*/
-INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
+INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code);
EM_PROFILE_BEGIN(profile_emcore_send_mail);
int ret = false;
int err = EMAIL_ERROR_NONE, err2 = EMAIL_ERROR_NONE;
int attachment_tbl_count = 0;
- int i = 0;
int account_id = 0;
SENDSTREAM** send_stream = NULL;
ENVELOPE *envelope = NULL;
@@ -1625,20 +1691,20 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
}
/* get mail to send */
- if (!emstorage_get_mail_by_id(mail_id, &mail_tbl_data, false, &err) || err != EMAIL_ERROR_NONE) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_tbl_data, false, &err) || err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
account_id = mail_tbl_data->account_id;
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if ((err = emstorage_get_attachment_list(mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -1671,6 +1737,7 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
opt = &(ref_account->options);
#ifdef __FEATURE_SUPPORT_VALIDATION_SYSTEM__
+ int i = 0;
EM_VALIDATION_SYSTEM_LOG("INFO", mail_id, "Email Send Start, %s -> %s, success", mail_tbl_data->full_address_from, mail_tbl_data->full_address_to);
for (i = 0; i < attachment_tbl_count; i++) {
if(attachment_tbl_data)
@@ -1681,7 +1748,7 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
/*Update status flag to DB*/
/* get rfc822 data */
- if (!emcore_make_rfc822_file_from_mail(mail_tbl_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fpath, opt, &err)) {
+ if (!emcore_make_rfc822_file_from_mail(multi_user_name, mail_tbl_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fpath, opt, &err)) {
EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -1705,22 +1772,27 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
}
if (ref_account->pop_before_smtp != FALSE) {
- if (!emcore_connect_to_remote_mailbox(account_id, 0, (void **)&mail_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, 0, (void **)&mail_stream, &err)) {
EM_DEBUG_EXCEPTION(" POP before SMTP Authentication failed [%d]", err);
if (err == EMAIL_ERROR_CONNECTION_BROKEN)
err = EMAIL_ERROR_CANCELLED;
goto FINISH_OFF;
}
}
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_DRAFT, &local_mailbox, false, &err)) {
+
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_DRAFT, &local_mailbox, false, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
dst_mailbox_id = local_mailbox->mailbox_id;
emstorage_free_mailbox(&local_mailbox, 1, NULL);
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ goto FINISH_OFF;
+ }
- send_stream = emcore_get_smtp_stream (account_id, &err);
+ send_stream = emcore_get_smtp_stream (multi_user_name, account_id, &err);
if (!send_stream) {
EM_DEBUG_EXCEPTION(" emcore_get_smtp_stream failed [%d]", err);
if (err == EMAIL_ERROR_CONNECTION_BROKEN)
@@ -1729,7 +1801,7 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
}
#if 0
- if (!emcore_connect_to_remote_mailbox(account_id, EMAIL_CONNECT_FOR_SENDING, (void **)&tmp_stream, &err)) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, EMAIL_CONNECT_FOR_SENDING, (void **)&tmp_stream, &err)) {
EM_DEBUG_EXCEPTION(" emcore_connect_to_remote_mailbox failed [%d]", err);
if (err == EMAIL_ERROR_CONNECTION_BROKEN)
@@ -1771,20 +1843,20 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
}
mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING;
- emcore_show_user_message(mail_id, EMAIL_ACTION_SENDING_MAIL, EMAIL_ERROR_NONE);
+ emcore_show_user_message(multi_user_name, mail_id, EMAIL_ACTION_SENDING_MAIL, EMAIL_ERROR_NONE);
/*Update status save_status to DB*/
- if (!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err))
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err))
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
/* send mail to server. */
- if (!emcore_send_mail_smtp(*send_stream, envelope, fpath, account_id, mail_id, &err)) {
+ if (!emcore_send_mail_smtp(multi_user_name, *send_stream, envelope, fpath, account_id, mail_id, &err)) {
EM_DEBUG_EXCEPTION(" emcore_send_mail_smtp failed [%d]", err);
if (err == SMTP_RESPONSE_EXCEED_SIZE_LIMIT)
err = EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE;
#ifndef __FEATURE_MOVE_TO_OUTBOX_FIRST__
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, false, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
@@ -1792,7 +1864,7 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
emstorage_free_mailbox(&local_mailbox, 1, NULL);
/* unsent mail is moved to 'OUTBOX'. */
- if (!emcore_move_mail(&mail_id, 1, dst_mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, NULL))
+ if (!emcore_move_mail(multi_user_name, &mail_id, 1, dst_mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, NULL))
EM_DEBUG_EXCEPTION(" emcore_mail_move falied...");
#endif
if (err > 0)
@@ -1800,18 +1872,18 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
goto FINISH_OFF;
}
- emcore_show_user_message(mail_id, EMAIL_ACTION_SEND_MAIL, err);
+ emcore_show_user_message(multi_user_name, mail_id, EMAIL_ACTION_SEND_MAIL, err);
sent_flag = 1;
/* sent mail is moved to 'SENT' box or deleted. */
if (opt->keep_local_copy) {
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &local_mailbox, true, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
dst_mailbox_id = local_mailbox->mailbox_id;
- if (!emcore_move_mail(&mail_id, 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, &err))
+ if (!emcore_move_mail(multi_user_name, &mail_id, 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, &err))
EM_DEBUG_EXCEPTION(" emcore_mail_move falied [%d]", err);
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
#ifdef __FEATURE_LOCAL_ACTIVITY__
@@ -1836,7 +1908,7 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
EM_DEBUG_EXCEPTION(" emcore_add_activity Failed [%d] ", err);
}
- if (!emcore_move_mail_on_server(dest_mbox.account_id, dst_mailbox_id, &mail_id, 1, dest_mbox.name, &err)) {
+ if (!emcore_move_mail_on_server(multi_user_name, dest_mbox.account_id, dst_mailbox_id, &mail_id, 1, dest_mbox.name, &err)) {
EM_DEBUG_EXCEPTION(" emcore_move_mail_on_server falied [%d]", err);
}
else {
@@ -1859,23 +1931,29 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
#endif
if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
emstorage_mailbox_tbl_t* src_mailbox = NULL;
- emstorage_mail_tbl_t *temp_mail = NULL;
+// emstorage_mail_tbl_t *temp_mail = NULL;
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &src_mailbox, true, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &src_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("local_yn:[%d]", src_mailbox->local_yn);
- if (src_mailbox->local_yn) {
-
+ if (src_mailbox->local_yn) {
+ /* This is syncing operation in sent box
+ but it slowed operation */
+ /*
void *local_stream = NULL;
- if (!emcore_sync_header (local_mailbox, &local_stream, NULL, NULL, NULL, NULL, NULL, 0, -1, &err)) {
+ if (!emcore_sync_header (multi_user_name, local_mailbox, &local_stream, NULL, NULL, NULL, NULL, NULL, 0, -1, &err)) {
EM_DEBUG_EXCEPTION("emcore_sync_header failed");
}
mail_close (local_stream);
-
- if (!emstorage_get_maildata_by_servermailid(local_mailbox->mailbox_id, "0", &temp_mail, false, &err)) {
+ if (!emstorage_get_maildata_by_servermailid(multi_user_name,
+ "0",
+ local_mailbox->mailbox_id,
+ &temp_mail,
+ false,
+ &err)) {
if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid failed : [%d]", err);
goto FINISH_OFF;
@@ -1883,12 +1961,19 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
}
if (temp_mail) {
- emcore_sync_mail_from_client_to_server(mail_id);
- emstorage_free_mail(&temp_mail, 1, NULL);
+ emcore_sync_mail_from_client_to_server(multi_user_name, mail_id);
+ emstorage_free_mail(&temp_mail, 1, NULL);
+ }
+ */
+
+ /* sent box exception list : gmail (After the mail sent, moved the sent box) */
+ if (ref_account->outgoing_server_address) {
+ if (!strcasestr(ref_account->outgoing_server_address, "gmail"))
+ emcore_sync_mail_from_client_to_server(multi_user_name, mail_id);
}
}
else {
- if (!emcore_move_mail_on_server(account_id, src_mailbox->mailbox_id, &mail_id, 1, local_mailbox->mailbox_name, &err)) {
+ if (!emcore_move_mail_on_server(multi_user_name, account_id, src_mailbox->mailbox_id, &mail_id, 1, local_mailbox->mailbox_name, &err)) {
EM_DEBUG_EXCEPTION(" emcore_move_mail_on_server falied [%d]", err);
}
}
@@ -1899,22 +1984,22 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
/* On Successful Mail sent remove the Draft flag */
mail_tbl_data->flags_draft_field = 0;
- if (!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "flags_draft_field", mail_tbl_data->flags_draft_field, true, &err))
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "flags_draft_field", mail_tbl_data->flags_draft_field, true, &err))
EM_DEBUG_EXCEPTION("Failed to modify extra flag [%d]", err);
}
else {
- if (!emcore_delete_mail(account_id, &mail_id, 1, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_AFTER_SENDING, false, &err))
+ if (!emcore_delete_mail(multi_user_name, account_id, &mail_id, 1, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_AFTER_SENDING, false, &err))
EM_DEBUG_EXCEPTION(" emcore_delete_mail failed [%d]", err);
}
/* Set the phone log */
- if ((err = emcore_set_sent_contacts_log(mail_tbl_data)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_set_sent_contacts_log(multi_user_name, mail_tbl_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_sent_contacts_log failed : [%d]", err);
}
/*Update save_status */
mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENT;
- if (!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err))
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err))
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
if (!emcore_delete_transaction_info_by_mailId(mail_id))
@@ -1924,13 +2009,13 @@ INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code)
FINISH_OFF:
if (ret == false && sent_flag == 0) {
- emcore_show_user_message(mail_id, EMAIL_ACTION_SEND_MAIL, err);
+ emcore_show_user_message(multi_user_name, mail_id, EMAIL_ACTION_SEND_MAIL, err);
}
if (ret == false && err != EMAIL_ERROR_INVALID_PARAM && mail_tbl_data) {
if (err != EMAIL_ERROR_CANCELLED) {
mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SEND_FAILURE;
- if (!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err2))
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err2))
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err2);
}
else {
@@ -1938,7 +2023,7 @@ FINISH_OFF:
EM_DEBUG_LOG("EMAIL_MAIL_STATUS_SEND_CANCELED Already set for ");
else {
mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SEND_CANCELED;
- if (!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err2))
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err2))
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err2);
}
}
@@ -1995,7 +2080,7 @@ FINISH_OFF:
if (err != EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE) {
/* Add alarm for next sending mails */
- if( (err2 = emcore_create_alarm_for_auto_resend(AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
+ if( (err2 = emcore_create_alarm_for_auto_resend(multi_user_name, AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
if (err2 != EMAIL_ERROR_MAIL_NOT_FOUND)
EM_DEBUG_EXCEPTION("emcore_create_alarm_for_auto_resend failed [%d]", err2);
}
@@ -2013,7 +2098,7 @@ FINISH_OFF:
}
/* send a saved all mails */
-INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_name, int *err_code)
+INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id, char *input_mailbox_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_name[%p], err_code[%p]", account_id, input_mailbox_name, err_code);
@@ -2022,7 +2107,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
int err2 = EMAIL_ERROR_NONE;
int status = EMAIL_SEND_FAIL;
int *mail_ids = NULL;
- int handle = 0;
+ DB_STMT handle = NULL;
int i = 0;
int total = 0;
int attachment_tbl_count = 0;
@@ -2045,7 +2130,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
}
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -2054,15 +2139,20 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
/*don't delete the comment. several threads including event thread call this func */
/* FINISH_OFF_IF_CANCELED; */
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
opt = &(ref_account->options);
- if (!emstorage_get_mailbox_by_name(account_id, -1, input_mailbox_name, &local_mailbox, false, &err)) {
+ if (!emstorage_get_mailbox_by_name(multi_user_name, account_id, -1, input_mailbox_name, &local_mailbox, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed : [%d]", err);
goto FINISH_OFF;
}
/* search mail. */
- if (!emstorage_mail_search_start(NULL, account_id, local_mailbox->mailbox_id, 0, &handle, &total, true, &err)) {
+ if (!emstorage_mail_search_start(multi_user_name, NULL, account_id, local_mailbox->mailbox_id, 0, &handle, &total, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_mail_search_start failed [%d]", err);
goto FINISH_OFF;
}
@@ -2097,7 +2187,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
/*don't delete the comment. several threads including event thread call this func */
/* FINISH_OFF_IF_CANCELED;*/
- if (!emstorage_get_mail_by_id(mail_ids[i], &searched_mail_tbl_data, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_ids[i], &searched_mail_tbl_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -2110,7 +2200,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
continue;
}
- if ( (err = emstorage_get_attachment_list(mail_ids[i], false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
+ if ( (err = emstorage_get_attachment_list(multi_user_name, mail_ids[i], false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -2124,7 +2214,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING;
- if (!emcore_make_rfc822_file_from_mail(searched_mail_tbl_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fpath, opt, &err)) {
+ if (!emcore_make_rfc822_file_from_mail(multi_user_name, searched_mail_tbl_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fpath, opt, &err)) {
EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail falied [%d]", err);
goto FINISH_OFF;
}
@@ -2141,7 +2231,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
}
stream = NULL;
- if (!emcore_connect_to_remote_mailbox(account_id, EMAIL_CONNECT_FOR_SENDING, &tmp_stream, &err) || !tmp_stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, EMAIL_CONNECT_FOR_SENDING, &tmp_stream, &err) || !tmp_stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
if (err == EMAIL_ERROR_CONNECTION_BROKEN)
@@ -2172,29 +2262,29 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING;
/* update mail status to sending. */
- if (!emstorage_change_mail_field(mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) {
+ if (!emstorage_change_mail_field(multi_user_name, mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
goto FINISH_OFF;
}
- if (!emcore_send_mail_smtp(stream, envelope, fpath, account_id, mail_ids[i], &err)) {
+ if (!emcore_send_mail_smtp(multi_user_name, stream, envelope, fpath, account_id, mail_ids[i], &err)) {
EM_DEBUG_EXCEPTION("emcore_send_mail_smtp failed [%d]", err);
if (err == SMTP_RESPONSE_EXCEED_SIZE_LIMIT) err = EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE;
searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SEND_FAILURE;
/* update mail status to failure. */
- if (!emstorage_change_mail_field(mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err2))
+ if (!emstorage_change_mail_field(multi_user_name, mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err2))
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, true, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
dst_mailbox_id = local_mailbox->mailbox_id;
- emcore_move_mail(&mail_ids[i], 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, NULL);
+ emcore_move_mail(multi_user_name, &mail_ids[i], 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, NULL);
if(local_mailbox)
emstorage_free_mailbox(&local_mailbox, 1, NULL);
@@ -2205,32 +2295,32 @@ INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *input_mailbox_nam
searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENT;
/* update mail status to sent mail. */
- if (!emstorage_change_mail_field(mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) {
+ if (!emstorage_change_mail_field(multi_user_name, mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
goto FINISH_OFF;
}
/* sent mail is moved to 'SENT' box or deleted. */
if (opt->keep_local_copy) {
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &local_mailbox, true, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
dst_mailbox_id = local_mailbox->mailbox_id;
- if (!emcore_move_mail(&mail_ids[i], 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, &err))
+ if (!emcore_move_mail(multi_user_name, &mail_ids[i], 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, &err))
EM_DEBUG_EXCEPTION("emcore_mail_move falied [%d]", err);
if(local_mailbox)
emstorage_free_mailbox(&local_mailbox, 1, NULL);
}
else {
- if (!emcore_delete_mail(account_id, &mail_ids[i], 1, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_AFTER_SENDING, false, &err))
+ if (!emcore_delete_mail(multi_user_name, account_id, &mail_ids[i], 1, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_AFTER_SENDING, false, &err))
EM_DEBUG_EXCEPTION("emcore_delete_mail falied [%d]", err);
}
/* Set the phone log */
- if ((err = emcore_set_sent_contacts_log(searched_mail_tbl_data)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_set_sent_contacts_log(multi_user_name, searched_mail_tbl_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_sent_contacts_log failed : [%d]", err);
}
@@ -2290,11 +2380,11 @@ FINISH_OFF:
if (ret == true) {
mail_send_notify(EMAIL_SEND_FINISH, 0, 0, account_id, mail_ids[total], err);
- emcore_show_user_message(account_id, EMAIL_ACTION_SEND_MAIL, err);
+ emcore_show_user_message(multi_user_name, account_id, EMAIL_ACTION_SEND_MAIL, err);
} else {
if(mail_ids) /* prevent 34385 */
mail_send_notify(status, 0, 0, account_id, mail_ids[total], err);
- emcore_show_user_message(account_id, EMAIL_ACTION_SEND_MAIL, err);
+ emcore_show_user_message(multi_user_name, account_id, EMAIL_ACTION_SEND_MAIL, err);
}
EM_SAFE_FREE(mail_ids);
@@ -2305,9 +2395,16 @@ FINISH_OFF:
return ret;
}
-static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_file, int account_id, int mail_id, int *err_code)
+static int emcore_send_mail_smtp(char *multi_user_name,
+ SENDSTREAM *stream,
+ ENVELOPE *env,
+ char *data_file,
+ int account_id,
+ int mail_id,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN_SEC("stream[%p], env[%p], data_file[%s], account_id[%d], mail_id[%d], err_code[%p]", stream, env, data_file, account_id, mail_id, err_code);
+ EM_DEBUG_FUNC_BEGIN_SEC("stream[%p], env[%p], data_file[%s], account_id[%d], mail_id[%d], err_code[%p]",
+ stream, env, data_file, account_id, mail_id, err_code);
EM_PROFILE_BEGIN(profile_emcore_send_mail_smtp);
int ret = false;
@@ -2331,7 +2428,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
goto FINISH_OFF;
}
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -2354,9 +2451,12 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
if (stream->protocol.esmtp.dsn.ok && stream->protocol.esmtp.dsn.want) {
EM_DEBUG_LOG("stream->protocol.esmtp.dsn.want is required");
- strncat (buf, stream->protocol.esmtp.dsn.full ? " RET=FULL" : " RET=HDRS", sizeof(buf)-EM_SAFE_STRLEN(buf)-1);
+ strncat(buf, stream->protocol.esmtp.dsn.full ? " RET=FULL" : " RET=HDRS",
+ sizeof(buf)-EM_SAFE_STRLEN(buf)-1);
+
if (stream->protocol.esmtp.dsn.envid)
- SNPRINTF (buf + EM_SAFE_STRLEN (buf), sizeof(buf)-(EM_SAFE_STRLEN(buf)), " ENVID=%.100s", stream->protocol.esmtp.dsn.envid);
+ SNPRINTF (buf + EM_SAFE_STRLEN (buf), sizeof(buf)-(EM_SAFE_STRLEN(buf)),
+ " ENVID=%.100s", stream->protocol.esmtp.dsn.envid);
}
else
EM_DEBUG_LOG("stream->protocol.esmtp.dsn.want is not required or DSN is not supported");
@@ -2434,7 +2534,6 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
recipients++;
}
-
if (send_err) {
EM_DEBUG_EXCEPTION("One or more recipients failed...");
err = EMAIL_ERROR_INVALID_ADDRESS;
@@ -2476,9 +2575,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
}
EM_PROFILE_END(profile_open_file);
-
#ifdef __FEATURE_SEND_OPTMIZATION__
- {
char *data = NULL;
int read_size, allocSize, dataSize, gMaxAllocSize = 40960; /* 40KB */
int total_fixed = 0;
@@ -2505,15 +2602,15 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
}
while (total) {
-#if 0
/* Cancel the sending event */
if (!emcore_check_send_mail_thread_status()) {
+ EM_SAFE_FREE(data);
EM_DEBUG_EXCEPTION(" emcore_check_send_mail_thread_status failed...");
err = EMAIL_ERROR_CANCELLED;
goto FINISH_OFF;
}
-#endif
- if (total < allocSize)
+
+ if (total < allocSize)
dataSize = total;
else
dataSize = allocSize;
@@ -2546,7 +2643,8 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
emcore_update_notification_for_send(account_id, mail_id, progress);
}
- EM_DEBUG_LOG("Sent data Successfully. sent[%d] total[%d]", sent, total);
+ EM_DEBUG_LOG("Sent data Successfully. sent[%d] total[%d] datasize[%d]",
+ sent, total, dataSize);
}
total -= dataSize;
}
@@ -2577,13 +2675,13 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
}
}
-#endif
if (!send_ret) {
EM_DEBUG_EXCEPTION("smtp_soutr failed - %ld", send_ret);
err = EMAIL_ERROR_SMTP_SEND_FAILURE;
goto FINISH_OFF;
}
}
+#endif
send_ret = smtp_send(stream, ".", 0);
EM_DEBUG_LOG("[SMTP] . --------> %s", stream->reply);
@@ -2596,6 +2694,7 @@ static int emcore_send_mail_smtp(SENDSTREAM *stream, ENVELOPE *env, char *data_f
ret = true;
FINISH_OFF:
+
if (ret == false)
smtp_send(stream, "RSET", 0);
@@ -2805,7 +2904,7 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
if (strcasecmp(content_sub_type, "IMAGE") == 0) {
part->body.type = TYPEIMAGE;
if ((p = strstr(content_sub_type, "/"))) {
- EM_SAFE_FREE(part->body.subtype);
+ EM_SAFE_FREE(part->body.subtype);
part->body.subtype = EM_SAFE_STRDUP(p+1);
}
}
@@ -3049,7 +3148,7 @@ FINISH_OFF:
return new_part;
}
#ifdef __FEATURE_SUPPORT_REPORT_MAIL__
-static int attach_attachment_to_body(BODY **multipart_body, BODY *text_body, emstorage_attachment_tbl_t *input_attachment_tbl, int input_attachment_tbl_count, int *err_code)
+static int attach_attachment_to_body(char *multi_user_name, BODY **multipart_body, BODY *text_body, emstorage_attachment_tbl_t *input_attachment_tbl, int input_attachment_tbl_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("multipart_body[%p], text_body[%p], input_attachment_tbl[%p], input_attachment_tbl_count [%d], err_code[%p]", multipart_body, text_body, input_attachment_tbl, input_attachment_tbl_count, err_code);
@@ -3057,6 +3156,9 @@ static int attach_attachment_to_body(BODY **multipart_body, BODY *text_body, ems
int i = 0;
int error = EMAIL_ERROR_NONE;
BODY *frame_body = NULL;
+ char *prefix_path = NULL;
+ char real_file_path[MAX_PATH] = {0};
+
/* make multipart body(multipart frame_body..) .. that has not content.. */
if (!multipart_body || !text_body || !input_attachment_tbl) {
@@ -3088,14 +3190,27 @@ static int attach_attachment_to_body(BODY **multipart_body, BODY *text_body, ems
char *name = NULL;
struct stat st_buf;
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ error = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
for(i = 0; i < input_attachment_tbl_count; i++) {
temp_attachment_tbl = input_attachment_tbl + i;
EM_DEBUG_LOG("insert files - attachment id[%d]", temp_attachment_tbl->attachment_id);
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, temp_attachment_tbl->attachment_path);
+
if (stat(temp_attachment_tbl->attachment_path, &st_buf) == 0) {
if (!temp_attachment_tbl->attachment_name) {
- if (!emcore_get_file_name(temp_attachment_tbl->attachment_path, &name, &error)) {
+ if (!emcore_get_file_name(real_file_path, &name, &error)) {
EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", error);
goto FINISH_OFF;
}
@@ -3103,7 +3218,7 @@ static int attach_attachment_to_body(BODY **multipart_body, BODY *text_body, ems
else
name = temp_attachment_tbl->attachment_name;
- if (!attach_part(frame_body, (unsigned char *)temp_attachment_tbl->attachment_path, 0, name, NULL, false, &error)) {
+ if (!attach_part(frame_body, (unsigned char *)real_file_path, 0, name, NULL, false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
@@ -3113,6 +3228,9 @@ static int attach_attachment_to_body(BODY **multipart_body, BODY *text_body, ems
ret = true;
FINISH_OFF:
+
+ EM_SAFE_FREE(prefix_path);
+
if (ret == true)
*multipart_body = frame_body;
else if (frame_body != NULL)
@@ -3140,10 +3258,8 @@ static char *emcore_encode_rfc2047_text(char *utf8_text, int *err_code)
if (len > 0) {
-#ifdef __FEATURE_USE_GMIME__
return emcore_gmime_get_encoding_to_utf8(utf8_text);
// return g_strdup(utf8_text); /* emoji handle */
-#endif /* __FEATURE_USE_GMIME__ */
}
else
return strdup("");
@@ -3166,7 +3282,7 @@ static void emcore_encode_rfc2047_address(ADDRESS *address, int *err_code)
#define DATE_STR_LENGTH 100
-static int emcore_make_envelope_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, ENVELOPE **output_envelope)
+static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_tbl_t *input_mail_tbl_data, ENVELOPE **output_envelope)
{
EM_DEBUG_FUNC_BEGIN("input_mail_tbl_data[%p], output_envelope[%p]", input_mail_tbl_data, output_envelope);
@@ -3198,7 +3314,7 @@ static int emcore_make_envelope_from_mail(emstorage_mail_tbl_t *input_mail_tbl_d
is_incomplete = input_mail_tbl_data->flags_draft_field || (input_mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SENDING);
if (is_incomplete && (input_mail_tbl_data->account_id > 0)) {
- ref_account = emcore_get_account_reference(input_mail_tbl_data->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, input_mail_tbl_data->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_tbl_data->account_id);
error = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -3351,8 +3467,9 @@ static int emcore_make_envelope_from_mail(emstorage_mail_tbl_t *input_mail_tbl_d
emcore_encode_rfc2047_address(envelope->cc, &error);
emcore_encode_rfc2047_address(envelope->bcc, &error);
- if (input_mail_tbl_data->subject)
+ if (input_mail_tbl_data->subject) {
envelope->subject = emcore_encode_rfc2047_text(input_mail_tbl_data->subject, &error);
+ }
char rfc822_date_string[DATE_STR_LENGTH] = { 0, };
rfc822_date(rfc822_date_string);
@@ -3491,7 +3608,7 @@ static char *emcore_get_digest_string(int digest_type, int mime_type)
/* input_mail_tbl_data : */
/* is_draft : this mail is draft mail. */
/* file_path : path of file that rfc822 data will be written to. */
-INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, emstorage_attachment_tbl_t *input_attachment_tbl, int input_attachment_count, ENVELOPE **env, char **file_path, email_option_t *sending_option, int *err_code)
+INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emstorage_mail_tbl_t *input_mail_tbl_data, emstorage_attachment_tbl_t *input_attachment_tbl, int input_attachment_count, ENVELOPE **env, char **file_path, email_option_t *sending_option, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mail_tbl_data[%p], env[%p], file_path[%p], sending_option[%p], err_code[%p]", input_mail_tbl_data, env, file_path, sending_option, err_code);
@@ -3508,6 +3625,9 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
PART *part_for_related = NULL;
PARAMETER *param = NULL;
+ char *prefix_path = NULL;
+ char real_file_path[MAX_PATH] = {0};
+
if (!input_mail_tbl_data) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
error = EMAIL_ERROR_INVALID_PARAM;
@@ -3520,7 +3640,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
goto FINISH_OFF;
}
- if ( (error = emcore_make_envelope_from_mail(input_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
+ if ( (error = emcore_make_envelope_from_mail(multi_user_name, input_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_make_envelope_from_mail failed [%d]", error);
goto FINISH_OFF;
}
@@ -3544,6 +3664,16 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
goto FINISH_OFF;
}
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ error = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
if (input_attachment_count > 0) {
/* handle the Multipart/mixed, Multipart/related and S/MIME */
EM_DEBUG_LOG("input_attachment_num [%d]", input_attachment_count);
@@ -3636,9 +3766,12 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
if (strlen(input_mail_tbl_data->file_path_plain) > 0) {
EM_DEBUG_LOG_SEC("file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_plain);
text_body = &(part_for_alternative->body);
- if (!attach_part(text_body, (unsigned char *)input_mail_tbl_data->file_path_plain, 0, NULL, "plain", false, &error)) {
+ if (!attach_part(text_body, (unsigned char *)real_file_path, 0, NULL, "plain", false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
@@ -3647,8 +3780,11 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
if (strlen(input_mail_tbl_data->file_path_html) > 0) {
EM_DEBUG_LOG_SEC("file_path_html[%s]", input_mail_tbl_data->file_path_html);
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_html);
+
html_body = &(part_for_alternative->body);
- if (!attach_part (html_body, (unsigned char *)input_mail_tbl_data->file_path_html, 0, NULL, "html", false, &error)) {
+ if (!attach_part (html_body, (unsigned char *)real_file_path, 0, NULL, "html", false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
@@ -3658,8 +3794,11 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
(input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html)) {
if (input_mail_tbl_data->file_path_plain && EM_SAFE_STRLEN(input_mail_tbl_data->file_path_plain) > 0) {
EM_DEBUG_LOG_SEC("file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
- if (!attach_part (root_body, (unsigned char *) input_mail_tbl_data->file_path_plain, 0,
- NULL, "plain", false, &error)) {
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_plain);
+
+ if (!attach_part (root_body, (unsigned char *)real_file_path, 0, NULL, "plain", false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
@@ -3667,7 +3806,8 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
if (input_mail_tbl_data->file_path_html && EM_SAFE_STRLEN(input_mail_tbl_data->file_path_html) > 0) {
EM_DEBUG_LOG_SEC("file_path_html[%s]", input_mail_tbl_data->file_path_html);
- if (input_mail_tbl_data->inline_content_count > 0 && (strcasecmp(root_body->subtype, "RELATED") != 0)) {
+ if (input_mail_tbl_data->inline_content_count > 0 &&
+ (root_body->subtype && (strcasecmp(root_body->subtype, "RELATED") != 0))) {
part_for_related = attach_multipart_with_sub_type(root_body, "RELATED", &error);
if (!part_for_related) {
EM_DEBUG_EXCEPTION("attach_multipart_with_sub_type [related] failed [%d]", error);
@@ -3675,15 +3815,18 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
}
}
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_html);
+
if (part_for_related) {
- if (!attach_part(&(part_for_related->body), (unsigned char *)input_mail_tbl_data->file_path_html, 0,
- NULL, "html", false, &error)) {
+ if (!attach_part(&(part_for_related->body), (unsigned char *)real_file_path, 0,
+ NULL, "html", false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
} else {
- if (!attach_part (root_body, (unsigned char *)input_mail_tbl_data->file_path_html, 0,
- NULL, "html", false, &error)) {
+ if (!attach_part (root_body, (unsigned char *)real_file_path, 0,
+ NULL, "html", false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
@@ -3692,6 +3835,10 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
} else if (input_mail_tbl_data->smime_type == EMAIL_SMIME_SIGNED || input_mail_tbl_data->smime_type == EMAIL_PGP_SIGNED) {
if (input_mail_tbl_data->file_path_mime_entity && EM_SAFE_STRLEN(input_mail_tbl_data->file_path_mime_entity) > 0) {
EM_DEBUG_LOG_SEC("file_path_mime_entity[%s]", input_mail_tbl_data->file_path_mime_entity);
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_mime_entity);
+
root_body->sparep = EM_SAFE_STRDUP(input_mail_tbl_data->file_path_mime_entity);
}
} else if (input_mail_tbl_data->smime_type == EMAIL_PGP_ENCRYPTED || input_mail_tbl_data->smime_type == EMAIL_PGP_SIGNED_AND_ENCRYPTED) {
@@ -3732,12 +3879,15 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
else
body_to_attach = root_body;
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, temp_attachment_tbl->attachment_path);
+
if (!attach_part(body_to_attach,
- (unsigned char *)temp_attachment_tbl->attachment_path,
- 0,
- name,
- temp_attachment_tbl->attachment_mime_type,
- temp_attachment_tbl->attachment_inline_content_status,
+ (unsigned char *)real_file_path,
+ 0,
+ name,
+ temp_attachment_tbl->attachment_mime_type,
+ temp_attachment_tbl->attachment_inline_content_status,
&error))
{
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
@@ -3763,7 +3913,10 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
if (strlen(input_mail_tbl_data->file_path_plain) > 0) {
EM_DEBUG_LOG_SEC("file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
- if (!attach_part(root_body, (unsigned char *)input_mail_tbl_data->file_path_plain, 0, NULL, "plain", false, &error)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_plain);
+
+ if (!attach_part(root_body, (unsigned char *)real_file_path, 0, NULL, "plain", false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
@@ -3772,7 +3925,10 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
if (strlen(input_mail_tbl_data->file_path_html) > 0) {
EM_DEBUG_LOG_SEC("file_path_html[%s]", input_mail_tbl_data->file_path_html);
- if (!attach_part (root_body, (unsigned char *)input_mail_tbl_data->file_path_html, 0, NULL, "html", false, &error)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_html);
+
+ if (!attach_part (root_body, (unsigned char *)real_file_path, 0, NULL, "html", false, &error)) {
EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
goto FINISH_OFF;
}
@@ -3781,8 +3937,17 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_
else {
root_body->type = TYPETEXT;
root_body->encoding = ENC8BIT;
- if (input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html)
- root_body->sparep = EM_SAFE_STRDUP(input_mail_tbl_data->file_path_plain ? input_mail_tbl_data->file_path_plain : input_mail_tbl_data->file_path_html);
+ if (input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html) {
+ if (input_mail_tbl_data->file_path_plain) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_plain);
+ } else {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_html);
+ }
+
+ root_body->sparep = EM_SAFE_STRDUP(real_file_path);
+ }
else
root_body->sparep = NULL;
@@ -3826,6 +3991,7 @@ FINISH_OFF:
mail_free_body(&root_body);
EM_SAFE_FREE(digest_string);
+ EM_SAFE_FREE(prefix_path);
if (err_code != NULL)
*err_code = error;
@@ -3834,7 +4000,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_make_rfc822_file(email_mail_data_t *input_mail_tbl_data, email_attachment_data_t *input_attachment_tbl, int input_attachment_count, int mime_entity_status, char **file_path, int *err_code)
+INTERNAL_FUNC int emcore_make_rfc822_file(char *multi_user_name, email_mail_data_t *input_mail_tbl_data, email_attachment_data_t *input_attachment_tbl, int input_attachment_count, int mime_entity_status, char **file_path, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mail_tbl_data[%p], file_path[%p], err_code[%p]", input_mail_tbl_data, file_path, err_code);
@@ -3887,9 +4053,9 @@ INTERNAL_FUNC int emcore_make_rfc822_file(email_mail_data_t *input_mail_tbl_data
}
modified_mail_data->attachment_count = attachment_count;
- modified_mail_data->inline_content_count = inline_content_count;
-
- if (!emcore_make_rfc822_file_from_mail(modified_mail_data, modified_attachment_data, input_attachment_count, NULL, file_path, NULL, &err)) {
+ modified_mail_data->inline_content_count = inline_content_count;
+
+ if (!emcore_make_rfc822_file_from_mail(multi_user_name, modified_mail_data, modified_attachment_data, input_attachment_count, NULL, file_path, NULL, &err)) {
EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -3912,7 +4078,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_SUPPORT_REPORT_MAIL__
-static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body, int *err_code)
+static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope, BODY **multipart_body, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("envelope[%p], mulitpart_body[%p], err_code[%p]", envelope, multipart_body, err_code);
@@ -4021,7 +4187,7 @@ static int emcore_get_report_mail_body(ENVELOPE *envelope, BODY **multipart_body
goto FINISH_OFF;
}
- if (!attach_attachment_to_body(&m_body, text_body, temp_attachment_tbl, 1, &err)) {
+ if (!attach_attachment_to_body(multi_user_name, &m_body, text_body, temp_attachment_tbl, 1, &err)) {
EM_DEBUG_EXCEPTION(" attach_attachment_to_body failed [%d]", err);
goto FINISH_OFF;
}
@@ -4137,7 +4303,7 @@ FINISH_OFF:
return ret;
}
-static int emcore_copy_attachment_from_original_mail(int input_original_mail_id, int input_target_mail_id)
+static int emcore_copy_attachment_from_original_mail(char *multi_user_name, int input_original_mail_id, int input_target_mail_id)
{
EM_DEBUG_FUNC_BEGIN("input_original_mail_id[%d] input_target_mail_id[%d]", input_original_mail_id, input_target_mail_id);
int err = EMAIL_ERROR_NONE;
@@ -4147,16 +4313,17 @@ static int emcore_copy_attachment_from_original_mail(int input_original_mail_id,
int attachment_id = 0;
char output_file_name[MAX_PATH] = { 0, };
char output_file_path[MAX_PATH] = { 0, };
+ char virtual_file_path[MAX_PATH] = { 0, };
emstorage_attachment_tbl_t *original_mail_attachment_array = NULL;
emstorage_attachment_tbl_t *target_mail_attachment_array = NULL;
emstorage_attachment_tbl_t *target_attach = NULL;
- if((err = emstorage_get_attachment_list(input_original_mail_id, false, &original_mail_attachment_array, &original_mail_attachment_count)) != EMAIL_ERROR_NONE) {
+ if((err = emstorage_get_attachment_list(multi_user_name, input_original_mail_id, false, &original_mail_attachment_array, &original_mail_attachment_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
goto FINISH_OFF;
}
- if((err = emstorage_get_attachment_list(input_target_mail_id, false, &target_mail_attachment_array, &target_mail_attachment_count)) != EMAIL_ERROR_NONE) {
+ if((err = emstorage_get_attachment_list(multi_user_name, input_target_mail_id, false, &target_mail_attachment_array, &target_mail_attachment_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -4174,19 +4341,28 @@ static int emcore_copy_attachment_from_original_mail(int input_original_mail_id,
EM_DEBUG_LOG("attachment_inline_content_status [%d] attachment_id[%d]", target_attach->attachment_inline_content_status, attachment_id);
- if(!emcore_save_mail_file(target_attach->account_id, target_attach->mail_id, attachment_id, original_mail_attachment_array[i].attachment_path, original_mail_attachment_array[i].attachment_name, output_file_path, sizeof(output_file_path), &err)) {
+ if(!emcore_save_mail_file(multi_user_name,
+ target_attach->account_id,
+ target_attach->mail_id,
+ attachment_id,
+ original_mail_attachment_array[i].attachment_path,
+ original_mail_attachment_array[i].attachment_name,
+ output_file_path,
+ virtual_file_path,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_save_mail_file failed [%d]", err);
goto FINISH_OFF;
}
EM_SAFE_FREE(target_attach->attachment_path);
- target_attach->attachment_path = EM_SAFE_STRDUP(output_file_path);
+ target_attach->attachment_path = EM_SAFE_STRDUP(virtual_file_path);
target_attach->attachment_save_status = 1;
- if(!emstorage_update_attachment(target_attach, false, &err)) {
+ if(!emstorage_update_attachment(multi_user_name, target_attach, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_attachment failed [%d]", err);
goto FINISH_OFF;
}
+
memset(output_file_path, 0, MAX_PATH);
memset(output_file_name, 0, MAX_PATH);
break;
@@ -4206,7 +4382,7 @@ FINISH_OFF:
}
/* send a mail */
-INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(int input_mail_id)
+INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(char *multi_user_name, int input_mail_id)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d]", input_mail_id);
int err = EMAIL_ERROR_NONE;
@@ -4217,7 +4393,7 @@ INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(
email_attachment_data_t *attachment_array = NULL;
/* Get mail data */
- if((err = emcore_get_mail_data(input_mail_id, &mail_to_be_sent)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_get_mail_data(multi_user_name, input_mail_id, &mail_to_be_sent)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
goto FINISH_OFF;
}
@@ -4229,13 +4405,13 @@ INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(
}
/* Get original mail data */
- if((err = emcore_get_mail_data(mail_to_be_sent->reference_mail_id, &original_mail)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_get_mail_data(multi_user_name, mail_to_be_sent->reference_mail_id, &original_mail)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
goto FINISH_OFF;
}
/* Check necessity of download */
- if((err = emcore_get_attachment_data_list(original_mail->mail_id, &attachment_array, &attachment_count)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_get_attachment_data_list(multi_user_name, original_mail->mail_id, &attachment_array, &attachment_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -4245,28 +4421,21 @@ INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(
if(attachment_array[i].save_status != 1) {
/* this function is not run by event thread,
so cancellable should be set to 0*/
-#ifdef __FEATURE_USE_GMIME__
- if(!emcore_gmime_download_attachment (original_mail->mail_id, i + 1, 0, -1, 0, &err)) {
- EM_DEBUG_EXCEPTION("emcore_download_attachment failed [%d]", err);
+ if(!emcore_gmime_download_attachment(multi_user_name, original_mail->mail_id, i + 1, 0, -1, 0, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_gmime_download_attachment failed [%d]", err);
goto FINISH_OFF;
}
-#else
- if(!emcore_download_attachment (original_mail->account_id, original_mail->mail_id, i + 1, 0, -1, &err)) {
- EM_DEBUG_EXCEPTION("emcore_download_attachment failed [%d]", err);
- goto FINISH_OFF;
- }
-#endif
}
}
/* Copy attachment to the mail to be sent */
- if((err = emcore_copy_attachment_from_original_mail(original_mail->mail_id, mail_to_be_sent->mail_id)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_download_attachment failed [%d]", err);
+ if((err = emcore_copy_attachment_from_original_mail(multi_user_name, original_mail->mail_id, mail_to_be_sent->mail_id)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_copy_attachment_from_original failed [%d]", err);
goto FINISH_OFF;
}
/* Send the mail */
- if(!emcore_send_mail(mail_to_be_sent->mail_id, &err)) {
+ if(!emcore_send_mail(multi_user_name, mail_to_be_sent->mail_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -4297,6 +4466,7 @@ static int emcore_sending_alarm_cb(email_alarm_data_t *alarm_data, void *user_pa
EM_DEBUG_FUNC_BEGIN("alarm_data [%p] user_parameter [%p]", alarm_data, user_parameter);
int err = EMAIL_ERROR_NONE;
int ret = 0;
+ char *multi_user_name = (char *)user_parameter;
if (alarm_data == NULL) {
EM_DEBUG_EXCEPTION("Invalid parameter");
@@ -4304,7 +4474,7 @@ static int emcore_sending_alarm_cb(email_alarm_data_t *alarm_data, void *user_pa
}
/* send mail here */
- if(!emcore_send_mail(alarm_data->reference_id, &err)) {
+ if(!emcore_send_mail(multi_user_name, alarm_data->reference_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", ret);
goto FINISH_OFF;
}
@@ -4316,38 +4486,39 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_schedule_sending_mail(int input_mail_id, time_t input_time_to_send)
+INTERNAL_FUNC int emcore_schedule_sending_mail(char *multi_user_name, int input_mail_id, time_t input_time_to_send)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d] input_time_to_send[%d]", input_mail_id, input_time_to_send);
int err = EMAIL_ERROR_NONE;
emstorage_mail_tbl_t *mail_data = NULL;
/* get mail data */
- if (!emstorage_get_mail_by_id(input_mail_id, &mail_data, true, &err) || mail_data == NULL) {
+ if (!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_data, true, &err) || mail_data == NULL) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
/*
- if (!emstorage_set_field_of_mails_with_integer_value(mail_data->account_id, &(mail_data->mail_id), 1, "save_status", EMAIL_MAIL_STATUS_SEND_SCHEDULED, true, &err)) {
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, mail_data->account_id, &(mail_data->mail_id), 1, "save_status", EMAIL_MAIL_STATUS_SEND_SCHEDULED, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
*/
- if (!emstorage_set_field_of_mails_with_integer_value(mail_data->account_id, &(mail_data->mail_id), 1, "scheduled_sending_time", input_time_to_send, true, &err)) {
+ if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, mail_data->account_id, &(mail_data->mail_id), 1, "scheduled_sending_time", input_time_to_send, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
/* add alarm */
- if ((err = emcore_add_alarm(input_time_to_send, EMAIL_ALARM_CLASS_SCHEDULED_SENDING, input_mail_id, emcore_sending_alarm_cb, NULL)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_alarm(multi_user_name, input_time_to_send, EMAIL_ALARM_CLASS_SCHEDULED_SENDING, input_mail_id, emcore_sending_alarm_cb, NULL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
- if(mail_data)
+
+ if (mail_data)
emstorage_free_mail(&mail_data, 1, NULL);
EM_DEBUG_FUNC_END("err [%d]", err);
@@ -4370,6 +4541,7 @@ static int emcore_auto_resend_cb(email_alarm_data_t *alarm_data, void *user_para
int sorting_rule_count = 2;
int result_mail_count = 0;
int i = 0;
+ char *multi_user_name = (char *)user_parameter;
/* Get all mails have remaining resend counts in outbox with status 'EMAIL_MAIL_STATUS_SEND_FAILURE or EMAIL_MAIL_STATUS_SEND_WAIT' */
attribute_field_name = emcore_get_mail_field_name_by_attribute_type(EMAIL_MAIL_ATTRIBUTE_REMAINING_RESEND_TIMES);
@@ -4404,14 +4576,14 @@ static int emcore_auto_resend_cb(email_alarm_data_t *alarm_data, void *user_para
sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_MAIL_ID;
sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_ASCEND;
- if( (err = emstorage_write_conditional_clause_for_getting_mail_list(filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
- if(!emstorage_query_mail_list(conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
+ if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
EM_DEBUG_LOG("There is no mails to be sent [%d]", err);
goto FINISH_OFF;
}
@@ -4419,12 +4591,12 @@ static int emcore_auto_resend_cb(email_alarm_data_t *alarm_data, void *user_para
/* Send mails in loop */
for(i = 0; i < result_mail_count; i++) {
- if(!emcore_send_mail(result_mail_list[i].mail_id, &err)) {
+ if(!emcore_send_mail(multi_user_name, result_mail_list[i].mail_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err);
}
if(attribute_field_name) {
- if(!emstorage_set_field_of_mails_with_integer_value(result_mail_list[i].account_id, &(result_mail_list[i].mail_id), 1, attribute_field_name, result_mail_list[i].remaining_resend_times - 1, true, &err)) {
+ if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, result_mail_list[i].account_id, &(result_mail_list[i].mail_id), 1, attribute_field_name, result_mail_list[i].remaining_resend_times - 1, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
}
}
@@ -4438,7 +4610,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(int input_alarm_interval_in_second)
+INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(char *multi_user_name, int input_alarm_interval_in_second)
{
EM_DEBUG_FUNC_BEGIN("input_alarm_interval_in_second[%d]", input_alarm_interval_in_second);
int err = EMAIL_ERROR_NONE;
@@ -4496,14 +4668,14 @@ INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(int input_alarm_interval_i
sorting_rule_list[1].target_attribute = EMAIL_MAIL_ATTRIBUTE_MAIL_ID;
sorting_rule_list[1].sort_order = EMAIL_SORT_ORDER_ASCEND;
- if( (err = emstorage_write_conditional_clause_for_getting_mail_list(filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
- if(!emstorage_query_mail_list(conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
+ if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
if (err == EMAIL_ERROR_MAIL_NOT_FOUND)
EM_DEBUG_LOG ("no mail found");
else
@@ -4517,7 +4689,7 @@ INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(int input_alarm_interval_i
trigger_at_time = current_time + input_alarm_interval_in_second;
- if ((err = emcore_add_alarm(trigger_at_time, EMAIL_ALARM_CLASS_AUTO_RESEND, 0, emcore_auto_resend_cb, NULL)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_AUTO_RESEND, 0, emcore_auto_resend_cb, NULL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
goto FINISH_OFF;
}
diff --git a/email-core/email-core-task-manager.c b/email-core/email-core-task-manager.c
index bad8921..bf0e57b 100755
--- a/email-core/email-core-task-manager.c
+++ b/email-core/email-core-task-manager.c
@@ -1,646 +1,678 @@
-/*
-* email-service
-*
-* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-*
-* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-*
-* 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.
-*
-*/
-
-/*
- * email-core-task-manager.c
- *
- * Created on: 2012. 11. 1.
- * Author: kyuho.jo@samsung.com
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <dbus/dbus.h>
-
-#include "email-internal-types.h"
-#include "email-utilities.h"
-#include "email-core-tasks.h"
-#include "email-core-task-manager.h"
-#include "email-core-signal.h"
-#include "email-core-global.h"
-#include "email-core-utils.h"
-#include "email-debug-log.h"
-
-/* TODO : implement a function for removing a task from task pool */
-/* TODO : after fetching a task from DB, update status of the task. */
-
-
-#define REGISTER_TASK_BINDER(TASK_NAME) emcore_register_task_handler(TASK_NAME, task_handler_##TASK_NAME, email_encode_task_parameter_##TASK_NAME, email_decode_task_parameter_##TASK_NAME)
-
-/*- variables - begin --------------------------------------------------------*/
-static pthread_cond_t _task_available_signal = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t _task_available_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t _task_manager_loop_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t _active_task_pool_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static email_active_task_t _active_task_pool[MAX_ACTIVE_TASK];
-static thread_t _thread_task_manager_loop;
-static int _task_manager_loop_availability = 1;
-/*- variables - end ----------------------------------------------------------*/
-static int emcore_insert_task_to_active_task_pool(int input_task_slot_index, int input_task_id, email_task_type_t input_task_type, thread_t input_thread_id);
-static int emcore_remove_task_from_active_task_pool(int input_task_id);
-static int emcore_find_available_slot_in_active_task_pool(int *result_index);
-static int emcore_update_task_status_on_task_table(int input_task_id, email_task_status_type_t task_status);
-static int emcore_get_task_handler_reference(email_task_type_t input_task_type, email_task_handler_t **output_task_handler);
-
-/*- task handlers helpers - begin --------------------------------------------*/
-static int emcore_initialize_async_task_handler(email_task_t *input_task)
-{
- EM_DEBUG_FUNC_BEGIN("input_task [%p]", input_task);
- int err = EMAIL_ERROR_NONE;
-
- if(input_task == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- /* insert task to _active_task_pool */
- emcore_insert_task_to_active_task_pool(input_task->active_task_id
- , input_task->task_id
- , input_task->task_type
- , THREAD_SELF());
-
- /* send notification for 'task start */
- if( (err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_send_task_status_signal failed [%d]", err);
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-static int emcore_finalize_async_task_handler(email_task_t *input_task, int input_error_code)
-{
- EM_DEBUG_FUNC_BEGIN("input_task [%p] input_error_code [%d]",input_task ,input_error_code);
- int err = EMAIL_ERROR_NONE;
- email_task_status_type_t task_status = EMAIL_TASK_STATUS_FINISHED;
-
- if(input_task == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- if(input_error_code != EMAIL_ERROR_NONE) {
- task_status = EMAIL_TASK_STATUS_FAILED;
- }
-
- /* remove task from task table */
- if( (err = emcore_remove_task_from_task_table(input_task->task_id)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_remove_task_from_active_task_pool failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* remove task id from active task id array */
- if( (err = emcore_remove_task_from_active_task_pool(input_task->task_id)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_remove_task_from_active_task_pool failed [%d]", err);
- goto FINISH_OFF;
- }
-
- /* send signal for 'task finish or failure */
- if( (err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, task_status, input_error_code, 0)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_send_task_status_signal failed [%d]", err);
- goto FINISH_OFF;
- }
-
- ENTER_CRITICAL_SECTION(_task_available_lock);
- WAKE_CONDITION_VARIABLE(_task_available_signal);
- LEAVE_CRITICAL_SECTION(_task_available_lock);
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC void* emcore_default_async_task_handler(void *input_param)
-{
- EM_DEBUG_FUNC_BEGIN("intput_param [%p]", input_param);
- int err = EMAIL_ERROR_NONE;
- email_task_t *task = input_param;
- email_task_handler_t *task_handler = NULL;
- void *decoded_task_parameter = NULL;
-
- if((err = emcore_initialize_async_task_handler(task)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_initialize_async_task_handler failed. [%d]", err);
- goto FINISH_OFF;
- }
-
- /* create a thread to do this task */
- if((err = emcore_get_task_handler_reference(task->task_type, &task_handler)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_LOG("emcore_get_task_handler_reference returns [%d]", err);
- }
- else {
- /* Decode parameter */
- emcore_decode_task_parameter(task->task_type, task->task_parameter, task->task_parameter_length, &decoded_task_parameter);
- task_handler->task_handler_function(decoded_task_parameter);
- }
-
-FINISH_OFF:
- emcore_finalize_async_task_handler(task, err);
-
- EM_SAFE_FREE(decoded_task_parameter);
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return NULL;
-}
-
-INTERNAL_FUNC void* emcore_default_sync_task_handler(void *intput_param)
-{
- EM_DEBUG_FUNC_BEGIN("intput_param [%p]", intput_param);
- int err = EMAIL_ERROR_NONE;
- email_task_t *task = intput_param;
- email_task_handler_t *task_handler = NULL;
- void *decoded_task_parameter = NULL;
-
- /* create a thread to do this task */
- if((err = emcore_get_task_handler_reference(task->task_type, &task_handler)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_LOG("emcore_get_task_handler_reference returns [%d]", err);
- }
- else {
- /* Decode parameter */
- emcore_decode_task_parameter(task->task_type, task->task_parameter, task->task_parameter_length, &decoded_task_parameter);
- err = (int)task_handler->task_handler_function(decoded_task_parameter);
- }
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return (void*)err;
-}
-/*- task handlers helpers - end --------------------------------------------*/
-
-int _task_handler_array_size;
-email_task_handler_t **_task_handler_array;
-
-static int emcore_register_task_handler(email_task_type_t input_task_type, void* (*input_task_handler)(void *), int (*input_task_parameter_encoder)(void*,char**,int*), int (*input_task_parameter_decoder)(char*,int,void**))
-{
- EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_handler [%p] input_task_parameter_encoder [%p] input_task_parameter_decoder [%p]", input_task_type, input_task_handler, input_task_parameter_encoder, input_task_parameter_decoder);
- int err = EMAIL_ERROR_NONE;
- email_task_handler_t *new_task_handler = NULL;
-
- new_task_handler = malloc(sizeof(email_task_handler_t));
- if (new_task_handler == NULL) {
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
- goto FINISH_OFF;
- }
-
- new_task_handler->task_type = input_task_type;
- new_task_handler->task_handler_function = input_task_handler;
- new_task_handler->task_parameter_encoder = input_task_parameter_encoder;
- new_task_handler->task_parameter_decoder = input_task_parameter_decoder;
-
- _task_handler_array_size++;
-
- if (_task_handler_array) {
- _task_handler_array = realloc(_task_handler_array, sizeof(email_task_handler_t*) * _task_handler_array_size);
- }
- else {
- _task_handler_array = malloc(sizeof(email_task_handler_t*) * _task_handler_array_size);
- }
-
- if (_task_handler_array == NULL) {
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- EM_SAFE_FREE(new_task_handler);
- goto FINISH_OFF;
- }
-
- _task_handler_array[_task_handler_array_size - 1] = new_task_handler;
-
-FINISH_OFF:
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_init_task_handler_array()
-{
- EM_DEBUG_FUNC_BEGIN();
-
- if (_task_handler_array == NULL) {
- _task_handler_array = NULL;
- _task_handler_array_size = 0;
-
- REGISTER_TASK_BINDER(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT);
- REGISTER_TASK_BINDER(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX);
- REGISTER_TASK_BINDER(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL);
- REGISTER_TASK_BINDER(EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL);
- REGISTER_TASK_BINDER(EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE);
- }
-
- EM_DEBUG_FUNC_END();
- return EMAIL_ERROR_NONE;
-}
-
-INTERNAL_FUNC int emcore_free_task_handler_array()
-{
- EM_DEBUG_FUNC_BEGIN();
-
- int i = 0;
-
- for(i = 0; i < _task_handler_array_size; i++) {
- EM_SAFE_FREE (_task_handler_array[i]);
- }
-
- EM_SAFE_FREE (_task_handler_array);
- _task_handler_array_size = 0;
-
- EM_DEBUG_FUNC_END();
- return EMAIL_ERROR_NONE;
-}
-
-static int emcore_get_task_handler_reference(email_task_type_t input_task_type, email_task_handler_t **output_task_handler)
-{
- EM_DEBUG_FUNC_BEGIN("input_task_type [%d] output_task_handler [%p]", input_task_type, output_task_handler);
- int i = 0;
- int err = EMAIL_ERROR_NONE;
-
- if (output_task_handler == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- *output_task_handler = NULL;
- for (i = 0; i < _task_handler_array_size; i++) {
- if (_task_handler_array[i]->task_type == input_task_type) {
- *output_task_handler = _task_handler_array[i];
- break;
- }
- }
-
- if (*output_task_handler == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_TASK_BINDER_NOT_FOUND");
- err = EMAIL_ERROR_TASK_BINDER_NOT_FOUND;
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_encode_task_parameter(email_task_type_t input_task_type, void *input_task_parameter_struct, char **output_byte_stream, int *output_stream_size)
-{
- EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_parameter_struct [%p] output_byte_stream [%p] output_stream_size [%p]", input_task_type, input_task_parameter_struct, output_byte_stream, output_stream_size);
- int err = EMAIL_ERROR_NONE;
- email_task_handler_t *task_handler = NULL;
- int (*task_parameter_encoder)(void*, char**, int*);
-
- if (input_task_parameter_struct == NULL || output_byte_stream == NULL || output_stream_size == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- if ((err = emcore_get_task_handler_reference(input_task_type, &task_handler)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_get_task_handler_reference failed [%d]", err);
- goto FINISH_OFF;
- }
-
- task_parameter_encoder = task_handler->task_parameter_encoder;
-
- if ((err = task_parameter_encoder(input_task_parameter_struct, output_byte_stream, output_stream_size)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("task_parameter_encoder failed [%d]", err);
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_decode_task_parameter(email_task_type_t input_task_type, char *input_byte_stream, int input_stream_size, void **output_task_parameter_struct)
-{
- EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]", input_task_type, input_byte_stream, input_stream_size, output_task_parameter_struct);
- int err = EMAIL_ERROR_NONE;
- email_task_handler_t *task_handler = NULL;
- int (*task_parameter_decoder)(char*, int, void**);
-
- if (input_byte_stream == NULL || output_task_parameter_struct == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- if ((err = emcore_get_task_handler_reference(input_task_type, &task_handler)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_get_task_handler_reference failed [%d]", err);
- goto FINISH_OFF;
- }
-
- task_parameter_decoder = task_handler->task_parameter_decoder;
-
- if ((err = task_parameter_decoder(input_byte_stream, input_stream_size, output_task_parameter_struct)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("task_parameter_decoder failed [%d]", err);
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-int emcore_fetch_task_from_task_pool(email_task_t **output_task)
-{
- EM_DEBUG_FUNC_BEGIN("output_task [%p]", output_task);
- int err = EMAIL_ERROR_NONE;
- int output_task_count;
-
- if((err = emstorage_query_task("WHERE task_status == 1", " ORDER BY date_time ASC, task_priority ASC LIMIT 0, 1", output_task, &output_task_count)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_query_task failed [%d]", err);
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-
-/*-Task manager loop - begin -------------------------------------------------------------*/
-
-
-static int emcore_insert_task_to_active_task_pool(int input_task_slot_index, int input_task_id, email_task_type_t input_task_type, thread_t input_thread_id)
-{
- EM_DEBUG_FUNC_BEGIN("input_task_slot_index [%d] input_task_id [%d] input_task_type [%d] input_thread_id [%d]", input_task_slot_index, input_task_id, input_task_type, input_thread_id);
- int err = EMAIL_ERROR_NONE;
-
- ENTER_CRITICAL_SECTION(_active_task_pool_lock);
- _active_task_pool[input_task_slot_index].task_id = input_task_id;
- _active_task_pool[input_task_slot_index].task_type = input_task_type;
- _active_task_pool[input_task_slot_index].thread_id = input_thread_id;
- LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
-
- EM_DEBUG_LOG("_active_task_pool[%d].task_id [%d]", input_task_slot_index, _active_task_pool[input_task_slot_index].task_id);
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-static int emcore_remove_task_from_active_task_pool(int input_task_id)
-{
- EM_DEBUG_FUNC_BEGIN(" input_task_id [%d]", input_task_id);
- int err = EMAIL_ERROR_NONE;
- int i = 0;
-
- ENTER_CRITICAL_SECTION(_active_task_pool_lock);
- for(i = 0; i < MAX_ACTIVE_TASK; i++) {
- if(_active_task_pool[i].task_id == input_task_id) {
- _active_task_pool[i].task_id = 0;
- _active_task_pool[i].task_type = 0;
- _active_task_pool[i].thread_id = 0;
- break;
- }
- }
- LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
-
- if(i >= MAX_ACTIVE_TASK) {
- EM_DEBUG_LOG("couldn't find proper task in active task pool [%d]", input_task_id);
- err = EMAIL_ERROR_TASK_NOT_FOUND;
- }
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_get_active_task_by_thread_id(thread_t input_thread_id, email_active_task_t **output_active_task)
-{
- EM_DEBUG_FUNC_BEGIN(" input_thread_id [%d] output_active_task [%p]", input_thread_id, output_active_task);
- int err = EMAIL_ERROR_NONE;
- int i = 0;
-
- if (output_active_task == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- for(i = 0; i < MAX_ACTIVE_TASK; i++) {
- if(_active_task_pool[i].thread_id == input_thread_id) {
- *output_active_task = _active_task_pool + i;
- break;
- }
- }
-
- if(i >= MAX_ACTIVE_TASK) {
- EM_DEBUG_LOG("couldn't find proper task in active task pool [%d]", input_thread_id);
- err = EMAIL_ERROR_TASK_NOT_FOUND;
- }
-
-FINISH_OFF:
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-
-static int emcore_find_available_slot_in_active_task_pool(int *result_index)
-{
- EM_DEBUG_FUNC_BEGIN("result_index [%p]", result_index);
- int i = 0;
- int err = EMAIL_ERROR_NONE;
-
- if (result_index == NULL) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
- err = EMAIL_ERROR_INVALID_PARAM;
- goto FINISH_OFF;
- }
-
- ENTER_CRITICAL_SECTION(_active_task_pool_lock);
- for(i = 0; i < MAX_ACTIVE_TASK; i++) {
- if(_active_task_pool[i].task_id == 0) {
- break;
- }
- }
-
- if(i >= MAX_ACTIVE_TASK) {
- EM_DEBUG_EXCEPTION("There is no available task slot");
- err = EMAIL_NO_AVAILABLE_TASK_SLOT;
- }
- else {
- _active_task_pool[i].task_id = -1;
- *result_index = i;
- }
- LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
-
-FINISH_OFF :
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-void* thread_func_task_manager_loop(void *arg)
-{
- EM_DEBUG_FUNC_BEGIN();
- int err = EMAIL_ERROR_NONE;
- int thread_error;
- int available_slot_index = 0;
- email_task_t *new_task = NULL;
-
- /* while loop */
- while (_task_manager_loop_availability) {
- /* fetch task from DB */
- if( ((err = emcore_fetch_task_from_task_pool(&new_task)) == EMAIL_ERROR_NONE) &&
- ((err = emcore_find_available_slot_in_active_task_pool(&available_slot_index)) == EMAIL_ERROR_NONE) ) {
-
- /* update task status as STARTED */
- if((err = emcore_update_task_status_on_task_table(new_task->task_id, EMAIL_TASK_STATUS_STARTED)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_update_task_status_on_task_table failed [%d]", err);
- }
- new_task->active_task_id = available_slot_index;
-
- /* create a thread to do this task */
- THREAD_CREATE(new_task->thread_id, emcore_default_async_task_handler, new_task, thread_error);
- EM_DEBUG_LOG("pthread_create returns [%d]", thread_error);
-
- /* new_task and task_parameter will be free in task handler. */
- EM_SAFE_FREE(new_task->task_parameter);
- EM_SAFE_FREE(new_task);
- }
- else {
- /* If there is no task or no available slot, sleep until someone wake you up. */
- /* Wake up case 1 : by emcore_add_task_to_task_table */
- /* Wake up case 2 : when some task terminated */
- ENTER_CRITICAL_SECTION(_task_available_lock);
- SLEEP_CONDITION_VARIABLE(_task_available_signal, _task_available_lock);
- LEAVE_CRITICAL_SECTION(_task_available_lock);
- EM_DEBUG_LOG("thread_func_task_manager_loop wake up!");
- }
- }
-
- EM_DEBUG_FUNC_END();
- return NULL;
-}
-
-INTERNAL_FUNC int emcore_start_task_manager_loop()
-{
- EM_DEBUG_FUNC_BEGIN();
- int thread_error;
- int err = EMAIL_ERROR_NONE;
-
- memset(&_active_task_pool, 0, sizeof(email_active_task_t) * MAX_ACTIVE_TASK);
-
- if (_thread_task_manager_loop) {
- EM_DEBUG_EXCEPTION("service thread is already running...");
- err = EMAIL_ERROR_ALREADY_INITIALIZED;
- goto FINISH_OFF;
- }
-
- _task_manager_loop_availability = 10;
-
- /* create thread */
- THREAD_CREATE(_thread_task_manager_loop, thread_func_task_manager_loop, NULL, thread_error);
-
- if (thread_error != 0) {
- EM_DEBUG_EXCEPTION("cannot create thread [%d]", thread_error);
- err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }
-
-FINISH_OFF :
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_stop_task_manager_loop()
-{
- EM_DEBUG_FUNC_BEGIN();
-
- int err = EMAIL_ERROR_NONE;
-
- /* TODO : cancel tasks */
-
- /* stop event_data loop */
- _task_manager_loop_availability = 0;
-
- ENTER_CRITICAL_SECTION(_task_manager_loop_lock);
- WAKE_CONDITION_VARIABLE(_task_available_signal);
- LEAVE_CRITICAL_SECTION(_task_manager_loop_lock);
-
- /* wait for thread finished */
- THREAD_JOIN(_thread_task_manager_loop);
-
- _thread_task_manager_loop = 0;
-
- DELETE_CRITICAL_SECTION(_task_manager_loop_lock);
- DELETE_CONDITION_VARIABLE(_task_available_signal);
-
- /* Free _active_task_pool */
-
- //FINISH_OFF :
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_add_task_to_task_table(email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int *output_task_id)
-{
- EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_priority [%d] input_task_parameter [%p] input_task_parameter_length [%d] output_task_id [%p]", input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, output_task_id);
- int err = EMAIL_ERROR_NONE;
-
- if((err = emstorage_add_task(input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, false, output_task_id)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_add_task failed [%d]", err);
- goto FINISH_OFF;
- }
-
- ENTER_CRITICAL_SECTION(_task_available_lock);
- WAKE_CONDITION_VARIABLE(_task_available_signal);
- LEAVE_CRITICAL_SECTION(_task_available_lock);
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-INTERNAL_FUNC int emcore_remove_task_from_task_table(int input_task_id)
-{
- EM_DEBUG_FUNC_BEGIN("input_task_id [%d]", input_task_id);
- int err = EMAIL_ERROR_NONE;
-
- if((err = emstorage_delete_task(input_task_id, true)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_delete_task failed [%d]", err);
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-static int emcore_update_task_status_on_task_table(int input_task_id, email_task_status_type_t task_status)
-{
- EM_DEBUG_FUNC_BEGIN("input_task_id [%d] task_status [%d]", input_task_id, task_status);
- int err = EMAIL_ERROR_NONE;
-
- if((err = emstorage_update_task_status(input_task_id, task_status, true)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_update_task_status failed [%d]", err);
- goto FINISH_OFF;
- }
-
-FINISH_OFF:
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
-
-/*-Task manager loop - end-------------------------------------------------------------*/
+/*
+* email-service
+*
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+*
+* 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.
+*
+*/
+
+/*
+ * email-core-task-manager.c
+ *
+ * Created on: 2012. 11. 1.
+ * Author: kyuho.jo@samsung.com
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <dbus/dbus.h>
+
+#include "email-internal-types.h"
+#include "email-utilities.h"
+#include "email-core-tasks.h"
+#include "email-core-task-manager.h"
+#include "email-core-signal.h"
+#include "email-core-global.h"
+#include "email-core-utils.h"
+#include "email-debug-log.h"
+
+/* TODO : implement a function for removing a task from task pool */
+/* TODO : after fetching a task from DB, update status of the task. */
+
+
+#define REGISTER_TASK_BINDER(TASK_NAME) emcore_register_task_handler(TASK_NAME, task_handler_##TASK_NAME, email_encode_task_parameter_##TASK_NAME, email_decode_task_parameter_##TASK_NAME)
+
+/*- variables - begin --------------------------------------------------------*/
+static pthread_cond_t _task_available_signal = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t _task_available_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t _task_manager_loop_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t _active_task_pool_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static email_active_task_t _active_task_pool[MAX_ACTIVE_TASK];
+static thread_t _thread_task_manager_loop;
+static int _task_manager_loop_availability = 1;
+/*- variables - end ----------------------------------------------------------*/
+static int emcore_insert_task_to_active_task_pool(int input_task_slot_index, int input_task_id, email_task_type_t input_task_type, thread_t input_thread_id);
+static int emcore_remove_task_from_active_task_pool(int input_task_id);
+static int emcore_find_available_slot_in_active_task_pool(int *result_index);
+static int emcore_update_task_status_on_task_table(char *multi_user_name, int input_task_id, email_task_status_type_t task_status);
+static int emcore_get_task_handler_reference(email_task_type_t input_task_type, email_task_handler_t **output_task_handler);
+
+/*- task handlers helpers - begin --------------------------------------------*/
+static int emcore_initialize_async_task_handler(email_task_t *input_task)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task [%p]", input_task);
+ int err = EMAIL_ERROR_NONE;
+
+ if(input_task == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ /* insert task to _active_task_pool */
+ emcore_insert_task_to_active_task_pool(input_task->active_task_id
+ , input_task->task_id
+ , input_task->task_type
+ , THREAD_SELF());
+
+ /* send notification for 'task start */
+ if( (err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_send_task_status_signal failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+static int emcore_finalize_async_task_handler(email_task_t *input_task, int input_error_code)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task [%p] input_error_code [%d]",input_task ,input_error_code);
+ int err = EMAIL_ERROR_NONE;
+ email_task_status_type_t task_status = EMAIL_TASK_STATUS_FINISHED;
+
+ if(input_task == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if(input_error_code != EMAIL_ERROR_NONE) {
+ task_status = EMAIL_TASK_STATUS_FAILED;
+ }
+
+ /* remove task from task table */
+ if( (err = emcore_remove_task_from_task_table(NULL, input_task->task_id)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_remove_task_from_active_task_pool failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ /* remove task id from active task id array */
+ if( (err = emcore_remove_task_from_active_task_pool(input_task->task_id)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_remove_task_from_active_task_pool failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ /* send signal for 'task finish or failure */
+ if( (err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, task_status, input_error_code, 0)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_send_task_status_signal failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ ENTER_CRITICAL_SECTION(_task_available_lock);
+ WAKE_CONDITION_VARIABLE(_task_available_signal);
+ LEAVE_CRITICAL_SECTION(_task_available_lock);
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC void* emcore_default_async_task_handler(void *input_param)
+{
+ EM_DEBUG_FUNC_BEGIN("intput_param [%p]", input_param);
+ int err = EMAIL_ERROR_NONE;
+ email_task_t *task = input_param;
+ email_task_handler_t *task_handler = NULL;
+ void *decoded_task_parameter = NULL;
+
+ if((err = emcore_initialize_async_task_handler(task)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_initialize_async_task_handler failed. [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ /* create a thread to do this task */
+ if ((err = emcore_get_task_handler_reference(task->task_type, &task_handler)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_LOG("emcore_get_task_handler_reference returns [%d]", err);
+ }
+ else {
+ /* Decode parameter */
+ emcore_decode_task_parameter(task->task_type,
+ task->task_parameter,
+ task->task_parameter_length,
+ &decoded_task_parameter);
+
+ task_handler->task_handler_function(decoded_task_parameter);
+ }
+
+FINISH_OFF:
+
+ emcore_finalize_async_task_handler(task, err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return NULL;
+}
+
+INTERNAL_FUNC int emcore_default_sync_task_handler(void *intput_param)
+{
+ EM_DEBUG_FUNC_BEGIN("intput_param [%p]", intput_param);
+ int err = EMAIL_ERROR_NONE;
+ int *return_err = NULL;
+ email_task_t *task = intput_param;
+ email_task_handler_t *task_handler = NULL;
+ void *decoded_task_parameter = NULL;
+
+ /* create a thread to do this task */
+ if ((err = emcore_get_task_handler_reference(task->task_type, &task_handler)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_LOG("emcore_get_task_handler_reference returns [%d]", err);
+ } else {
+ /* Decode parameter */
+ emcore_decode_task_parameter(task->task_type,
+ task->task_parameter,
+ task->task_parameter_length,
+ &decoded_task_parameter);
+
+ return_err = (int *)task_handler->task_handler_function(decoded_task_parameter);
+ }
+
+ if (return_err) {
+ err = *return_err;
+ free(return_err);
+ }
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+/*- task handlers helpers - end --------------------------------------------*/
+
+int _task_handler_array_size;
+email_task_handler_t **_task_handler_array;
+
+static int emcore_register_task_handler(email_task_type_t input_task_type,
+ void* (*input_task_handler)(void *),
+ int (*input_task_parameter_encoder)(void*,char**,int*),
+ int (*input_task_parameter_decoder)(char*,int,void**))
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_handler [%p] "
+ "input_task_parameter_encoder [%p] input_task_parameter_decoder [%p]",
+ input_task_type, input_task_handler,
+ input_task_parameter_encoder, input_task_parameter_decoder);
+
+ int err = EMAIL_ERROR_NONE;
+ email_task_handler_t *new_task_handler = NULL;
+
+ new_task_handler = malloc(sizeof(email_task_handler_t));
+
+ if (new_task_handler == NULL) {
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
+ goto FINISH_OFF;
+ }
+
+ new_task_handler->task_type = input_task_type;
+ new_task_handler->task_handler_function = input_task_handler;
+ new_task_handler->task_parameter_encoder = input_task_parameter_encoder;
+ new_task_handler->task_parameter_decoder = input_task_parameter_decoder;
+
+ _task_handler_array_size++;
+
+ if (_task_handler_array) {
+ _task_handler_array = realloc(_task_handler_array, sizeof(email_task_handler_t*) * _task_handler_array_size);
+ }
+ else {
+ _task_handler_array = malloc(sizeof(email_task_handler_t*) * _task_handler_array_size);
+ }
+
+ if (_task_handler_array == NULL) {
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ EM_SAFE_FREE(new_task_handler);
+ goto FINISH_OFF;
+ }
+
+ _task_handler_array[_task_handler_array_size - 1] = new_task_handler;
+
+FINISH_OFF:
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC int emcore_init_task_handler_array()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ if (_task_handler_array == NULL) {
+ _task_handler_array = NULL;
+ _task_handler_array_size = 0;
+
+ REGISTER_TASK_BINDER(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT);
+ REGISTER_TASK_BINDER(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX);
+ REGISTER_TASK_BINDER(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL);
+ REGISTER_TASK_BINDER(EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL);
+ REGISTER_TASK_BINDER(EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE);
+ }
+
+ EM_DEBUG_FUNC_END();
+ return EMAIL_ERROR_NONE;
+}
+
+INTERNAL_FUNC int emcore_free_task_handler_array()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int i = 0;
+
+ for(i = 0; i < _task_handler_array_size; i++) {
+ EM_SAFE_FREE (_task_handler_array[i]);
+ }
+
+ EM_SAFE_FREE (_task_handler_array);
+ _task_handler_array_size = 0;
+
+ EM_DEBUG_FUNC_END();
+ return EMAIL_ERROR_NONE;
+}
+
+static int emcore_get_task_handler_reference(email_task_type_t input_task_type, email_task_handler_t **output_task_handler)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_type [%d] output_task_handler [%p]", input_task_type, output_task_handler);
+ int i = 0;
+ int err = EMAIL_ERROR_NONE;
+
+ if (output_task_handler == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ *output_task_handler = NULL;
+ for (i = 0; i < _task_handler_array_size; i++) {
+ if (_task_handler_array[i]->task_type == input_task_type) {
+ *output_task_handler = _task_handler_array[i];
+ break;
+ }
+ }
+
+ if (*output_task_handler == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_TASK_BINDER_NOT_FOUND");
+ err = EMAIL_ERROR_TASK_BINDER_NOT_FOUND;
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC int emcore_encode_task_parameter(email_task_type_t input_task_type, void *input_task_parameter_struct, char **output_byte_stream, int *output_stream_size)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_parameter_struct [%p] output_byte_stream [%p] output_stream_size [%p]", input_task_type, input_task_parameter_struct, output_byte_stream, output_stream_size);
+ int err = EMAIL_ERROR_NONE;
+ email_task_handler_t *task_handler = NULL;
+ int (*task_parameter_encoder)(void*, char**, int*);
+
+ if (input_task_parameter_struct == NULL || output_byte_stream == NULL || output_stream_size == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if ((err = emcore_get_task_handler_reference(input_task_type, &task_handler)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_task_handler_reference failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ task_parameter_encoder = task_handler->task_parameter_encoder;
+
+ if ((err = task_parameter_encoder(input_task_parameter_struct, output_byte_stream, output_stream_size)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("task_parameter_encoder failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC int emcore_decode_task_parameter(email_task_type_t input_task_type, char *input_byte_stream, int input_stream_size, void **output_task_parameter_struct)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]", input_task_type, input_byte_stream, input_stream_size, output_task_parameter_struct);
+ int err = EMAIL_ERROR_NONE;
+ email_task_handler_t *task_handler = NULL;
+ int (*task_parameter_decoder)(char*, int, void**);
+
+ if (input_byte_stream == NULL || output_task_parameter_struct == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if ((err = emcore_get_task_handler_reference(input_task_type, &task_handler)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_task_handler_reference failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ task_parameter_decoder = task_handler->task_parameter_decoder;
+
+ if ((err = task_parameter_decoder(input_byte_stream,
+ input_stream_size,
+ output_task_parameter_struct)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("task_parameter_decoder failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+int emcore_fetch_task_from_task_pool(email_task_t **output_task)
+{
+ EM_DEBUG_FUNC_BEGIN("output_task [%p]", output_task);
+ int err = EMAIL_ERROR_NONE;
+ int output_task_count;
+
+ if ((err = emstorage_query_task(NULL,
+ "WHERE task_status == 1",
+ "ORDER BY date_time ASC, task_priority ASC LIMIT 0, 1",
+ output_task,
+ &output_task_count)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_query_task failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+/*-Task manager loop - begin -------------------------------------------------------------*/
+
+
+static int emcore_insert_task_to_active_task_pool(int input_task_slot_index, int input_task_id, email_task_type_t input_task_type, thread_t input_thread_id)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_slot_index [%d] input_task_id [%d] input_task_type [%d] input_thread_id [%d]", input_task_slot_index, input_task_id, input_task_type, input_thread_id);
+ int err = EMAIL_ERROR_NONE;
+
+ ENTER_CRITICAL_SECTION(_active_task_pool_lock);
+ _active_task_pool[input_task_slot_index].task_id = input_task_id;
+ _active_task_pool[input_task_slot_index].task_type = input_task_type;
+ _active_task_pool[input_task_slot_index].thread_id = input_thread_id;
+ LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
+
+ EM_DEBUG_LOG("_active_task_pool[%d].task_id [%d]", input_task_slot_index, _active_task_pool[input_task_slot_index].task_id);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+static int emcore_remove_task_from_active_task_pool(int input_task_id)
+{
+ EM_DEBUG_FUNC_BEGIN(" input_task_id [%d]", input_task_id);
+ int err = EMAIL_ERROR_NONE;
+ int i = 0;
+
+ ENTER_CRITICAL_SECTION(_active_task_pool_lock);
+ for(i = 0; i < MAX_ACTIVE_TASK; i++) {
+ if(_active_task_pool[i].task_id == input_task_id) {
+ _active_task_pool[i].task_id = 0;
+ _active_task_pool[i].task_type = 0;
+ _active_task_pool[i].thread_id = 0;
+ break;
+ }
+ }
+ LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
+
+ if(i >= MAX_ACTIVE_TASK) {
+ EM_DEBUG_LOG("couldn't find proper task in active task pool [%d]", input_task_id);
+ err = EMAIL_ERROR_TASK_NOT_FOUND;
+ }
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC int emcore_get_active_task_by_thread_id(thread_t input_thread_id, email_active_task_t **output_active_task)
+{
+ EM_DEBUG_FUNC_BEGIN(" input_thread_id [%d] output_active_task [%p]", input_thread_id, output_active_task);
+ int err = EMAIL_ERROR_NONE;
+ int i = 0;
+
+ if (output_active_task == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ for(i = 0; i < MAX_ACTIVE_TASK; i++) {
+ if(_active_task_pool[i].thread_id == input_thread_id) {
+ *output_active_task = _active_task_pool + i;
+ break;
+ }
+ }
+
+ if(i >= MAX_ACTIVE_TASK) {
+ EM_DEBUG_LOG("couldn't find proper task in active task pool [%d]", input_thread_id);
+ err = EMAIL_ERROR_TASK_NOT_FOUND;
+ }
+
+FINISH_OFF:
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+static int emcore_find_available_slot_in_active_task_pool(int *result_index)
+{
+ EM_DEBUG_FUNC_BEGIN("result_index [%p]", result_index);
+ int i = 0;
+ int err = EMAIL_ERROR_NONE;
+
+ if (result_index == NULL) {
+ EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ ENTER_CRITICAL_SECTION(_active_task_pool_lock);
+ for(i = 0; i < MAX_ACTIVE_TASK; i++) {
+ if(_active_task_pool[i].task_id == 0) {
+ break;
+ }
+ }
+
+ if(i >= MAX_ACTIVE_TASK) {
+ EM_DEBUG_EXCEPTION("There is no available task slot");
+ err = EMAIL_NO_AVAILABLE_TASK_SLOT;
+ }
+ else {
+ _active_task_pool[i].task_id = -1;
+ *result_index = i;
+ }
+ LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
+
+FINISH_OFF :
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+void* thread_func_task_manager_loop(void *arg)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ int thread_error;
+ int available_slot_index = 0;
+ email_task_t *new_task = NULL;
+
+ /* while loop */
+ while (_task_manager_loop_availability) {
+ /* fetch task from DB */
+ if( ((err = emcore_fetch_task_from_task_pool(&new_task)) == EMAIL_ERROR_NONE) &&
+ ((err = emcore_find_available_slot_in_active_task_pool(&available_slot_index)) == EMAIL_ERROR_NONE) ) {
+
+ /* update task status as STARTED */
+ if((err = emcore_update_task_status_on_task_table(NULL, new_task->task_id, EMAIL_TASK_STATUS_STARTED)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_update_task_status_on_task_table failed [%d]", err);
+ }
+ new_task->active_task_id = available_slot_index;
+
+ /* create a thread to do this task */
+ THREAD_CREATE(new_task->thread_id, emcore_default_async_task_handler, new_task, thread_error);
+ EM_DEBUG_LOG("pthread_create returns [%d]", thread_error);
+
+ /* new_task and task_parameter will be free in task handler. */
+ EM_SAFE_FREE(new_task->task_parameter);
+ EM_SAFE_FREE(new_task);
+ }
+ else {
+ /* If there is no task or no available slot, sleep until someone wake you up. */
+ /* Wake up case 1 : by emcore_add_task_to_task_table */
+ /* Wake up case 2 : when some task terminated */
+ ENTER_CRITICAL_SECTION(_task_available_lock);
+ SLEEP_CONDITION_VARIABLE(_task_available_signal, _task_available_lock);
+ LEAVE_CRITICAL_SECTION(_task_available_lock);
+ EM_DEBUG_LOG("thread_func_task_manager_loop wake up!");
+ }
+ }
+
+ EM_DEBUG_FUNC_END();
+ return NULL;
+}
+
+INTERNAL_FUNC int emcore_start_task_manager_loop()
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int thread_error;
+ int err = EMAIL_ERROR_NONE;
+
+ memset(&_active_task_pool, 0, sizeof(email_active_task_t) * MAX_ACTIVE_TASK);
+
+ if (_thread_task_manager_loop) {
+ EM_DEBUG_EXCEPTION("service thread is already running...");
+ err = EMAIL_ERROR_ALREADY_INITIALIZED;
+ goto FINISH_OFF;
+ }
+
+ _task_manager_loop_availability = 10;
+
+ /* create thread */
+ THREAD_CREATE(_thread_task_manager_loop, thread_func_task_manager_loop, NULL, thread_error);
+
+ if (thread_error != 0) {
+ EM_DEBUG_EXCEPTION("cannot create thread [%d]", thread_error);
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF :
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC int emcore_stop_task_manager_loop()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMAIL_ERROR_NONE;
+
+ if (!_thread_task_manager_loop) {
+ EM_DEBUG_LOG("_thread_task_manager_loop is NULL ");
+ err = EMAIL_ERROR_UNKNOWN;
+ return err;
+ }
+
+ /* TODO : cancel tasks */
+
+ /* stop event_data loop */
+ _task_manager_loop_availability = 0;
+
+ ENTER_CRITICAL_SECTION(_task_manager_loop_lock);
+ WAKE_CONDITION_VARIABLE(_task_available_signal);
+ LEAVE_CRITICAL_SECTION(_task_manager_loop_lock);
+
+ /* wait for thread finished */
+ THREAD_JOIN(_thread_task_manager_loop);
+
+ _thread_task_manager_loop = 0;
+
+ DELETE_CRITICAL_SECTION(_task_manager_loop_lock);
+ DELETE_CONDITION_VARIABLE(_task_available_signal);
+
+ /* Free _active_task_pool */
+
+ //FINISH_OFF :
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC int emcore_add_task_to_task_table(char *multi_user_name, email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int *output_task_id)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_priority [%d] input_task_parameter [%p] input_task_parameter_length [%d] output_task_id [%p]", input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, output_task_id);
+ int err = EMAIL_ERROR_NONE;
+
+ if((err = emstorage_add_task(multi_user_name, input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, false, output_task_id)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_add_task failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ ENTER_CRITICAL_SECTION(_task_available_lock);
+ WAKE_CONDITION_VARIABLE(_task_available_signal);
+ LEAVE_CRITICAL_SECTION(_task_available_lock);
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+INTERNAL_FUNC int emcore_remove_task_from_task_table(char *multi_user_name, int input_task_id)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_id [%d]", input_task_id);
+ int err = EMAIL_ERROR_NONE;
+
+ if((err = emstorage_delete_task(multi_user_name, input_task_id, true)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_delete_task failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+static int emcore_update_task_status_on_task_table(char *multi_user_name, int input_task_id, email_task_status_type_t task_status)
+{
+ EM_DEBUG_FUNC_BEGIN("input_task_id [%d] task_status [%d]", input_task_id, task_status);
+ int err = EMAIL_ERROR_NONE;
+
+ if((err = emstorage_update_task_status(multi_user_name, input_task_id, task_status, true)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_update_task_status failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+/*-Task manager loop - end-------------------------------------------------------------*/
diff --git a/email-core/email-core-tasks.c b/email-core/email-core-tasks.c
index d04e258..ca7a67e 100755
--- a/email-core/email-core-tasks.c
+++ b/email-core/email-core-tasks.c
@@ -67,6 +67,12 @@ INTERNAL_FUNC int email_encode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAI
, &task_parameter->target_mailbox_id
, &task_parameter->mail_id_count
, &tb);
+ if (tn == NULL) {
+ EM_DEBUG_EXCEPTION("tpl_map failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
tb.sz = sizeof(int) * task_parameter->mail_id_count;
tb.addr = task_parameter->mail_id_array;
tpl_pack(tn, 0);
@@ -97,8 +103,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAI
}
task_parameter = em_malloc(sizeof(task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT));
-
- if(task_parameter == NULL) {
+ if (task_parameter == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
@@ -111,6 +116,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAI
, &tb);
if (tn == NULL) {
EM_DEBUG_EXCEPTION("tpl_map failed");
+ EM_SAFE_FREE(task_parameter);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -145,7 +151,7 @@ INTERNAL_FUNC void* task_handler_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTH
task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT *task_param = input_param;
for(i = 0; i < task_param->mail_id_count; i++) {
- if((err = emcore_move_mail_to_another_account(task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_move_mail_to_another_account(task_param->multi_user_name, task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_move_mail_to_another_account failed [%d]", err);
goto FINISH_OFF;
}
@@ -225,7 +231,6 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX
}
task_parameter = em_malloc(sizeof(task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX));
-
if(task_parameter == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -239,6 +244,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX
, &task_parameter->on_server);
if (tn == NULL) {
EM_DEBUG_EXCEPTION("tpl_map failed");
+ EM_SAFE_FREE(task_parameter);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -322,7 +328,6 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DO
}
task_parameter = em_malloc(sizeof(task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL));
-
if (task_parameter == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -333,6 +338,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DO
, &task_parameter->mail_id);
if (tn == NULL) {
EM_DEBUG_EXCEPTION("tpl_map failed");
+ EM_SAFE_FREE(task_parameter);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -341,7 +347,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DO
tpl_unpack(tn, 0);
*output_task_parameter_struct = task_parameter;
-
+
FINISH_OFF:
if(tn)
@@ -410,7 +416,6 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_M
}
task_parameter = em_malloc(sizeof(task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL));
-
if(task_parameter == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -421,6 +426,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_M
, &task_parameter->mail_id, &task_parameter->scheduled_time);
if (tn == NULL) {
EM_DEBUG_EXCEPTION("tpl_map failed");
+ EM_SAFE_FREE(task_parameter);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
@@ -442,21 +448,35 @@ FINISH_OFF:
INTERNAL_FUNC void* task_handler_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL(void *input_param)
{
EM_DEBUG_FUNC_BEGIN("input_param [%p]", input_param);
+
int err = EMAIL_ERROR_NONE;
+ int *return_err = NULL;
task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL *task_param = input_param;
- if((err = emcore_schedule_sending_mail(task_param->mail_id, task_param->scheduled_time)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_schedule_sending_mail(task_param->multi_user_name,
+ task_param->mail_id,
+ task_param->scheduled_time)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_schedule_sending_mail [%d]", err);
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
+ return_err = em_malloc(sizeof(int));
+ if (return_err == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ *return_err = err;
+
FINISH_OFF:
EM_SAFE_FREE(task_param);
- emcore_close_smtp_stream_list ();
+ emcore_close_smtp_stream_list();
EM_DEBUG_FUNC_END("err [%d]", err);
- return (void*)err;
+
+ return (void *)return_err;
}
/*-------------------------------------------------------------------------------------------*/
/* to handle EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE */
@@ -536,13 +556,26 @@ FINISH_OFF:
if(tn)
tpl_free(tn);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_SAFE_FREE(result_data);
+
+ if (task_parameter) {
+ EM_SAFE_FREE(task_parameter->multi_user_name);
+ EM_SAFE_FREE(task_parameter->mail_id_array);
+ free(task_parameter);
+ }
+ }
+
EM_DEBUG_FUNC_END("err [%d]", err);
- return EMAIL_ERROR_NONE;
+ return err;
}
-INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(char *input_byte_stream, int input_stream_size, void **output_task_parameter_struct)
+INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(char *input_byte_stream,
+ int input_stream_size,
+ void **output_task_parameter_struct)
{
- EM_DEBUG_FUNC_BEGIN("input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]", input_byte_stream, input_stream_size, output_task_parameter_struct);
+ EM_DEBUG_FUNC_BEGIN("input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]",
+ input_byte_stream, input_stream_size, output_task_parameter_struct);
int err = EMAIL_ERROR_NONE;
tpl_node *tn = NULL;
tpl_bin tb_mail_id_array;
@@ -557,7 +590,6 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(c
}
task_parameter = em_malloc(sizeof(task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE));
-
if(task_parameter == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -581,14 +613,16 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(c
tpl_unpack(tn, 0);
if(task_parameter->mail_id_count <= 0 || tb_mail_id_array.addr == NULL) {
- EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]", task_parameter->mail_id_count, tb_mail_id_array.addr);
+ EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]",
+ task_parameter->mail_id_count, tb_mail_id_array.addr);
}
else {
task_parameter->mail_id_array = tb_mail_id_array.addr;
}
if(tb_value.addr) {
- if ((err = emcore_get_mail_attribute_value_type(task_parameter->attribute_type, &attribute_value_type)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_get_mail_attribute_value_type(task_parameter->attribute_type,
+ &attribute_value_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_attribute_value_type failed [%d]", err);
goto FINISH_OFF;
}
@@ -621,40 +655,57 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(c
FINISH_OFF:
- if(tn)
+ if (tn)
tpl_free(tn);
+ if (err != EMAIL_ERROR_NONE) {
+ if (task_parameter) {
+ EM_SAFE_FREE(task_parameter->multi_user_name);
+ EM_SAFE_FREE(task_parameter->mail_id_array);
+ free(task_parameter);
+ }
+ }
+
EM_DEBUG_FUNC_END("err [%d]", err);
- return EMAIL_ERROR_NONE;
+ return err;
}
-INTERNAL_FUNC void* task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_param)
+INTERNAL_FUNC void *task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_param)
{
EM_DEBUG_FUNC_BEGIN("input_param [%p]", input_param);
- if(!input_param) { /*prevent 43681*/
+ if (!input_param) { /*prevent 43681*/
EM_DEBUG_EXCEPTION("NULL parameter");
return NULL;
}
int err = EMAIL_ERROR_NONE;
+ int *return_err = NULL;
char *field_name = NULL;
task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE *task_param = input_param;
email_mail_attribute_value_type attribute_value_type = EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE; /*prevent 43700*/
- if((field_name = emcore_get_mail_field_name_by_attribute_type(task_param->attribute_type)) == NULL) {
+ if ((field_name = emcore_get_mail_field_name_by_attribute_type(task_param->attribute_type)) == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- if((err = emcore_get_mail_attribute_value_type(task_param->attribute_type, &attribute_value_type)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_get_mail_attribute_value_type(task_param->attribute_type,
+ &attribute_value_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_get_mail_attribute_value_type failed [%d]", err);
goto FINISH_OFF;
}
switch(attribute_value_type) {
case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER :
- if(!emstorage_set_field_of_mails_with_integer_value(task_param->account_id, task_param->mail_id_array, task_param->mail_id_count, field_name, task_param->value.integer_type_value, true, &err)) {
+ if (!emstorage_set_field_of_mails_with_integer_value(task_param->multi_user_name,
+ task_param->account_id,
+ task_param->mail_id_array,
+ task_param->mail_id_count,
+ field_name,
+ task_param->value.integer_type_value,
+ true,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
@@ -664,7 +715,14 @@ INTERNAL_FUNC void* task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_pa
EM_DEBUG_LOG("EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING is not supported");
break;
case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME :
- if(!emstorage_set_field_of_mails_with_integer_value(task_param->account_id, task_param->mail_id_array, task_param->mail_id_count, field_name, task_param->value.datetime_type_value, true, &err)) {
+ if (!emstorage_set_field_of_mails_with_integer_value(task_param->multi_user_name,
+ task_param->account_id,
+ task_param->mail_id_array,
+ task_param->mail_id_count,
+ field_name,
+ task_param->value.datetime_type_value,
+ true,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
goto FINISH_OFF;
}
@@ -676,8 +734,18 @@ INTERNAL_FUNC void* task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_pa
break;
}
+ return_err = em_malloc(sizeof(int));
+ if (return_err == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ *return_err = err;
+
FINISH_OFF:
+ EM_SAFE_FREE(task_param->multi_user_name);
EM_SAFE_FREE(task_param->mail_id_array);
if (attribute_value_type == EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING) {
EM_SAFE_FREE(task_param->value.string_type_value);
@@ -686,6 +754,7 @@ FINISH_OFF:
EM_SAFE_FREE (task_param);
EM_DEBUG_FUNC_END("err [%d]", err);
- return (void*)err;
+
+ return (void *)return_err;
}
/*-------------------------------------------------------------------------------------------*/
diff --git a/email-core/email-core-timer.c b/email-core/email-core-timer.c
index 0f293cb..d6943aa 100755
--- a/email-core/email-core-timer.c
+++ b/email-core/email-core-timer.c
@@ -72,7 +72,7 @@ INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData)
if (pUserData)
return 0;
else
- return 1;
+ return 1;
}
INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMAIL_TIMER_CALLBACK a_pCallBack, void *a_pData)
@@ -80,17 +80,14 @@ INTERNAL_FUNC int emcore_set_timer_ex(long a_nSetTimeValue, EMAIL_TIMER_CALLBACK
EM_DEBUG_LOG("emcore_set_timer_ex %d", a_nSetTimeValue);
em_timer_callback_data *pTimerData = NULL;
pTimerData = malloc(sizeof(em_timer_callback_data));
- char *data = NULL;
if (!pTimerData)
return -1;
- memset(pTimerData, 0x00, sizeof(em_timer_callback_data));
- if (a_pData)
- EM_DEBUG_LOG("emcore_set_timer_ex >>> data : %s", (char *)a_pData);
+
+ memset(pTimerData, 0x00, sizeof(em_timer_callback_data));
pTimerData->user_callback_function = a_pCallBack;
if (a_pData) {
- data = (char *) a_pData;
- pTimerData->callback_user_data = EM_SAFE_STRDUP(data);
+ pTimerData->callback_user_data = a_pData;
}
pTimerData->time_id = g_timeout_add(a_nSetTimeValue, emcore_timer_ex_callback, pTimerData);
return pTimerData->time_id;
diff --git a/email-core/email-core-utils.c b/email-core/email-core-utils.c
index b942f70..001017f 100755
--- a/email-core/email-core-utils.c
+++ b/email-core/email-core-utils.c
@@ -50,13 +50,13 @@
#include <notification.h>
#include <notification_type.h>
#include <notification_internal.h>
+#include <notification_text_domain.h>
#include <badge.h>
#include <badge_internal.h>
#ifdef __FEATURE_USE_DRM_API__
#include <drm_client_types.h>
#include <drm_client.h>
#endif /* __FEATURE_USE_DRM_API__ */
-#include <feedback.h>
#include <storage.h>
#include <bundle.h>
#include <curl/curl.h>
@@ -73,20 +73,21 @@
#include "email-core-account.h"
#include "email-core-mailbox-sync.h"
#include "email-core-mime.h"
+#include "email-core-gmime.h"
#include "email-core-signal.h"
#include "email-daemon.h"
#include "email-utilities.h"
#include "email-convert.h"
#include "email-internal-types.h"
#include "email-device.h"
+#include "email-core-container.h"
#include <gio/gio.h>
#include "email-dbus-activation.h"
-#ifdef __FEATURE_DRIVING_MODE__
#include <app_control.h>
-#endif /* __FEATURE_DRIVING_MODE__ */
+#include <app_control_internal.h>
#define LED_TIMEOUT_SECS 12
#define G_DISPLAY_LENGTH 256
@@ -102,7 +103,7 @@
#define EMAIL_CH_SQUARE_BRACKET_S '['
#define EMAIL_CH_SQUARE_BRACKET_E ']'
#define EMAIL_CH_SPACE ' '
-#define EMAIL_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/noti_email.png"
+#define EMAIL_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/E-mail/noti_email.png"
#define EMAIL_NOTI_INDICATOR_ICON_PATH "/usr/apps/org.tizen.indicator/res/icons/Event/B03_Event_email.png"
#define EMAIL_NOTI_MAX_MAIL_ID 100
@@ -126,7 +127,6 @@ struct emcore_account_list_t {
#include <gmime/gmime.h>
-
INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
{
EM_DEBUG_FUNC_BEGIN("mailbox_name[%p]", mailbox_name);
@@ -150,7 +150,7 @@ INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
return NULL;
}
-
+
for (; *cursor; ++cursor)
switch (*cursor) {
case '+':
@@ -194,7 +194,7 @@ INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
}
}
else {
- result_mailbox_name = (char *)utf8_from_mutf7 ((unsigned char *)mailbox_name);
+ result_mailbox_name = (char *)utf8_from_mutf7((unsigned char *)mailbox_name);
EM_DEBUG_LOG_SEC("result_mailbox_name[%s]", result_mailbox_name);
if (result_mailbox_name == NULL)
result_mailbox_name = EM_SAFE_STRDUP(mutf7_text);
@@ -212,7 +212,7 @@ INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
}
/* in smtp case, path argument must be ENCODED_PATH_SMTP */
-int emcore_get_long_encoded_path_with_account_info(email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code)
+int emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code)
{
EM_PROFILE_BEGIN(emCorelongEncodedpath);
EM_DEBUG_FUNC_BEGIN_SEC("account[%p], path[%s], delimiter[%d], long_enc_path[%p], err_code[%p]", account, path, delimiter, long_enc_path, err_code);
@@ -247,10 +247,21 @@ int emcore_get_long_encoded_path_with_account_info(email_account_t *account, cha
/* ex:"{mai.test.com:143/imap} or {mai.test.com:143/imap/tls}my-mailbox" */
- SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d",
- account->incoming_server_address,
- account->incoming_server_port_number,
- account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap", account->account_id);
+ if (multi_user_name) {
+ SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d%s%s",
+ account->incoming_server_address,
+ account->incoming_server_port_number,
+ account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
+ account->account_id,
+ TOKEN_FOR_MULTI_USER,
+ multi_user_name);
+ } else {
+ SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d",
+ account->incoming_server_address,
+ account->incoming_server_port_number,
+ account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
+ account->account_id);
+ }
if (account->incoming_server_secure_connection & 0x01) {
strncat(p, "/ssl", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
@@ -286,7 +297,16 @@ int emcore_get_long_encoded_path_with_account_info(email_account_t *account, cha
"smtp");
if (account->outgoing_server_need_authentication > 0) {
- SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d", account->account_id);
+ if (multi_user_name) {
+ SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d%s%s",
+ account->account_id,
+ TOKEN_FOR_MULTI_USER,
+ multi_user_name);
+ } else {
+ SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d",
+ account->account_id);
+ }
+
if (account->outgoing_server_need_authentication == EMAIL_AUTHENTICATION_METHOD_XOAUTH2) {
strncat(p, "/xoauth2", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
}
@@ -344,7 +364,7 @@ FINISH_OFF:
return ret;
}
-int emcore_get_long_encoded_path(int account_id, char *path, int delimiter, char **long_enc_path, int *err_code)
+int emcore_get_long_encoded_path(char *multi_user_name, int account_id, char *path, int delimiter, char **long_enc_path, int *err_code)
{
EM_PROFILE_BEGIN(emCorelongEncodedpath);
EM_DEBUG_FUNC_BEGIN("account_id[%d], delimiter[%d], long_enc_path[%p], err_code[%p]", account_id, delimiter, long_enc_path, err_code);
@@ -353,14 +373,14 @@ int emcore_get_long_encoded_path(int account_id, char *path, int delimiter, char
int error = EMAIL_ERROR_NONE;
email_account_t *ref_account = NULL;
- ref_account = emcore_get_account_reference(account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
error = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (emcore_get_long_encoded_path_with_account_info(ref_account, path, delimiter, long_enc_path, &error) == false) {
+ if (emcore_get_long_encoded_path_with_account_info(multi_user_name, ref_account, path, delimiter, long_enc_path, &error) == false) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path_with_account_info failed [%d]", error);
goto FINISH_OFF;
}
@@ -763,7 +783,7 @@ INTERNAL_FUNC int emcore_get_current_session(email_session_t **session)
return true;
}
-INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_type, int priority_sender, int *total_mail, int *unread_mail, int *err_code)
+INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int account_id, int mailbox_type, int priority_sender, int *total_mail, int *unread_mail, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id : [%d], mailbox_type : [%d], priority_sender : [%d]", account_id, mailbox_type, priority_sender);
@@ -784,7 +804,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_typ
/* Get rule list */
if (priority_sender) {
- if (!emstorage_get_rule(ALL_ACCOUNT, type, 0, &rule_count, &is_completed, &rule, true, &err)) {
+ if (!emstorage_get_rule(multi_user_name, ALL_ACCOUNT, type, 0, &rule_count, &is_completed, &rule, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_rule failed");
goto FINISH_OFF;
}
@@ -892,8 +912,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_typ
filter_list[k++].list_filter_item.rule.key_value.integer_type_value = mailbox_type;
}
-
- if ((err = emstorage_write_conditional_clause_for_getting_mail_list(filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
@@ -901,7 +920,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_typ
EM_DEBUG_LOG_DEV ("conditional_clause_string[%s]", conditional_clause_string);
/* Search the mail of priority sender in DB */
- if ((err = emstorage_query_mail_count(conditional_clause_string, true, &total_count, &unread_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_query_mail_count(multi_user_name, conditional_clause_string, true, &total_count, &unread_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_count failed:[%d]", err);
goto FINISH_OFF;
}
@@ -930,13 +949,19 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_display_badge_count(int count)
+INTERNAL_FUNC int emcore_display_badge_count(char *multi_user_name, int count)
{
EM_DEBUG_FUNC_BEGIN();
/* Use badge API */
int err = EMAIL_ERROR_NONE;
badge_error_e badge_err = BADGE_ERROR_NONE;
bool exist;
+ void *join_zone = NULL;
+
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
if((badge_err = badge_is_existing("org.tizen.email", &exist)) != BADGE_ERROR_NONE) {
EM_DEBUG_EXCEPTION("badge_is_existing failed [%d]", badge_err);
@@ -971,6 +996,9 @@ INTERNAL_FUNC int emcore_display_badge_count(int count)
FINISH_OFF:
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_DEBUG_FUNC_END();
return err;
}
@@ -984,7 +1012,10 @@ void emcore_display_unread_in_badge(void *data)
int total_mail_count = 0;
int unseen = 0;
- if (!emcore_get_mail_count_by_query(ALL_ACCOUNT, EMAIL_MAILBOX_TYPE_INBOX, 0, &total_mail_count, &total_unread_count, &err)) {
+ if (!emcore_get_mail_count_by_query((char *)data, ALL_ACCOUNT,
+ EMAIL_MAILBOX_TYPE_INBOX, 0,
+ &total_mail_count, &total_unread_count,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_count_by_query failed");
goto FINISH_OFF;
}
@@ -994,11 +1025,11 @@ void emcore_display_unread_in_badge(void *data)
FINISH_OFF:
if (unseen <= 0) {
- if ((err = emcore_display_badge_count(0)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_display_badge_count((char *)data, 0)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_display_badge_count failed : [%d]", err);
}
} else {
- if ((err = emcore_display_badge_count(unseen)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_display_badge_count((char *)data, unseen)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_display_badge_count failed : [%d]", err);
}
}
@@ -1018,7 +1049,7 @@ static int emcore_layout_multi_noti(notification_h noti, int unread_mail, char *
goto FINISH_OFF;
}
- noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New email", dgettext(NATIVE_EMAIL_DOMAIN,"IDS_EMAIL_TPOP_NEW_EMAIL_RECEIVED_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New emails", dgettext(NATIVE_EMAIL_DOMAIN,"IDS_EMAIL_MBODY_NEW_EMAILS_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
if (noti_err != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_TITLE failed");
goto FINISH_OFF;
@@ -1156,7 +1187,9 @@ static int emcore_get_alert_type(int vibrate_status)
int email_vibe_status = 0;
int call_state = 0;
int alert_type = EMAIL_ALERT_TYPE_MUTE;
+#ifdef __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__
int voicerecoder_state = 0;
+#endif /* __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__ */
if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &global_sound_status) != 0) {
EM_DEBUG_LOG("vconf_get_bool for VCONFKEY_SETAPPL_SOUND_STATUS_BOOL failed");
@@ -1171,26 +1204,28 @@ static int emcore_get_alert_type(int vibrate_status)
EM_DEBUG_LOG("global_sound_status [%d] global_vibe_status [%d]", global_sound_status, global_vibe_status);
if (global_sound_status || global_vibe_status) {
-
+#ifdef __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__
if (vconf_get_int(VCONFKEY_VOICERECORDER_STATE, &voicerecoder_state) != 0) {
EM_DEBUG_LOG("vconf_get_int for VCONFKEY_VOICERECORDER_STATE failed");
}
EM_DEBUG_LOG("voicerecoder_state [%d]", voicerecoder_state);
+#endif /* __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__ */
- if (vconf_get_int(VCONFKEY_CALL_STATE, &call_state) != 0) {
- EM_DEBUG_LOG("vconf_get_int for VCONFKEY_CALL_STATE failed");
- }
+ call_state = emcore_get_call_status();
EM_DEBUG_LOG("call_state [%d] ", call_state);
email_vibe_status = vibrate_status;
EM_DEBUG_LOG("email_vibe_status [%d] ", email_vibe_status);
-
+#ifdef __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__
if (voicerecoder_state == VCONFKEY_VOICERECORDER_RECORDING) {
alert_type = EMAIL_ALERT_TYPE_VIB;
EM_DEBUG_LOG("voice recorder is on recording...");
}
- else if (call_state > VCONFKEY_CALL_OFF && call_state < VCONFKEY_CALL_STATE_MAX) {
+/* else if (call_state > VCONFKEY_CALL_OFF && call_state < VCONFKEY_CALL_STATE_MAX) { */
+#endif /* __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__ */
+
+ if (call_state > VCONFKEY_CALL_OFF && call_state < VCONFKEY_CALL_STATE_MAX) {
EM_DEBUG_LOG("Calling");
if (global_sound_status)
alert_type = EMAIL_ALERT_TYPE_MELODY;
@@ -1209,11 +1244,12 @@ static int emcore_get_alert_type(int vibrate_status)
}
FINISH_OFF:
+
EM_DEBUG_FUNC_END("alert_type [%d]", alert_type);
return alert_type;
}
-static char * emcore_get_sound_file_path(int default_ringtone_status, char *alert_ringtone_path)
+static char *emcore_get_sound_file_path(int default_ringtone_status, char *alert_ringtone_path)
{
EM_DEBUG_FUNC_BEGIN();
char *ret = NULL;
@@ -1253,7 +1289,7 @@ INTERNAL_FUNC int emcore_show_toast_popup(char *input_popup_string)
goto FINISH_OFF;
}
- ret = app_control_set_app_id(svc_handle, "com.samsung.email-tts-play");
+ ret = app_control_set_app_id(svc_handle, "org.tizen.email-tts-play");
if (ret != APP_CONTROL_ERROR_NONE) {
EM_DEBUG_LOG("app_control_set_app_id() failed! ret:[%d]", ret);
err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -1296,7 +1332,7 @@ FINISH_OFF:
#endif
-INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display)
+INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d] mail_id[%d] unread_mail_count[%d] input_play_alert_tone[%d]", account_id, mail_id, unread_mail_count, input_play_alert_tone );
int err = EMAIL_ERROR_NONE;
@@ -1317,6 +1353,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
int display_status = false;
EMAIL_ALERT_TYPE alert_type = EMAIL_ALERT_TYPE_NONE;
char *alert_tone_path = NULL;
+ void *join_zone = NULL;
/* For service bundle */
char buf[256] = {0,};
@@ -1324,7 +1361,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
app_control_h service = NULL;
bundle *b = NULL;
- if (!emstorage_get_account_by_id(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1335,7 +1372,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
/* Get the unread mail id */
- if (!emstorage_get_unread_mailid(account_id, 0, &p_mail_id, &unread_mail_count_t, &err)) {
+ if (!emstorage_get_unread_mailid(multi_user_name, account_id, 0, &p_mail_id, &unread_mail_count_t, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_unread_mailid failed [%d]", err);
goto FINISH_OFF;
}
@@ -1352,6 +1389,11 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
/* Turn display on to blink LED */
// emdevice_change_display_state(DISPLAY_STATE_ON);
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
noti = notification_load(NULL, private_id);
if(noti == NULL) {
EM_DEBUG_EXCEPTION("notification_load failed");
@@ -1392,7 +1434,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
goto FINISH_OFF;
}
- if ( (alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_MELODY) && EM_SAFE_STRLEN(alert_tone_path)) {
+ if ((alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_MELODY) && EM_SAFE_STRLEN(alert_tone_path)) {
if(strcmp(alert_tone_path, "silent") == 0) {
if ((noti_err = notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL)) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_sound failed [%d]", noti_err);
@@ -1409,7 +1451,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
}
- if ( alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_VIB)
+ if (alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_VIB)
noti_vibe_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
if ((noti_err = notification_set_vibration(noti, noti_vibe_type, NULL)) != NOTIFICATION_ERROR_NONE) {
@@ -1418,13 +1460,13 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
goto FINISH_OFF;
}
- if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/com.samsung.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
+ if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text_domain failed [%d]", noti_err);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_name_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
+ if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
@@ -1438,7 +1480,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
if (unseen == 1) {
- if (!emstorage_get_mail_by_id(p_mail_id[0], &p_mail_data, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, p_mail_id[0], &p_mail_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1539,14 +1581,25 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
}
+#ifdef __FEATURE_DRIVING_MODE__
if (unseen) {
- err = emcore_start_driving_mode(p_mail_id[unseen - 1]);
+ err = emcore_start_driving_mode(multi_user_name, p_mail_id[unseen - 1]);
if (err != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_start_driving_mode failed : [%d]", err);
}
+#endif /* __FEATURE_DRIVING_MODE__ */
FINISH_OFF:
+ if (service)
+ app_control_destroy(service);
+
+ if (noti)
+ notification_free(noti);
+
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_SAFE_FREE(alert_tone_path);
EM_SAFE_FREE(p_mail_id); /* prevent */
@@ -1564,22 +1617,21 @@ FINISH_OFF:
EM_SAFE_FREE(mailbox_name);
- notification_free(noti);
-
- app_control_destroy(service);
#endif /* __FEATURE_NOTIFICATION_ENABLE__ */
EM_DEBUG_FUNC_END("ret [%d]", err);
return err;
}
-INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display)
+INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display)
{
EM_DEBUG_FUNC_BEGIN("account_id: %d, mail_id: %d, action:%d", account_id, mail_id, action );
int err = EMAIL_ERROR_NONE;
-#ifdef __FEATURE_NOTIFICATION_ENABLE__
+#ifdef __FEATURE_NOTIFICATION_ENABLE__
int private_id = 0;
+ void *join_zone = NULL;
char *mailbox_name = NULL;
+ char *dgettext_string = NULL;
char vconf_private_id[MAX_PATH] = {0, };
notification_h noti = NULL;
notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
@@ -1592,7 +1644,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
bundle *b = NULL;
/* get general noti status */
- if (!emstorage_get_account_by_id(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1608,19 +1660,24 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
}
/* Delete the previous noti */
- emcore_delete_notification_by_account(account_id, true);
+ emcore_delete_notification_by_account(multi_user_name, account_id, true);
if (g_sending_noti_handle) {
if((noti_err = notification_free(g_sending_noti_handle)) != NOTIFICATION_ERROR_NONE)
err = EMAIL_ERROR_NOTI;
g_sending_noti_handle = NULL;
}
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
if (action == EMAIL_ACTION_SENDING_MAIL)
noti = notification_create(NOTIFICATION_TYPE_ONGOING);
else
noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
- if(noti == NULL) {
+ if (noti == NULL) {
EM_DEBUG_EXCEPTION("notification_new failed");
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
@@ -1632,7 +1689,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
goto FINISH_OFF;
}
- if (!emstorage_get_mail_by_id(mail_id, &p_mail_data, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &p_mail_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1663,130 +1720,134 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
switch (action) {
case EMAIL_ACTION_SEND_MAIL :
-
+/*
setlocale(LC_MESSAGES, vconf_get_str(VCONFKEY_LANGSET));
bindtextdomain("sys_string", "/usr/share/locale");
textdomain("sys_string");
+*/
+ setlocale(LC_MESSAGES, vconf_get_str(VCONFKEY_LANGSET));
+ bindtextdomain(NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale");
+ textdomain(NATIVE_EMAIL_DOMAIN);
- if (sending_error == EMAIL_ERROR_NONE) {
- /*if ((noti_err = emcore_layout_single_noti(noti, account_tbl->account_name, 1, "IDS_COM_POP_SENT", p_mail_data->date_time, p_mail_data->subject)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_layout_single_noti failed [%d]", err);
- err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }*/
+ switch(sending_error) {
+ case EMAIL_ERROR_NONE:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_EMAIL_SENT");
+ break;
+ case EMAIL_ERROR_FLIGHT_MODE_ENABLE:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_FAILED_TO_CONNECT_TO_NETWORK");
+ break;
+ case EMAIL_ERROR_NETWORK_NOT_AVAILABLE:
+ case EMAIL_ERROR_NO_SIM_INSERTED:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_NETWORK_NOT_AVAILABLE_EMAIL_WILL_BE_SENT_WHEN_CONNECTED_TO_NETWORK");
+ break;
+ case EMAIL_ERROR_SERVER_STORAGE_FULL:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED_SERVER_STORAGE_FULL_ABB");
+ break;
+ default:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED");
+ break;
+ }
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_EMAIL_SENT"))) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
+ if ((noti_err = notification_set_layout(noti,
+ NOTIFICATION_LY_NOTI_EVENT_SINGLE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_layout failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- } else {
- /*if ((noti_err = emcore_layout_single_noti(noti, account_tbl->account_name, 1, "IDS_COM_POP_SENDING_FAILED", p_mail_data->date_time, p_mail_data->subject)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_layout_single_noti failed [%d]", err);
- err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }*/
-
- switch(sending_error) {
- case EMAIL_ERROR_FLIGHT_MODE_ENABLE:
- EM_DEBUG_LOG("Flight mode enable");
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_FAILED_TO_CONNECT_TO_NETWORK"))) != NOTIFICATION_ERROR_NONE)
- {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- break;
+ if ((noti_err = notification_set_image(noti,
+ NOTIFICATION_IMAGE_TYPE_ICON,
+ EMAIL_NOTI_ICON_PATH)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_image failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- case EMAIL_ERROR_NETWORK_NOT_AVAILABLE:
- case EMAIL_ERROR_NO_SIM_INSERTED:
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_NETWORK_NOT_AVAILABLE_EMAIL_WILL_BE_SENT_WHEN_CONNECTED_TO_NETWORK"))) != NOTIFICATION_ERROR_NONE)
- {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- break;
- default:
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED"))) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- }
- if ((noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_layout failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_TITLE,
+ p_mail_data->alias_recipient,
+ NULL,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- if ((noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, EMAIL_NOTI_ICON_PATH)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_image failed [%d]", noti_err);
+ switch (sending_error) {
+ case EMAIL_ERROR_NONE:
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_CONTENT,
+ "Email Sent",
+ dgettext_string,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
-
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Sending failed", dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED"), NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ break;
+ case EMAIL_ERROR_SERVER_STORAGE_FULL:
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_CONTENT,
+ "Sending failed. Server storage full.",
+ dgettext_string,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
-
- if (p_mail_data->subject) {
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, p_mail_data->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- } else {
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "No subject", NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- }
-
- if (sending_error == EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE) {
- setlocale(LC_MESSAGES, vconf_get_str(VCONFKEY_LANGSET));
- bindtextdomain(NATIVE_EMAIL_DOMAIN, "/usr/apps/com.samsung.email/res/locale");
- textdomain(NATIVE_EMAIL_DOMAIN);
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_POP_THE_EMAIL_IS_TOO_LARGE"), NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_INFO_1 failed");
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- }
-
- /*notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);*/
-
- if ((noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ break;
+ default:
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_CONTENT,
+ "Sending failed",
+ dgettext_string,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
+ break;
+ }
- if ((noti_err = notification_insert(noti, &private_id)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ if (sending_error == EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE) {
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_INFO_1,
+ dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_POP_THE_EMAIL_IS_TOO_LARGE"),
+ NULL,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_INFO_1 failed");
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
+ }
- EM_DEBUG_LOG("Private_id = [%d]", private_id);
+ if ((noti_err = notification_set_display_applist(noti,
+ NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
- if (vconf_set_int(vconf_private_id, private_id) != 0) {
- EM_DEBUG_EXCEPTION("vconf_set_int failed");
- err = EMAIL_ERROR_GCONF_FAILURE;
- goto FINISH_OFF;
- }
+ if ((noti_err = notification_insert(noti, &private_id)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("Private_id = [%d]", private_id);
+
+ SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
+ if (vconf_set_int(vconf_private_id, private_id) != 0) {
+ EM_DEBUG_EXCEPTION("vconf_set_int failed");
+ err = EMAIL_ERROR_GCONF_FAILURE;
+ goto FINISH_OFF;
}
break;
case EMAIL_ACTION_SENDING_MAIL :
- if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/com.samsung.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
+ if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text_domain failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
@@ -1834,8 +1895,8 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
EM_DEBUG_LOG("Private_id = [%d]", private_id);
SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
- if ((err = vconf_set_int (vconf_private_id, private_id)) != 0) {
- EM_DEBUG_EXCEPTION("vconf_set_int failed [%d]", err);
+ if (vconf_set_int (vconf_private_id, private_id) != 0) {
+ EM_DEBUG_EXCEPTION("vconf_set_int failed");
err = EMAIL_ERROR_GCONF_FAILURE;
goto FINISH_OFF;
}
@@ -1847,16 +1908,31 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
EM_DEBUG_EXCEPTION ("notification_free error [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
}
+
break;
}
FINISH_OFF:
+ if (service)
+ app_control_destroy(service);
+
if ((action == EMAIL_ACTION_SEND_MAIL) && noti) {
- if( (noti_err = notification_free(noti)) != NOTIFICATION_ERROR_NONE)
+ if ((noti_err = notification_free(noti)) != NOTIFICATION_ERROR_NONE) {
err = EMAIL_ERROR_NOTI;
+ }
}
+ if ((action != EMAIL_ACTION_SEND_MAIL) && (err != EMAIL_ERROR_NONE)) {
+ if (noti) {
+ notification_free(noti);
+ g_sending_noti_handle = NULL;
+ }
+ }
+
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
if (p_mail_data)
emstorage_free_mail(&p_mail_data, 1, NULL);
@@ -1865,7 +1941,6 @@ FINISH_OFF:
EM_SAFE_FREE(mailbox_name);
- app_control_destroy(service);
#endif /* __FEATURE_NOTIFICATION_ENABLE__ */
EM_DEBUG_FUNC_END("ret [%d]", err);
@@ -1894,7 +1969,7 @@ INTERNAL_FUNC void emcore_update_notification_for_send(int account_id, int mail_
EM_DEBUG_FUNC_END();
}
-INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int error)
+INTERNAL_FUNC int emcore_show_user_message(char *multi_user_name, int id, email_action_t action, int error)
{
EM_DEBUG_FUNC_BEGIN("id[%d], action[%d], error[%d]", id, action, error);
@@ -1910,13 +1985,13 @@ INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int er
return false;
}
- if (!emstorage_get_mail_by_id(id, &mail_table_data, true, NULL)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, id, &mail_table_data, true, NULL)) {
EM_DEBUG_LOG("Mail not found");
return false;
}
EM_DEBUG_LOG ("smtp_stream : sent_end");
- if (emcore_add_notification_for_send(mail_table_data->account_id, id, action, error, display) != EMAIL_ERROR_NONE) {
+ if (emcore_add_notification_for_send(multi_user_name, mail_table_data->account_id, id, action, error, display) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_notification_set error");
goto FINISH_OFF;
}
@@ -1939,8 +2014,8 @@ int emcore_get_storage_status(void)
EM_DEBUG_FUNC_BEGIN();
int storage_status = 0, nError = 0;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
#ifdef STORAGE_STATUS
@@ -1985,7 +2060,7 @@ FINISH_OFF:
return err;
}
-int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, int *output_size)
+int emcore_calc_mail_size(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, int *output_size)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count[%d], output_size[%p]", input_mail_data, input_attachment_data_list, input_attachment_count, output_size);
@@ -1993,6 +2068,8 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
int mail_size = 0; /* size of the plain text body and attachments */
int err = EMAIL_ERROR_NONE;
int i = 0;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) || (!input_attachment_count &&input_attachment_data_list) || !output_size) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -2000,8 +2077,21 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
goto FINISH_OFF;
}
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
if (input_mail_data->file_path_plain != NULL) {
- if (stat(input_mail_data->file_path_plain, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_plain);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_plain : stat(\"%s\") failed...", input_mail_data->file_path_plain);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF;
@@ -2012,7 +2102,10 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
}
if (input_mail_data->file_path_html != NULL) {
- if (stat(input_mail_data->file_path_html, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_html);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_html : stat(\"%s\") failed...", input_mail_data->file_path_html);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF;
@@ -2022,7 +2115,10 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
}
for(i = 0; i < input_attachment_count; i++) {
- if (stat(input_attachment_data_list[i].attachment_path, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_attachment_data_list[i].attachment_path);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_attachment_data_list[i].attachment_path);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF;
@@ -2034,6 +2130,8 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
FINISH_OFF:
+ EM_SAFE_FREE(prefix_path);
+
EM_DEBUG_FUNC_END("mail_size [%d]", mail_size);
return err;
}
@@ -2050,8 +2148,9 @@ char *emcore_get_alias_of_mailbox(const char *mailbox_path)
gchar *mailbox = NULL, *name = NULL;
char *converted_name;
+
mailbox = g_strdup(mailbox_path);
- token_list = g_strsplit_set(mailbox, "/", -1);
+ token_list = g_strsplit_set(mailbox, "/\\", -1);
if(token_list == NULL) {
EM_DEBUG_LOG("g_strsplit_set failed.");
@@ -2139,7 +2238,7 @@ FINISH_OFF:
return err;
}
-void emcore_fill_address_information_of_mail_tbl(emstorage_mail_tbl_t *mail_data)
+void emcore_fill_address_information_of_mail_tbl(char *multi_user_name, emstorage_mail_tbl_t *mail_data)
{
EM_DEBUG_FUNC_BEGIN("mail_data [%p]", mail_data);
@@ -2154,7 +2253,7 @@ void emcore_fill_address_information_of_mail_tbl(emstorage_mail_tbl_t *mail_data
email_account_t *ref_account = NULL;
- ref_account = emcore_get_account_reference(mail_data->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, mail_data->account_id, false);
if (!ref_account) {
EM_DEBUG_LOG("emcore_get_account_reference failed [%d]", mail_data->account_id);
}
@@ -2346,7 +2445,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_BODY_SEARCH__
-int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped_text, int *err_code)
+int emcore_strip_mail_body_from_file(char *multi_user_name, emstorage_mail_tbl_t *mail, char **stripped_text, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail[%p]", mail);
@@ -2355,8 +2454,11 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
char *buf = NULL;
char *encoding_type = NULL;
char *utf8_encoded_string = NULL;
- unsigned int byte_read = 0;
- unsigned int byte_written = 0;
+ char *prefix_path = NULL;
+ char real_html_path[255] = {0};
+ char real_plain_path[255] = {0};
+ gsize byte_read = 0;
+ gsize byte_written = 0;
GError *glib_error = NULL;
FILE *fp_plain = NULL;
struct stat st_buf;
@@ -2367,23 +2469,34 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
goto FINISH_OFF;
}
- /* MAX_PREVIEW_TEXT_LENGTH */
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
/* read file to buf & strip if html text */
if (mail->file_path_html) {
char result_buffer[MAX_PREVIEW_TEXT_LENGTH] = { 0, };
+
if (mail->preview_text) {
*stripped_text = EM_SAFE_STRDUP(mail->preview_text);
ret = true;
goto FINISH_OFF;
}
+ SNPRINTF(real_html_path, sizeof(real_html_path), "%s%s", prefix_path, mail->file_path_html);
+
if ((err = em_get_encoding_type_from_file_path(mail->file_path_plain, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
goto FINISH_OFF;
}
- if ((err = emcore_strip_HTML_tag(mail->file_path_html, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_strip_HTML_tag(real_html_path, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_strip_HTML_tag failed");
goto FINISH_OFF;
}
@@ -2392,21 +2505,23 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
}
if (!buf && mail->file_path_plain) {
+ SNPRINTF(real_plain_path, sizeof(real_plain_path), "%s%s", prefix_path, mail->file_path_plain);
+
if ((err = em_get_encoding_type_from_file_path(mail->file_path_plain, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
goto FINISH_OFF;
}
memset(&st_buf, 0, sizeof(struct stat));
- if (stat(mail->file_path_plain, &st_buf) < 0) {
- EM_DEBUG_EXCEPTION_SEC("stat(\"%s\") failed...", mail->file_path_plain);
+ if (stat(real_plain_path, &st_buf) < 0) {
+ EM_DEBUG_EXCEPTION_SEC("stat(\"%s\") failed...", real_plain_path);
err = EMAIL_ERROR_INVALID_MAIL;
goto FINISH_OFF;
}
- err = em_fopen(mail->file_path_plain, "r", &fp_plain);
+ err = em_fopen(real_plain_path, "r", &fp_plain);
if (err != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION_SEC("em_fopen failed [%s]", mail->file_path_plain);
+ EM_DEBUG_EXCEPTION_SEC("em_fopen failed [%s]", real_plain_path);
goto FINISH_OFF;
}
@@ -2427,7 +2542,7 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
EM_SAFE_FREE(buf);
err = EMAIL_ERROR_NULL_VALUE;
if (ferror(fp_plain)) {
- EM_DEBUG_EXCEPTION_SEC("fread failed [%s]", mail->file_path_plain);
+ EM_DEBUG_EXCEPTION_SEC("fread failed [%s]", real_plain_path);
err = EMAIL_ERROR_SYSTEM_FAILURE;
}
goto FINISH_OFF;
@@ -2453,19 +2568,22 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
if(utf8_encoded_string == NULL) {
if (!g_error_matches(glib_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) {
+ EM_SAFE_FREE(*stripped_text);
*stripped_text = EM_SAFE_STRDUP(buf);
goto FINISH_OFF;
}
EM_DEBUG_LOG("Extract the preview text, again");
- utf8_encoded_string = (char *)g_convert(buf, byte_read, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
+ utf8_encoded_string = (char *)g_convert(buf, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
if (utf8_encoded_string == NULL) {
+ EM_SAFE_FREE(*stripped_text);
*stripped_text = EM_SAFE_STRDUP(buf);
goto FINISH_OFF;
}
}
EM_SAFE_FREE(buf);
+ EM_SAFE_FREE(*stripped_text);
*stripped_text = EM_SAFE_STRDUP(utf8_encoded_string);
} else {
EM_SAFE_FREE(*stripped_text);
@@ -2481,6 +2599,7 @@ FINISH_OFF:
*err_code = err;
EM_SAFE_FREE(buf);
+ EM_SAFE_FREE(prefix_path);
EM_SAFE_FREE(encoding_type);
EM_SAFE_FREE(utf8_encoded_string);
@@ -2493,13 +2612,13 @@ FINISH_OFF:
#endif
-int emcore_get_preview_text_from_file(const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer)
+int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer)
{
EM_DEBUG_FUNC_BEGIN("input_plain_path[%p], input_html_path[%p], input_preview_buffer_length [%d], output_preview_buffer[%p]", input_plain_path, input_html_path, input_preview_buffer_length, output_preview_buffer);
int err = EMAIL_ERROR_NONE;
- unsigned int byte_read = 0;
- unsigned int byte_written = 0;
+ gsize byte_read = 0;
+ gsize byte_written = 0;
int local_preview_buffer_length = 0;
char *local_preview_text = NULL;
char *encoding_type = NULL;
@@ -2507,6 +2626,8 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
FILE *fp_plain = NULL;
GError *glib_error = NULL;
struct stat st_buf;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
if (!output_preview_buffer) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -2516,23 +2637,40 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
local_preview_buffer_length = input_preview_buffer_length * 2;
- if ( input_html_path ) { /*prevent 26249*/
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
+ if (input_html_path) { /*prevent 26249*/
/* get preview text from html file */
char result_buffer[MAX_PREVIEW_TEXT_LENGTH] = { 0, };
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_html_path);
+
if( (err = em_get_encoding_type_from_file_path(input_html_path, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
goto FINISH_OFF;
}
- if ((err = emcore_strip_HTML_tag(input_html_path, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_strip_HTML_tag(real_file_path, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_strip_HTML_tag failed");
goto FINISH_OFF;
}
local_preview_text = EM_SAFE_STRDUP(result_buffer);
}
- if ( !local_preview_text && input_plain_path) { /*prevent 26249*/
+ if (!local_preview_text && input_plain_path) { /*prevent 26249*/
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_plain_path);
+
/* get preview text from plain text file */
if( (err = em_get_encoding_type_from_file_path(input_plain_path, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
@@ -2540,13 +2678,13 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
}
memset(&st_buf, 0, sizeof(struct stat));
- if (stat(input_plain_path, &st_buf) < 0) {
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_plain_path);
err = EMAIL_ERROR_INVALID_MAIL;
goto FINISH_OFF;
}
- err = em_fopen(input_plain_path, "r", &fp_plain);
+ err = em_fopen(real_file_path, "r", &fp_plain);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_fopen failed [%s]", input_plain_path);
goto FINISH_OFF;
@@ -2590,7 +2728,7 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
encoding_type = EM_SAFE_STRDUP("EUC-KR");
}
- utf8_encoded_string = (char*)g_convert (local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
+ utf8_encoded_string = (char *)g_convert(local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
if(utf8_encoded_string == NULL) {
if (!g_error_matches (glib_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) {
@@ -2598,7 +2736,7 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
}
EM_DEBUG_LOG("Extract the preview text, again");
- utf8_encoded_string = (char *)g_convert(local_preview_text, byte_read, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
+ utf8_encoded_string = (char *)g_convert(local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
if (utf8_encoded_string == NULL) {
EM_DEBUG_LOG("g_convert fail, again");
goto FINISH_OFF;
@@ -2621,6 +2759,7 @@ FINISH_OFF:
EM_SAFE_FREE(local_preview_text);
EM_SAFE_FREE(encoding_type);
+ EM_SAFE_FREE(prefix_path);
if (fp_plain != NULL)
fclose(fp_plain);
@@ -2816,41 +2955,46 @@ FINISH_OFF:
}
-INTERNAL_FUNC int reg_replace_new (char **input_source_text, char *input_old_pattern_string, char *input_new_string)
+INTERNAL_FUNC char *reg_replace_new(char *input_source_text, char *input_old_pattern_string, char *input_new_string)
{
char *replaced_str = NULL;
- int error_code = EMAIL_ERROR_NONE;
GRegex *regex = NULL;
GError *error = NULL;
- if (input_source_text == NULL || *input_source_text == NULL) {
- return EMAIL_ERROR_INVALID_PARAM;
+ if (input_source_text == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return NULL;
}
regex = g_regex_new(input_old_pattern_string, G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &error);
-
if (!regex) {
EM_DEBUG_LOG("g_regex_new failed");
- error_code = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- replaced_str = g_regex_replace_literal(regex, *input_source_text, EM_SAFE_STRLEN(*input_source_text), 0, input_new_string, 0, &error);
-
- EM_SAFE_FREE(*input_source_text);
-
- *input_source_text = replaced_str;
+ replaced_str = g_regex_replace_literal(regex,
+ input_source_text,
+ strlen(input_source_text),
+ 0,
+ input_new_string,
+ 0,
+ &error);
+ if (replaced_str == NULL) {
+ EM_DEBUG_EXCEPTION("g_regex_replace_literal failed : [%s][%d]", error->message, error->code);
+ goto FINISH_OFF;
+ }
FINISH_OFF:
+
+ if (regex) g_regex_unref(regex);
- g_regex_unref(regex);
- return error_code;
+ return replaced_str;
}
#include <libxml/HTMLparser.h>
-static void emcore_get_content_string(xmlNode *input_node, char *input_result_buffer, int input_result_buffer_legnth, int *input_exit_flag)
+static void emcore_get_content_string(xmlNode *input_node, char *input_result_buffer, int input_result_buffer_length, int *input_exit_flag)
{
xmlNode *cur_node = NULL;
char *temp_content_string = NULL;
@@ -2864,41 +3008,60 @@ static void emcore_get_content_string(xmlNode *input_node, char *input_result_bu
if (cur_node->name && (strcasecmp((const char *)cur_node->name, "head") == 0 || strcasecmp((const char *)cur_node->name, "title") == 0))
continue;
+ if (cur_node->name && (strcasecmp((const char *)cur_node->name, "BR") == 0)) {
+ if (EM_SAFE_STRLEN(input_result_buffer) + 1 >= input_result_buffer_length) {
+ *input_exit_flag = 1;
+ break;
+ } else {
+ EM_SAFE_STRCAT(input_result_buffer, " ");
+ continue;
+ }
+ }
+
if (cur_node->type == XML_TEXT_NODE && cur_node->content) {
- if ((EM_SAFE_STRLEN(cur_node->content) + EM_SAFE_STRLEN(input_result_buffer)) >= input_result_buffer_legnth) {
+ if ((EM_SAFE_STRLEN(cur_node->content) + EM_SAFE_STRLEN(input_result_buffer)) >= input_result_buffer_length) {
int len1 = EM_SAFE_STRLEN(input_result_buffer);
- if (len1 >= 0 && len1 < input_result_buffer_legnth) {
- int remain_size = input_result_buffer_legnth - len1 - 2;
- char *remain_str = em_malloc(remain_size);
- if (remain_str && cur_node->content) {
- snprintf(remain_str, remain_size, "%s", (char*)(cur_node->content));
- }
+ if (len1 >= 0 && len1 < input_result_buffer_length) {
+ int remain_size = input_result_buffer_length - len1 - 2;
+ EM_DEBUG_LOG("remain_size : [%d], len1 : [%d]", remain_size, len1);
+ char *remain_str = NULL;
- if (remain_str)
- EM_SAFE_STRCAT(input_result_buffer, remain_str);
+ if (remain_size > 0)
+ remain_str = g_strndup((char *)(cur_node->content), remain_size);
- EM_SAFE_FREE(remain_str);
+ if (remain_str) {
+ char *replaced_string = NULL;
+ replaced_string = reg_replace_new(remain_str, "[ \t\r\n\v\f]+", " ");
+ EM_SAFE_STRCAT(input_result_buffer, replaced_string);
+ EM_SAFE_FREE(replaced_string);
+ free(remain_str);
+ }
}
*input_exit_flag = 1;
break;
}
+
temp_content_string = EM_SAFE_STRDUP((const char *)cur_node->content);
if (temp_content_string) {
- reg_replace_new(&temp_content_string, "[ \t\r\n\v\f]+", " ");
- EM_SAFE_STRCAT(input_result_buffer, temp_content_string);
- EM_SAFE_FREE(temp_content_string);
+ char *replaced_string = NULL;
+ replaced_string = reg_replace_new(temp_content_string, "[ \t\r\n\v\f]+", " ");
+ EM_SAFE_STRCAT(input_result_buffer, replaced_string);
+ EM_SAFE_FREE(replaced_string);
+ free(temp_content_string);
}
}
if (cur_node->children)
- emcore_get_content_string(cur_node->children, input_result_buffer, input_result_buffer_legnth, input_exit_flag);
+ emcore_get_content_string(cur_node->children, input_result_buffer, input_result_buffer_length, input_exit_flag);
if (*input_exit_flag == 1)
break;
}
+
FINISH_OFF:
+
return;
}
@@ -2925,7 +3088,6 @@ int emcore_strip_HTML_tag(const char *input_html_file_path, char *input_encoding
}
result_string = em_malloc(sizeof(char) * input_result_buffer_legnth);
-
if (result_string == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -2954,11 +3116,11 @@ int emcore_strip_HTML_tag(const char *input_html_file_path, char *input_encoding
root_element = xmlDocGetRootElement(result_html_document);
-
emcore_get_content_string(root_element, result_string, input_result_buffer_legnth, &exit_flag);
- reg_replace_new(&result_string, "[ \t\r\n\v\f]+", " ");
- EM_SAFE_STRCPY(output_result_buffer, result_string);
- // em_trim_left(output_result_buffer);
+ char *replaced_string = reg_replace_new(result_string, "[ \t\r\n\v\f]+", " ");
+ EM_SAFE_STRCPY(output_result_buffer, replaced_string);
+ EM_SAFE_FREE(replaced_string);
+ em_trim_left(output_result_buffer);
FINISH_OFF:
if (result_html_document) {
@@ -3035,10 +3197,9 @@ int convert_app_err_to_email_err(int app_error)
return err;
}
-INTERNAL_FUNC int emcore_start_driving_mode(int mail_id)
+INTERNAL_FUNC int emcore_start_driving_mode(char *multi_user_name, int mail_id)
{
EM_DEBUG_FUNC_BEGIN();
-
int err = APP_CONTROL_ERROR_NONE;
int tts_enable = 0;
char string_mail[10] = { 0 };
@@ -3066,7 +3227,7 @@ INTERNAL_FUNC int emcore_start_driving_mode(int mail_id)
if (!tts_enable)
goto FINISH_OFF;
- if (!emstorage_get_mail_by_id(mail_id, &p_mail_data, false, NULL)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &p_mail_data, false, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed");
goto FINISH_OFF;
}
@@ -3113,30 +3274,30 @@ FINISH_OFF:
}
#endif /* __FEATURE_DRIVING_MODE__ */
-INTERNAL_FUNC int emcore_clear_notifications(int account_id)
+INTERNAL_FUNC int emcore_clear_notifications(char *multi_user_name, int account_id)
{
int account_count = 0, i;
emstorage_account_tbl_t *account_list;
int error_code = EMAIL_ERROR_NONE;
if (account_id == ALL_ACCOUNT) {
- if(!emstorage_get_account_list(&account_count, &account_list, true, false, &error_code)) {
+ if(!emstorage_get_account_list(multi_user_name, &account_count, &account_list, true, false, &error_code)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed");
goto FINISH_OFF;
}
for(i = 0; i < account_count; i++) {
- error_code = emcore_delete_notification_by_account(account_list[i].account_id, true);
+ error_code = emcore_delete_notification_by_account(multi_user_name, account_list[i].account_id, true);
if (error_code != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
}
} else {
- error_code = emcore_delete_notification_by_account(account_id, true);
+ error_code = emcore_delete_notification_by_account(multi_user_name, account_id, true);
if (error_code != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
}
- if (!emstorage_update_save_status(account_id, &error_code)) {
+ if (!emstorage_update_save_status(multi_user_name, account_id, &error_code)) {
EM_DEBUG_EXCEPTION("emstorage_update_save_status failed : [%d]", error_code);
goto FINISH_OFF;
}
@@ -3153,7 +3314,7 @@ FINISH_OFF:
#define EAS_EXECUTABLE_PATH "/usr/bin/eas-engine"
-INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id, int with_noti_tray)
+INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int with_noti_tray)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id);
int error_code = EMAIL_ERROR_NONE;
@@ -3950,7 +4111,7 @@ static int emcore_get_next_peak_start_time(emstorage_account_tbl_t *input_accoun
if (time_info == NULL) {
EM_DEBUG_EXCEPTION("localtime failed");
err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
+ goto FINISH_OFF;
}
EM_DEBUG_LOG("input time and date: %s", asctime(time_info));
@@ -4024,7 +4185,7 @@ static int emcore_check_time_in_peak_schedule(emstorage_account_tbl_t *input_acc
if (time_info == NULL) {
EM_DEBUG_EXCEPTION("localtime failed");
err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
+ goto FINISH_OFF;
}
EM_DEBUG_LOG("input time and date: %s", asctime(time_info));
@@ -4061,7 +4222,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_calc_next_time_to_sync(int input_account_id, time_t input_current_time, time_t *output_time)
+INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input_account_id, time_t input_current_time, time_t *output_time)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d] input_current_time[%d] output_time[%p]", input_account_id, input_current_time, output_time);
int err = EMAIL_ERROR_NONE;
@@ -4071,7 +4232,7 @@ INTERNAL_FUNC int emcore_calc_next_time_to_sync(int input_account_id, time_t inp
time_t result_time = 0;
int is_time_in_peak_schedule = 0;
- emstorage_get_account_by_id(input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account, true, &err);
+ emstorage_get_account_by_id(multi_user_name, input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account, true, &err);
if (account == NULL) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]",err);
goto FINISH_OFF;
@@ -4171,14 +4332,14 @@ static int convert_contact_err_to_email_err(int contact_err)
return err;
}
-int emcore_get_mail_contact_info(email_mail_contact_info_t *contact_info, char *full_address, int *err_code)
+int emcore_get_mail_contact_info(char *multi_user_name, email_mail_contact_info_t *contact_info, char *full_address, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("contact_info[%p], full_address[%s], err_code[%p]", contact_info, full_address, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
- if (!emcore_get_mail_contact_info_with_update(contact_info, full_address, 0, &err))
+ if (!emcore_get_mail_contact_info_with_update(multi_user_name, contact_info, full_address, 0, &err))
EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info_with_update failed [%d]", err);
else
ret = true;
@@ -4189,7 +4350,7 @@ int emcore_get_mail_contact_info(email_mail_contact_info_t *contact_info, char *
return ret;
}
-int emcore_search_contact_info(const char *contact_uri, int address_property_id, char *address, int favorite_property_id, bool is_favorite, int limit, contacts_record_h *contacts_record)
+int emcore_search_contact_info(char *multi_user_name, const char *contact_uri, int address_property_id, char *address, int favorite_property_id, bool is_favorite, int limit, contacts_record_h *contacts_record)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = CONTACTS_ERROR_NONE;
@@ -4198,6 +4359,15 @@ int emcore_search_contact_info(const char *contact_uri, int address_property_id,
contacts_filter_h filter = NULL;
contacts_list_h list = NULL;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if (emcore_set_join_zone(multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ goto FINISH_OFF;
+ }
+ }
+
if ((contact_err = contacts_query_create(contact_uri, &query)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_query_create failed");
goto FINISH_OFF;
@@ -4249,10 +4419,13 @@ FINISH_OFF:
if (list != NULL)
contacts_list_destroy(list, false);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
return contact_err;
}
-int emcore_search_contact_info_by_address(const char *contact_uri, int property_id, char *address, int limit, contacts_record_h *contacts_record)
+int emcore_search_contact_info_by_address(char *multi_user_name, const char *contact_uri, int property_id, char *address, int limit, contacts_record_h *contacts_record)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = CONTACTS_ERROR_NONE;
@@ -4261,6 +4434,15 @@ int emcore_search_contact_info_by_address(const char *contact_uri, int property_
contacts_filter_h filter = NULL;
contacts_list_h list = NULL;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if (emcore_set_join_zone(multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ goto FINISH_OFF;
+ }
+ }
+
if ((contact_err = contacts_query_create(contact_uri, &query)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_query_create failed");
goto FINISH_OFF;
@@ -4303,6 +4485,9 @@ FINISH_OFF:
if (list != NULL)
contacts_list_destroy(list, false);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
return contact_err;
}
@@ -4310,6 +4495,7 @@ typedef struct {
int account_id;
char *email_address;
char *subject;
+ char *multi_user_name;
time_t date_time;
email_action_t action;
} set_contacts_log_internal_t;
@@ -4326,6 +4512,7 @@ gboolean emcore_set_contacts_log_internal (void* arg)
char *subject = tmp->subject;
time_t date_time = tmp->date_time;
email_action_t action = tmp->action;
+ char *multi_user_name = tmp->multi_user_name;
int contacts_error = CONTACTS_ERROR_NONE;
int person_id = 0;
@@ -4334,12 +4521,15 @@ gboolean emcore_set_contacts_log_internal (void* arg)
contacts_record_h phone_record = NULL;
contacts_record_h person_record = NULL;
-/*
- if ((contacts_error = contacts_connect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- goto FINISH_OFF;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if (emcore_set_join_zone(multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ goto FINISH_OFF;
+ }
}
-*/
+
if ((contacts_error = contacts_record_create(_contacts_phone_log._uri, &phone_record)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_query_create failed [%d]", contacts_error);
goto FINISH_OFF;
@@ -4352,7 +4542,7 @@ gboolean emcore_set_contacts_log_internal (void* arg)
}
/* Search contact person info */
- if ((contacts_error = emcore_search_contact_info_by_address(_contacts_person_email._uri, _contacts_person_email.email, email_address, 1, &person_record)) != CONTACTS_ERROR_NONE) {
+ if ((contacts_error = emcore_search_contact_info_by_address(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, email_address, 1, &person_record)) != CONTACTS_ERROR_NONE) {
if (contacts_error != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contacts_error);
} else {
@@ -4419,12 +4609,9 @@ FINISH_OFF:
if (person_record != NULL)
contacts_record_destroy(person_record, false);
-/*
- if ((contacts_error = contacts_disconnect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- err = convert_contact_err_to_email_err(contacts_error);
- }
-*/
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_SAFE_FREE (email_address);
EM_SAFE_FREE (subject);
EM_SAFE_FREE (tmp);
@@ -4433,11 +4620,12 @@ FINISH_OFF:
return FALSE;
}
-int emcore_set_contacts_log (int account_id,
- char *email_address,
- char *subject,
- time_t date_time,
- email_action_t action)
+int emcore_set_contacts_log (char *multi_user_name,
+ int account_id,
+ char *email_address,
+ char *subject,
+ time_t date_time,
+ email_action_t action)
{
/* arg shall be destroyed in emcore_set_contacts_log_internal */
set_contacts_log_internal_t *arg = em_malloc (sizeof(set_contacts_log_internal_t));
@@ -4447,18 +4635,19 @@ int emcore_set_contacts_log (int account_id,
}
/* deep copy */
- arg->account_id = account_id;
- arg->email_address = EM_SAFE_STRDUP (email_address);
- arg->subject = EM_SAFE_STRDUP (subject);
- arg->date_time = date_time;
- arg->action = action;
+ arg->account_id = account_id;
+ arg->email_address = EM_SAFE_STRDUP (email_address);
+ arg->subject = EM_SAFE_STRDUP (subject);
+ arg->date_time = date_time;
+ arg->action = action;
+ arg->multi_user_name = EM_SAFE_STRDUP (multi_user_name);
g_main_context_invoke (NULL, emcore_set_contacts_log_internal, arg);
return EMAIL_ERROR_NONE;
}
-INTERNAL_FUNC int emcore_set_sent_contacts_log(emstorage_mail_tbl_t *input_mail_data)
+INTERNAL_FUNC int emcore_set_sent_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p]", input_mail_data);
@@ -4474,7 +4663,12 @@ INTERNAL_FUNC int emcore_set_sent_contacts_log(emstorage_mail_tbl_t *input_mail_
rfc822_parse_adrlist(&addr, address_array[i], NULL);
for (p_addr = addr ; p_addr ;p_addr = p_addr->next) {
SNPRINTF(email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", addr->mailbox, addr->host);
- if ((err = emcore_set_contacts_log(input_mail_data->account_id, email_address, input_mail_data->subject, input_mail_data->date_time, EMAIL_ACTION_SEND_MAIL)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_set_contacts_log(multi_user_name,
+ input_mail_data->account_id,
+ email_address,
+ input_mail_data->subject,
+ input_mail_data->date_time,
+ EMAIL_ACTION_SEND_MAIL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_contacts_log failed : [%d]", err);
goto FINISH_OFF;
}
@@ -4497,12 +4691,17 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_set_received_contacts_log(emstorage_mail_tbl_t *input_mail_data)
+INTERNAL_FUNC int emcore_set_received_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p]", input_mail_data);
int err = EMAIL_ERROR_NONE;
- if ((err = emcore_set_contacts_log(input_mail_data->account_id, input_mail_data->email_address_sender, input_mail_data->subject, input_mail_data->date_time, EMAIL_ACTION_SYNC_HEADER)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_set_contacts_log(multi_user_name,
+ input_mail_data->account_id,
+ input_mail_data->email_address_sender,
+ input_mail_data->subject,
+ input_mail_data->date_time,
+ EMAIL_ACTION_SYNC_HEADER)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_contacts_log failed [%d]", err);
}
@@ -4510,45 +4709,63 @@ INTERNAL_FUNC int emcore_set_received_contacts_log(emstorage_mail_tbl_t *input_m
return err;
}
+typedef struct _contacts_delete_data
+{
+ int account_id;
+ char *multi_user_name;
+} contacts_delete_data;
+
gboolean emcore_delete_contacts_log_internal(void* arg)
{
EM_DEBUG_FUNC_BEGIN();
-
- int account_id = (int) arg; /* it is not a pointer */
+ contacts_delete_data *data = (contacts_delete_data *)arg;
int contacts_error = CONTACTS_ERROR_NONE;
-/*
- if ((contacts_error = contacts_connect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- goto FINISH_OFF;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(data->multi_user_name) > 0) {
+ if (emcore_set_join_zone(data->multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ return FALSE;
+ }
}
-*/
+
/* Delete record of the account id */
- if ((contacts_error = contacts_phone_log_delete(CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1, account_id)) != CONTACTS_ERROR_NONE) {
+ if ((contacts_error = contacts_phone_log_delete(CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1, data->account_id)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_phone_log_delete failed [%d]", contacts_error);
}
-
/* err = convert_contact_err_to_email_err(contacts_error); */
-/*
- if ((contacts_error = contacts_disconnect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- err = convert_contact_err_to_email_err(contacts_error);
- }
-*/
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
+ EM_SAFE_FREE(data->multi_user_name);
+ EM_SAFE_FREE(data);
+
EM_DEBUG_FUNC_END();
return FALSE;
}
-INTERNAL_FUNC int emcore_delete_contacts_log(int account_id)
+INTERNAL_FUNC int emcore_delete_contacts_log(char *multi_user_name, int account_id)
{
- g_main_context_invoke (NULL, emcore_delete_contacts_log_internal, (void*) account_id);
+ contacts_delete_data *data = NULL;
+
+ data = (contacts_delete_data *)em_malloc(sizeof(contacts_delete_data));
+ if (data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ return EMAIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ data->account_id = account_id;
+ data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
+ g_main_context_invoke (NULL, emcore_delete_contacts_log_internal, (void*) data);
return EMAIL_ERROR_NONE;
}
-INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **contact_display_name)
+INTERNAL_FUNC int emcore_get_mail_display_name (char *multi_user_name, char *email_address, char **contact_display_name)
{
if (!email_address || !contact_display_name) {
EM_DEBUG_EXCEPTION ("NULL_PARAM email_address[%p] contact_display_name[%p]",
@@ -4560,8 +4777,8 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **cont
GVariant *result = NULL;
int ret = EMAIL_ERROR_NONE;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
@@ -4581,7 +4798,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **cont
result = g_dbus_proxy_call_sync (bproxy,
"GetDisplayName",
- g_variant_new ("(s)", email_address),
+ g_variant_new ("(ss)", email_address, multi_user_name),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
@@ -4589,7 +4806,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **cont
if (!result) {
- EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'SetContactsLog' error [%s]",
+ EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'GetDisplayName' error [%s]",
gerror->message);
ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
@@ -4614,8 +4831,9 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *email_address,
- char **contact_display_name)
+INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *multi_user_name,
+ char *email_address,
+ char **contact_display_name)
{
EM_DEBUG_FUNC_BEGIN_SEC("contact_name_value[%s], contact_display_name[%p]", email_address, contact_display_name);
@@ -4632,7 +4850,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *email_address,
goto FINISH_OFF;
}
*/
- if ((contact_err = emcore_search_contact_info_by_address(_contacts_contact_email._uri, _contacts_contact_email.email, email_address, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_err = emcore_search_contact_info_by_address(multi_user_name, _contacts_contact_email._uri, _contacts_contact_email.email, email_address, 1, &record)) != CONTACTS_ERROR_NONE) {
if (contact_err != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contact_err);
goto FINISH_OFF;
@@ -4680,34 +4898,58 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_connect_contacts_service()
+INTERNAL_FUNC int emcore_connect_contacts_service(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = 0;
int err = EMAIL_ERROR_NONE;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ return err;
+ }
+ }
+
if ((contact_err = contacts_connect()) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_connect failed : [%d]", contact_err);
}
err = convert_contact_err_to_email_err(contact_err);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_DEBUG_FUNC_END();
return err;
}
-INTERNAL_FUNC int emcore_disconnect_contacts_service()
+INTERNAL_FUNC int emcore_disconnect_contacts_service(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = 0;
int err = EMAIL_ERROR_NONE;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ return err;
+ }
+ }
+
if ((contact_err = contacts_disconnect()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("contacts_connect failed : [%d]", contact_err);
+ EM_DEBUG_EXCEPTION("contacts_disconnect failed : [%d]", contact_err);
}
err = convert_contact_err_to_email_err(contact_err);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_DEBUG_FUNC_END();
return err;
}
@@ -4740,7 +4982,7 @@ INTERNAL_FUNC void emcore_set_blocking_mode_status(int blocking_mode)
blocking_mode_status = blocking_mode;
}
-INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blocking_status)
+INTERNAL_FUNC int emcore_check_blocking_mode (char *multi_user_name, char *sender_address, int *blocking_status)
{
if ( !sender_address || !blocking_status ) {
EM_DEBUG_EXCEPTION ("NULL_PARAM sender_address[%p] blocking_status[%p]",
@@ -4748,12 +4990,13 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blockin
return EMAIL_ERROR_INVALID_PARAM;
}
+
GError *gerror = NULL;
GVariant *result = NULL;
int ret = EMAIL_ERROR_NONE;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
@@ -4773,7 +5016,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blockin
result = g_dbus_proxy_call_sync (bproxy,
"CheckBlockingMode",
- g_variant_new ("(s)", sender_address),
+ g_variant_new ("(ss)", sender_address, multi_user_name),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
@@ -4781,7 +5024,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blockin
if (!result) {
- EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'SetContactsLog' error [%s]",
+ EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'CheckBlockingMode' error [%s]",
gerror->message);
ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
@@ -4800,7 +5043,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int *blocking_status)
+INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, char *sender_address, int *blocking_status)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
@@ -4813,7 +5056,6 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
contacts_record_h record = NULL;
if (!blocking_mode_of_setting) {
-
return err;
}
@@ -4837,7 +5079,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
case ALLOWED_CONTACT_TYPE_ALL :
EM_DEBUG_LOG("allowed_contact_type is ALL");
/* Search the allowed contact type in contact DB */
- if ((contact_error = emcore_search_contact_info_by_address(_contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_error = emcore_search_contact_info_by_address(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
if (contact_error != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contact_error);
goto FINISH_OFF;
@@ -4852,7 +5094,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
break;
case ALLOWED_CONTACT_TYPE_FAVORITES :
- if ((contact_error = emcore_search_contact_info(_contacts_person_email._uri, _contacts_person_email.email, sender_address, _contacts_person_email.is_favorite, true, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_error = emcore_search_contact_info(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, _contacts_person_email.is_favorite, true, 1, &record)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_search_contact_info failed : [%d]", contact_error);
goto FINISH_OFF;
}
@@ -4872,7 +5114,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
goto FINISH_OFF;
}
- if ((contact_error = emcore_search_contact_info_by_address(_contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_error = emcore_search_contact_info_by_address(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
if (contact_error != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contact_error);
goto FINISH_OFF;
@@ -4976,31 +5218,6 @@ FINISH_OFF:
return mime_entity_path;
}
-/* Feedback LED api */
-INTERNAL_FUNC void emcore_set_flash_noti()
-{
- EM_DEBUG_FUNC_BEGIN();
- int flash_error = FEEDBACK_ERROR_NONE;
-
- flash_error = feedback_initialize();
- if (flash_error != FEEDBACK_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("feedback_initialize failed : [%d]", flash_error);
- return;
- }
-
- flash_error = feedback_play_type(FEEDBACK_TYPE_LED, FEEDBACK_PATTERN_EMAIL);
- if (flash_error != FEEDBACK_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("feedback_play_type failed : [%d]", flash_error);
- }
-
- flash_error = feedback_deinitialize();
- if (flash_error != FEEDBACK_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("feedback_play_type failed : [%d]", flash_error);
- }
-
- EM_DEBUG_FUNC_END();
-}
-
INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents, int *length)
{
EM_DEBUG_FUNC_BEGIN("filename[%s], contents[%p], length[%p]", filename, contents, length);
@@ -5152,12 +5369,12 @@ FINISH_OFF:
#ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__
-INTERNAL_FUNC int emcore_update_db_table_schema()
+INTERNAL_FUNC int emcore_update_db_table_schema(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- err = emstorage_update_db_table_schema();
+ err = emstorage_update_db_table_schema(multi_user_name);
EM_DEBUG_FUNC_END("err[%d]", err);
return err;
@@ -5361,4 +5578,119 @@ FINISH_OFF:
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
+
+/* Replace the VCONFKEY_CALL_STATE to dbus */
+#ifdef __FEATURE_DBUS_CALL_STATUS__
+
+static pthread_mutex_t call_status_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int call_status = 0;
+static guint g_dbus_return_id = 0;
+GDBusConnection *call_status_connection = NULL;
+
+static void call_status_dbus_callback(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int call_status_t = 0;
+ int call_type_t = 0;
+ char *phone_number_t = NULL;
+
+ if (strncasecmp(interface_name, "org.tizen.callmgr", strlen("org.tizen.callmgr")) &&
+ strncasecmp(sender_name, "CallStatus", strlen("CallStatus"))) {
+ EM_DEBUG_EXCEPTION("Invalid interface : [%s]", interface_name);
+ return;
+ }
+
+ g_variant_get(parameters, "(iis)",
+ &call_status_t,
+ &call_type_t,
+ &phone_number_t);
+
+ EM_DEBUG_LOG("Call status : [%d], Call type : [%d], Phone_number : [%s]", call_status_t, call_type_t, phone_number_t);
+
+ ENTER_CRITICAL_SECTION(call_status_mutex);
+ call_status = call_status_t;
+ LEAVE_CRITICAL_SECTION(call_status_mutex);
+
+ EM_SAFE_FREE(phone_number_t);
+
+ EM_DEBUG_FUNC_END();
+}
+
+INTERNAL_FUNC int emcore_init_dbus_call_status()
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ GError *error = NULL;
+
+ call_status_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (call_status_connection == NULL) {
+ EM_DEBUG_EXCEPTION("g_bus_get_sync failed : [%s]", error->message);
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ g_dbus_return_id = g_dbus_connection_signal_subscribe(call_status_connection,
+ NULL,
+ "org.tizen.callmgr",
+ "CallStatus",
+ "/org/tizen/callmgr",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ call_status_dbus_callback,
+ NULL,
+ NULL);
+ if (g_dbus_return_id == -1) {
+ EM_DEBUG_EXCEPTION("DBus connection failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ if (error)
+ g_error_free(error);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+INTERNAL_FUNC void emcore_shutdown_dbus_call_status()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ if (g_dbus_return_id) {
+ g_dbus_connection_signal_unsubscribe(call_status_connection, g_dbus_return_id);
+ g_dbus_return_id = 0;
+ }
+
+ if (call_status_connection) {
+ g_object_unref(call_status_connection);
+ call_status_connection = NULL;
+ }
+
+ EM_DEBUG_FUNC_END();
+}
+
+INTERNAL_FUNC int emcore_get_call_status()
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int call_status_t = 0;
+
+ ENTER_CRITICAL_SECTION(call_status_mutex);
+ call_status_t = call_status;
+ LEAVE_CRITICAL_SECTION(call_status_mutex);
+
+ EM_DEBUG_FUNC_END();
+ return call_status_t;
+}
+
+#endif /* __FEATURE_DBUS_CALL_STATUS__ */
+
/* EOF */
diff --git a/email-core/email-network/email-network.c b/email-core/email-network/email-network.c
index 04d44e8..ce47151 100755
--- a/email-core/email-network/email-network.c
+++ b/email-core/email-network/email-network.c
@@ -154,10 +154,10 @@ INTERNAL_FUNC int emnetwork_check_network_status(int *err_code)
int err = EMAIL_ERROR_NONE;
int ret = false;
- if(network_status == 0) {
+ if (network_status == 0) {
EM_DEBUG_LOG("VCONFKEY_NETWORK_STATUS is 0");
- if ( (err = _get_flight_mode(&flight_mode)) != EMAIL_ERROR_NONE) {
+ if ((err = _get_flight_mode(&flight_mode)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_get_flight_mode failed : [%d]", err);
goto FINISH_OFF;
}
@@ -168,7 +168,7 @@ INTERNAL_FUNC int emnetwork_check_network_status(int *err_code)
goto FINISH_OFF;
}
- if ( (err = emnetwork_get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) {
+ if ((err = emnetwork_get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emnetwork_get_wifi_status failed [%d]", err);
goto FINISH_OFF;
}
diff --git a/email-core/email-storage/email-storage.c b/email-core/email-storage/email-storage.c
index e684653..b6b81d3 100755
--- a/email-core/email-storage/email-storage.c
+++ b/email-core/email-storage/email-storage.c
@@ -62,11 +62,10 @@
#include "email-convert.h"
#include "email-core-signal.h"
#include "email-core-event.h"
-
-#define DB_STMT sqlite3_stmt *
+#include "email-core-container.h"
+#include "email-core-gmime.h"
#define SETTING_MEMORY_TEMP_FILE_PATH "/tmp/email_tmp_file"
-
#define CONTENT_DATA "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset="
#define CONTENT_TYPE_DATA "<meta http-equiv=\"Content-Type\" content=\"text/html; charset="
@@ -143,10 +142,10 @@
#define CERTIFICATE_PATH_LEN_IN_MAIL_ACCOUNT_TBL 256
/* this define is used for query to change data (delete, insert, update) */
-#define EMSTORAGE_START_WRITE_TRANSACTION(transaction_flag, error_code) \
+#define EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction_flag, error_code) \
do {\
if (transaction_flag) {\
- if (emstorage_begin_transaction(NULL, NULL, &error_code) == false) {\
+ if (emstorage_begin_transaction(multi_user_name, NULL, NULL, &error_code) == false) {\
EM_DEBUG_EXCEPTION("emstorage_begin_transaction error [%d]", error_code);\
goto FINISH_OFF;\
}\
@@ -154,18 +153,18 @@
} while(0)
/* this define is used for query to change data (delete, insert, update) */
-#define EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction_flag, result_code, error_code) \
+#define EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction_flag, result_code, error_code) \
do {\
if (transaction_flag) {\
if (result_code == true) {\
- if (emstorage_commit_transaction(NULL, NULL, NULL) == false) {\
+ if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {\
EM_DEBUG_EXCEPTION("emstorage_commit_transaction error");\
error_code = EMAIL_ERROR_DB_FAILURE;\
result_code = false;\
}\
}\
else {\
- if (emstorage_rollback_transaction(NULL, NULL, NULL) == false) {\
+ if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false) {\
EM_DEBUG_EXCEPTION("emstorage_rollback_transaction error");\
error_code = EMAIL_ERROR_DB_FAILURE;\
}\
@@ -177,14 +176,14 @@
#define EMSTORAGE_START_READ_TRANSACTION(transaction_flag) \
if (transaction_flag)\
{\
- /*_timedlock_shm_mutex(&mapped_for_db_lock, 2);*/\
+ /*_timedlock_shm_mutex(mapped_for_db_lock, 2);*/\
}
/* this define is used for query to read (select) */
#define EMSTORAGE_FINISH_READ_TRANSACTION(transaction_flag) \
if (transaction_flag)\
{\
- /*_unlockshm_mutex(&mapped_for_db_lock);*/\
+ /*_unlockshm_mutex(mapped_for_db_lock);*/\
}
/* for safety DB operation */
@@ -199,6 +198,7 @@ static pthread_mutex_t _ss_handle_lock = PTHREAD_MUTEX_INITIALIZER;
typedef struct
{
+ char *user_name;
pthread_t thread_id;
sqlite3 *db_handle;
} db_handle_t;
@@ -206,24 +206,43 @@ typedef struct
#define MAX_DB_CLIENT 100
/* static int _db_handle_count = 0; */
-db_handle_t _db_handle_list[MAX_DB_CLIENT] = {{0, 0}, };
+db_handle_t _db_handle_list[MAX_DB_CLIENT] = {{NULL, 0, 0}, };
+
-sqlite3 *emstorage_get_db_handle()
+sqlite3 *emstorage_get_db_handle(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int i;
pthread_t current_thread_id = THREAD_SELF();
sqlite3 *result_db_handle = NULL;
- ENTER_CRITICAL_SECTION(_db_handle_lock);
- for (i = 0; i < MAX_DB_CLIENT; i++) {
- if (pthread_equal(current_thread_id, _db_handle_list[i].thread_id)) {
- EM_DEBUG_LOG_DEV("found db handle at [%d]", i);
- result_db_handle = _db_handle_list[i].db_handle;
- break;
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ ENTER_CRITICAL_SECTION(_db_handle_lock);
+ for (i = 0; i < MAX_DB_CLIENT; i++) {
+ if (EM_SAFE_STRCASECMP(_db_handle_list[i].user_name, multi_user_name) != 0)
+ continue;
+
+ if (pthread_equal(current_thread_id, _db_handle_list[i].thread_id)) {
+ EM_DEBUG_LOG_DEV("found db handle at [%d]", i);
+ result_db_handle = _db_handle_list[i].db_handle;
+ break;
+ }
}
+ LEAVE_CRITICAL_SECTION(_db_handle_lock);
+ } else {
+ ENTER_CRITICAL_SECTION(_db_handle_lock);
+ for (i = 0; i < MAX_DB_CLIENT; i++) {
+ if (EM_SAFE_STRLEN(_db_handle_list[i].user_name) > 0)
+ continue;
+
+ if (pthread_equal(current_thread_id, _db_handle_list[i].thread_id)) {
+ EM_DEBUG_LOG_DEV("found db handle at [%d]", i);
+ result_db_handle = _db_handle_list[i].db_handle;
+ break;
+ }
+ }
+ LEAVE_CRITICAL_SECTION(_db_handle_lock);
}
- LEAVE_CRITICAL_SECTION(_db_handle_lock);
if (!result_db_handle)
EM_DEBUG_LOG("no db_handle for [%d] found", current_thread_id);
@@ -232,7 +251,7 @@ sqlite3 *emstorage_get_db_handle()
return result_db_handle;
}
-int emstorage_set_db_handle(sqlite3 *db_handle)
+int emstorage_set_db_handle(char *multi_user_name, sqlite3 *db_handle)
{
EM_DEBUG_FUNC_BEGIN();
int i, error_code = EMAIL_ERROR_MAX_EXCEEDED;
@@ -243,6 +262,8 @@ int emstorage_set_db_handle(sqlite3 *db_handle)
if (_db_handle_list[i].thread_id == 0) {
_db_handle_list[i].thread_id = current_thread_id;
_db_handle_list[i].db_handle = db_handle;
+ /* Only distinguished container and host */
+ _db_handle_list[i].user_name = EM_SAFE_STRDUP(multi_user_name);
EM_DEBUG_LOG("current_thread_id [%d], index [%d]", current_thread_id, i);
error_code = EMAIL_ERROR_NONE;
break;
@@ -268,6 +289,8 @@ int emstorage_remove_db_handle()
{
_db_handle_list[i].thread_id = 0;
_db_handle_list[i].db_handle = NULL;
+ EM_SAFE_FREE(_db_handle_list[i].user_name);
+
EM_DEBUG_LOG("index [%d]", i);
error_code = EMAIL_ERROR_NONE;
break;
@@ -282,7 +305,6 @@ int emstorage_remove_db_handle()
return error_code;
}
-
int emstorage_reset_db_handle_list()
{
EM_DEBUG_FUNC_BEGIN();
@@ -293,6 +315,7 @@ int emstorage_reset_db_handle_list()
{
_db_handle_list[i].thread_id = 0;
_db_handle_list[i].db_handle = NULL;
+ EM_SAFE_FREE(_db_handle_list[i].user_name);
}
LEAVE_CRITICAL_SECTION(_db_handle_lock)
@@ -300,9 +323,10 @@ int emstorage_reset_db_handle_list()
return EMAIL_ERROR_NONE;
}
-sqlite3 *emstorage_get_db_connection()
+
+sqlite3 *emstorage_get_db_connection(char *multi_user_name)
{
- return emstorage_db_open(NULL);
+ return emstorage_db_open(multi_user_name, NULL);
}
#else /* _MULTIPLE_DB_HANDLE */
@@ -336,9 +360,9 @@ int shm_fd_for_generating_mail_id = 0;
#ifdef __FEATURE_USE_SHARED_MUTEX_FOR_PROTECTED_FUNC_CALL__
#define EMSTORAGE_PROTECTED_FUNC_CALL(function_call, return_value) \
do {\
- _timedlock_shm_mutex(&mapped_for_db_lock, 2);\
+ _timedlock_shm_mutex(mapped_for_db_lock, 2);\
return_value = function_call;\
- _unlockshm_mutex(&mapped_for_db_lock);\
+ _unlockshm_mutex(mapped_for_db_lock);\
} while(0)
#else /* __FEATURE_USE_SHARED_MUTEX_FOR_PROTECTED_FUNC_CALL__ */
@@ -377,6 +401,7 @@ FINISH_OFF :
INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name)
{
EM_DEBUG_FUNC_BEGIN("shm_file_name [%p]", shm_file_name);
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
if(!shm_file_name) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -384,9 +409,8 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name)
}
int fd = shm_open (shm_file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); /* note: permission is not working */
-
if (fd < 0) {
- EM_DEBUG_EXCEPTION("shm_open errno [%d]", errno);
+ EM_DEBUG_EXCEPTION("shm_open errno [%d] [%s]", errno, EM_STRERROR(errno_buf));
return EMAIL_ERROR_SYSTEM_FAILURE;
}
@@ -411,15 +435,13 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name)
pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
pthread_mutex_init(&(m->mutex), &mattr);
-
pthread_mutexattr_destroy(&mattr);
- pthread_mutex_destroy(&(m->mutex));
+ pthread_mutex_destroy(&(m->mutex));
munmap(m, sizeof(mmapped_t));
EM_SAFE_CLOSE (fd);
EM_DEBUG_FUNC_END();
-
return EMAIL_ERROR_NONE;
}
@@ -451,15 +473,21 @@ int _initialize_shm_mutex(const char *shm_file_name, int *param_shm_fd, mmapped_
if (!(*param_mapped)) {
EM_DEBUG_LOG("** mapping begin **");
-
if (!(*param_shm_fd)) { /* open shm_file_name at first. Otherwise, the num of files in /proc/pid/fd will be increasing */
- *param_shm_fd = shm_open(shm_file_name, O_RDWR, 0);
+ *param_shm_fd = shm_open(shm_file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if ((*param_shm_fd) == -1) {
EM_DEBUG_EXCEPTION("FAIL: shm_open(): %s", EM_STRERROR(errno_buf));
return EMAIL_ERROR_SYSTEM_FAILURE;
}
}
+ fchmod((*param_shm_fd), 0666);
+ EM_DEBUG_LOG("** Create SHM FILE **");
+ if (ftruncate((*param_shm_fd), sizeof(mmapped_t)) != 0) {
+ EM_DEBUG_EXCEPTION("ftruncate errno [%d]", errno);
+ return EMAIL_ERROR_SYSTEM_FAILURE;
+ }
+
mmapped_t *tmp = (mmapped_t *)mmap(NULL, sizeof(mmapped_t), PROT_READ|PROT_WRITE, MAP_SHARED, (*param_shm_fd), 0);
if (tmp == MAP_FAILED) {
EM_DEBUG_EXCEPTION("mmap failed: %s", EM_STRERROR(errno_buf));
@@ -482,7 +510,7 @@ int _initialize_shm_mutex(const char *shm_file_name, int *param_shm_fd, mmapped_
return EMAIL_ERROR_NONE;
}
-int _timedlock_shm_mutex(mmapped_t **param_mapped, int sec)
+int _timedlock_shm_mutex(mmapped_t *param_mapped, int sec)
{
EM_DEBUG_FUNC_BEGIN("param_mapped [%p], sec [%d]", param_mapped, sec);
@@ -496,10 +524,10 @@ int _timedlock_shm_mutex(mmapped_t **param_mapped, int sec)
abs_time.tv_sec += sec;
char errno_buf[ERRNO_BUF_SIZE] = {0};
- int err = pthread_mutex_timedlock(&((*param_mapped)->mutex), &abs_time);
+ int err = pthread_mutex_timedlock(&(param_mapped->mutex), &abs_time);
if (err == EOWNERDEAD) {
- err = pthread_mutex_consistent(&((*param_mapped)->mutex));
+ err = pthread_mutex_consistent(&(param_mapped->mutex));
EM_DEBUG_EXCEPTION("Previous owner is dead with lock. Fix mutex : %s", EM_STRERROR(errno_buf));
}
else if (err != 0) {
@@ -511,10 +539,10 @@ int _timedlock_shm_mutex(mmapped_t **param_mapped, int sec)
return EMAIL_ERROR_NONE;
}
-void _unlockshm_mutex(mmapped_t **param_mapped)
+void _unlockshm_mutex(mmapped_t *param_mapped)
{
EM_DEBUG_FUNC_BEGIN();
- pthread_mutex_unlock(&((*param_mapped)->mutex));
+ pthread_mutex_unlock(&(param_mapped->mutex));
EM_DEBUG_FUNC_END();
}
/* ------------------------------------------------------------------------------ */
@@ -522,7 +550,7 @@ void _unlockshm_mutex(mmapped_t **param_mapped)
static int _open_counter = 0;
-static int _get_password_file_name(int account_id, char *recv_password_file_name, char *send_password_file_name);
+static int _get_password_file_name(char *multi_user_name, int account_id, char *recv_password_file_name, char *send_password_file_name);
static int _read_password_from_secure_storage(char *file_name, char **password);
#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__
@@ -734,6 +762,7 @@ enum
DEFAULT_CHARSET_IDX_IN_MAIL_TBL,
EAS_DATA_LENGTH_IDX_IN_MAIL_TBL,
EAS_DATA_IDX_IN_MAIL_TBL,
+ USER_NAME_IDX_IN_MAIL_TBL,
FIELD_COUNT_OF_MAIL_TBL, /* End of mail_tbl */
};
@@ -785,6 +814,7 @@ enum
MAIL_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL,
SERVER_MAIL_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL,
MAILBOX_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL,
+ MULTI_USER_NAME_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL,
};
#endif
@@ -972,6 +1002,7 @@ static char *g_test_query[] = {
" activity_type, "
" mailbox_id, "
" mailbox_name "
+ " multi_user_name "
" FROM mail_partial_body_activity_tbl ",
#endif
@@ -1043,6 +1074,7 @@ static char *g_test_query[] = {
" mail_id, "
" server_mail_id, "
" mailbox_id, "
+ " multi_user_name, "
" FROM mail_auto_download_activity_tbl ",
#endif
NULL,
@@ -1545,7 +1577,7 @@ INTERNAL_FUNC int emstorage_close(int *err_code)
int ret = false;
int error = EMAIL_ERROR_NONE;
- emstorage_db_close(&error);
+ if (!emstorage_db_close(NULL, &error))
if (--_open_counter == 0)
_emstorage_close_once();
@@ -1559,53 +1591,118 @@ INTERNAL_FUNC int emstorage_close(int *err_code)
return ret;
}
-static void *_emstorage_open_once(int *err_code)
+static void *_emstorage_open_once(char *multi_user_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int error = EMAIL_ERROR_NONE;
- mkdir(USERDATA_PATH, DIRECTORY_PERMISSION);
- mkdir(DATA_PATH, DIRECTORY_PERMISSION);
- mkdir(EMAILPATH, DIRECTORY_PERMISSION);
- mkdir(MAILHOME, DIRECTORY_PERMISSION);
- mkdir(MAILTEMP, DIRECTORY_PERMISSION);
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ char buf[MAX_PATH] = {0};
+ char *prefix_path = NULL;
- _delete_temp_file(MAILTEMP);
+ error = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+
+ memset(buf, 0x00, sizeof(buf));
+ SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, USERDATA_PATH);
+ mkdir(buf, DIRECTORY_PERMISSION);
+
+ memset(buf, 0x00, sizeof(buf));
+ SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, EMAILPATH);
+ mkdir(buf, DIRECTORY_PERMISSION);
+
+ memset(buf, 0x00, sizeof(buf));
+ SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, MAILHOME);
+ mkdir(buf, DIRECTORY_PERMISSION);
+
+ memset(buf, 0x00, sizeof(buf));
+ SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, MAILTEMP);
+ mkdir(buf, DIRECTORY_PERMISSION);
+ chmod(buf, 0777);
+
+ _delete_temp_file(buf);
+ EM_SAFE_FREE(prefix_path);
+ } else {
+ mkdir(USERDATA_PATH, DIRECTORY_PERMISSION);
+ mkdir(DATA_PATH, DIRECTORY_PERMISSION);
+ mkdir(EMAILPATH, DIRECTORY_PERMISSION);
+ mkdir(MAILHOME, DIRECTORY_PERMISSION);
+ mkdir(MAILTEMP, DIRECTORY_PERMISSION);
+ chmod(MAILTEMP, 0777);
+
+ _delete_temp_file(MAILTEMP);
+ }
- if (!emstorage_create_table(EMAIL_CREATE_DB_NORMAL, &error)) {
+ if (!emstorage_create_table(multi_user_name, EMAIL_CREATE_DB_NORMAL, &error)) {
EM_DEBUG_EXCEPTION(" emstorage_create_table failed - %d", error);
goto FINISH_OFF;
}
FINISH_OFF:
+
+
if (err_code != NULL)
*err_code = error;
-
return NULL;
}
/* pData : a parameter which is registered when busy handler is registerd */
/* count : retry count */
-#define EMAIL_STORAGE_MAX_RETRY_COUNT 20
static int _callback_sqlite_busy_handler(void *pData, int count)
{
- EM_DEBUG_LOG("Busy Handler Called!!: [%d]", count);
- usleep(200000); /* sleep time when SQLITE_LOCK */
+ if (10 - count > 0) {
+ struct timespec time = {
+ .tv_sec = 0,
+ .tv_nsec = (count + 1) * 100 * 1000 * 1000
+ };
+ EM_DEBUG_LOG("Busy handler called!!: PID[%d] / CNT [%d]", getpid(), count);
+ nanosleep(&time, NULL);
+ return 1;
+ } else {
+ EM_DEBUG_EXCEPTION("Busy handler will be returned SQLITE_BUSY error PID[%d] / CNT[%d]", getpid(), count);
+ return 0;
+ }
+}
- /* retry will be stopped if busy handler return 0 */
- return EMAIL_STORAGE_MAX_RETRY_COUNT - count;
+static int _callback_collation_utf7_sort(void *data, int length_text_a, const void *text_a,
+ int length_text_b, const void *text_b)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int result = 0;
+ char *converted_string_a = NULL;
+ char *converted_string_b = NULL;
+
+ EM_DEBUG_LOG_DEV("text_a : [%s]", text_a);
+ converted_string_a = emcore_convert_mutf7_to_utf8((char *)text_a);
+ EM_DEBUG_LOG_DEV("Converted text_a : [%s]", converted_string_a);
+
+ EM_DEBUG_LOG_DEV("text_b : [%s]", text_b);
+ converted_string_b = emcore_convert_mutf7_to_utf8((char *)text_b);
+ EM_DEBUG_LOG_DEV("Converted text_b : [%s]", converted_string_b);
+
+ if (converted_string_a && converted_string_b)
+ result = strcmp(converted_string_a, converted_string_b);
+
+ EM_SAFE_FREE(converted_string_a);
+ EM_SAFE_FREE(converted_string_b);
+
+ EM_DEBUG_FUNC_END();
+ return result;
}
-static int _delete_all_files_and_directories(int *err_code)
+static int _delete_all_files_and_directories(char *db_file_path, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int error = EMAIL_ERROR_NONE;
int ret = false;
- if (!emstorage_delete_file(EMAIL_SERVICE_DB_FILE_PATH, &error)) {
+ if (!emstorage_delete_file(db_file_path, &error)) {
if (error != EMAIL_ERROR_FILE_NOT_FOUND) {
EM_DEBUG_EXCEPTION_SEC("remove failed - %s", EMAIL_SERVICE_DB_FILE_PATH);
goto FINISH_OFF;
@@ -1626,7 +1723,7 @@ FINISH_OFF:
return ret;
}
-static int _recovery_from_malformed_db_file(int *err_code)
+static int _recovery_from_malformed_db_file(char *db_file_path, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1634,7 +1731,7 @@ static int _recovery_from_malformed_db_file(int *err_code)
int ret = false;
/* Delete all files and directories */
- if (!_delete_all_files_and_directories(&error)) {
+ if (!_delete_all_files_and_directories(db_file_path, &error)) {
EM_DEBUG_EXCEPTION("_delete_all_files_and_directories failed [%d]", error);
goto FINISH_OFF;
}
@@ -1653,8 +1750,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code)
+INTERNAL_FUNC int em_db_open(char *db_file_path, sqlite3 **sqlite_handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int rc = 0;
@@ -1670,8 +1766,10 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code)
return true;
}
+ EM_DEBUG_LOG("DB file path : [%s]", db_file_path);
+
/* db open */
- EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_open(EMAIL_SERVICE_DB_FILE_PATH, sqlite_handle), rc);
+ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_open(db_file_path, sqlite_handle), rc);
if (SQLITE_OK != rc) {
EM_DEBUG_EXCEPTION("sqlite3_open fail:%d -%s", rc, sqlite3_errmsg(*sqlite_handle));
if (SQLITE_PERM == rc || SQLITE_CANTOPEN == rc) {
@@ -1684,13 +1782,13 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code)
if (SQLITE_CORRUPT == rc) /* SQLITE_CORRUPT : The database disk image is malformed */ {/* Recovery DB file */
EM_DEBUG_LOG("The database disk image is malformed. Trying to remove and create database disk image and directories");
- if (!_recovery_from_malformed_db_file(&error)) {
+ if (!_recovery_from_malformed_db_file(db_file_path, &error)) {
EM_DEBUG_EXCEPTION("_recovery_from_malformed_db_file failed [%d]", error);
goto FINISH_OFF;
}
EM_DEBUG_LOG("Open DB again");
- EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_open(EMAIL_SERVICE_DB_FILE_PATH, sqlite_handle), rc);
+ EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_open(db_file_path, sqlite_handle), rc);
if (SQLITE_OK != rc) {
EM_DEBUG_EXCEPTION("sqlite3_open fail:%d -%s", rc, sqlite3_errmsg(*sqlite_handle));
if (SQLITE_PERM == rc) {
@@ -1707,8 +1805,8 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code)
goto FINISH_OFF;
}
- EM_DEBUG_LOG_DEV(">>>>> Register DB Handle to busy handler: *sqlite_handle[%p]", *sqlite_handle);
/* register busy handler */
+ EM_DEBUG_LOG_DEV(">>>>> Register DB Handle to busy handler: *sqlite_handle[%p]", *sqlite_handle);
rc = sqlite3_busy_handler(*sqlite_handle, _callback_sqlite_busy_handler, NULL); /* Busy Handler registration, NULL is a parameter which will be passed to handler */
if (SQLITE_OK != rc) {
EM_DEBUG_EXCEPTION("sqlite3_busy_handler fail:%d -%s", rc, sqlite3_errmsg(*sqlite_handle));
@@ -1718,6 +1816,16 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code)
goto FINISH_OFF;
}
+ /* Register collation callback function */
+ rc = sqlite3_create_collation(*sqlite_handle, "CONVERTUTF8", SQLITE_UTF8, NULL, _callback_collation_utf7_sort);
+ if (SQLITE_OK != rc) {
+ EM_DEBUG_EXCEPTION("sqlite3_create_collation failed : [%d][%s]", rc, sqlite3_errmsg(*sqlite_handle));
+ error = EMAIL_ERROR_DB_FAILURE;
+ sqlite3_close(*sqlite_handle);
+ *sqlite_handle = NULL;
+ goto FINISH_OFF;
+ }
+
ret = true;
FINISH_OFF:
@@ -1728,33 +1836,63 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC sqlite3* emstorage_db_open(int *err_code)
+INTERNAL_FUNC sqlite3* emstorage_db_open(char *multi_user_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
sqlite3 *_db_handle = NULL;
int error = EMAIL_ERROR_NONE;
+ char *prefix_path = NULL;
- _db_handle = emstorage_get_db_handle();
+ _db_handle = emstorage_get_db_handle(multi_user_name);
if( _db_handle == NULL) {
- if (!em_db_open(&_db_handle, &error)) {
+ char *output_file_path = NULL;
+ char temp_file_path[MAX_PATH] = {0};
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ error = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (error != EMAIL_ERROR_CONTAINER_NOT_INITIALIZATION && error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", error);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
+ if (error == EMAIL_ERROR_CONTAINER_NOT_INITIALIZATION) {
+ if ((error = emcore_get_canonicalize_path(EMAIL_SERVICE_DB_FILE_PATH, &output_file_path)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_canonicalize_path failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+
+ SNPRINTF(temp_file_path, sizeof(temp_file_path), "%s", output_file_path);
+ EM_SAFE_FREE(output_file_path);
+ } else {
+ SNPRINTF(temp_file_path, sizeof(temp_file_path), "%s%s", prefix_path, EMAIL_SERVICE_DB_FILE_PATH);
+ }
+
+ if (!em_db_open(temp_file_path, &_db_handle, &error)) {
EM_DEBUG_EXCEPTION("em_db_open failed[%d]", error);
goto FINISH_OFF;
}
+
_initialize_shm_mutex(SHM_FILE_FOR_DB_LOCK, &shm_fd_for_db_lock, &mapped_for_db_lock);
#ifdef __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__
_initialize_shm_mutex(SHM_FILE_FOR_MAIL_ID_LOCK, &shm_fd_for_generating_mail_id, &mapped_for_generating_mail_id);
#endif /*__FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ */
- emstorage_set_db_handle(_db_handle);
+ emstorage_set_db_handle(multi_user_name, _db_handle);
+
emstorage_initialize_field_count();
}
-
FINISH_OFF:
+
+ EM_SAFE_FREE(prefix_path);
+
if (err_code != NULL)
*err_code = error;
@@ -1762,11 +1900,11 @@ FINISH_OFF:
return _db_handle;
}
-INTERNAL_FUNC int emstorage_db_close(int *err_code)
+INTERNAL_FUNC int emstorage_db_close(char *multi_user_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
#ifdef _MULTIPLE_DB_HANDLE
- sqlite3 *_db_handle = emstorage_get_db_handle();
+ sqlite3 *_db_handle = emstorage_get_db_handle(multi_user_name);
#endif
int error = EMAIL_ERROR_NONE;
@@ -1796,38 +1934,52 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_open(int *err_code)
+INTERNAL_FUNC int emstorage_open(char *multi_user_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
- int ret = false;
- int error = EMAIL_ERROR_NONE;
+ int ret = false;
+ int error = EMAIL_ERROR_NONE;
+ int retValue;
+ char *prefix_path = NULL;
+ char buf[MAX_PATH] = {0};
- int retValue;
+ if (EM_SAFE_STRLEN(multi_user_name) <= 0) {
+ SNPRINTF(buf, sizeof(buf), "%s", DB_PATH);
+ } else {
+ error = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+ SNPRINTF(buf, sizeof(buf), "%s/%s", prefix_path, DB_PATH);
+ }
- retValue = mkdir(DB_PATH, DIRECTORY_PERMISSION);
+ retValue = mkdir(buf, DIRECTORY_PERMISSION);
- EM_DEBUG_LOG("mkdir return- %d", retValue);
- EM_DEBUG_LOG("emstorage_open - before sqlite3_open - pid = %d", getpid());
+ EM_DEBUG_LOG("mkdir return- %d", retValue);
+ EM_DEBUG_LOG("emstorage_open - before sqlite3_open - pid = %d", getpid());
- if (emstorage_db_open(&error) == NULL) {
- EM_DEBUG_EXCEPTION("emstorage_db_open failed[%d]", error);
- goto FINISH_OFF;
- }
+ if (emstorage_db_open(multi_user_name, &error) == NULL) {
+ EM_DEBUG_EXCEPTION("emstorage_db_open failed[%d]", error);
+ goto FINISH_OFF;
+ }
- if (_open_counter++ == 0) {
- _emstorage_open_once(&error);
- }
+ if (_open_counter++ == 0) {
+ _emstorage_open_once(multi_user_name, &error);
+ }
- ret = true;
+ ret = true;
FINISH_OFF:
- if (err_code != NULL)
- *err_code = error;
- EM_DEBUG_FUNC_END("ret [%d]", ret);
- return ret;
+ EM_SAFE_FREE(prefix_path);
+
+ if (err_code != NULL)
+ *err_code = error;
+
+ EM_DEBUG_FUNC_END("ret [%d]", ret);
+ return ret;
}
static int emstorage_get_field_count_from_create_table_query(char *input_create_table_query, int *output_field_count)
@@ -1910,7 +2062,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *err_code)
+INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create_db_type_t type, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1919,7 +2071,8 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e
int query_len = 0;
char sql_query_string[QUERY_SIZE] = {0, };
char **create_table_query = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
error = emcore_load_query_from_file(EMAIL_SERVICE_CREATE_TABLE_QUERY_FILE_PATH, &create_table_query, &query_len);
if (error != EMAIL_ERROR_NONE) {
@@ -2360,11 +2513,11 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e
EM_DEBUG_LOG("CREATE TABLE mail_text_tbl");
EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_TEXT_TBL], sizeof(sql_query_string)-1); /*prevent 21984 */
- error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
- if (error != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_exec_query_by_prepare_v2 failed:[%d]", error);
- goto FINISH_OFF;
- }
+ error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_exec_query_by_prepare_v2 failed:[%d]", error);
+ goto FINISH_OFF;
+ }
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
} /* mail_text_tbl */
@@ -2391,11 +2544,11 @@ INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *e
EM_DEBUG_LOG("CREATE TABLE mail_auto_download_activity_tbl");
EM_SAFE_STRNCPY(sql_query_string, create_table_query[CREATE_TABLE_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL], sizeof(sql_query_string)-1);
- error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
- if (error != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_exec_query_by_prepare_v2 failed:[%d]", error);
- goto FINISH_OFF;
- }
+ error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_exec_query_by_prepare_v2 failed:[%d]", error);
+ goto FINISH_OFF;
+ }
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
} /* mail_auto_download_activity_tbl */
@@ -2441,8 +2594,7 @@ FINISH_OFF2:
}
/* Query series --------------------------------------------------------------*/
-
-INTERNAL_FUNC int emstorage_query_mail_count(const char *input_conditional_clause, int input_transaction, int *output_total_mail_count, int *output_unseen_mail_count)
+INTERNAL_FUNC int emstorage_query_mail_count(char *multi_user_name, const char *input_conditional_clause, int input_transaction, int *output_total_mail_count, int *output_unseen_mail_count)
{
EM_DEBUG_FUNC_BEGIN("input_conditional_clause[%p], input_transaction[%d], output_total_mail_count[%p], output_unseen_mail_count[%p]", input_conditional_clause, input_transaction, output_total_mail_count, output_unseen_mail_count);
int rc = -1;
@@ -2466,7 +2618,7 @@ INTERNAL_FUNC int emstorage_query_mail_count(const char *input_conditional_claus
goto FINISH_OFF;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(input_transaction);
@@ -2513,7 +2665,7 @@ FINISH_OFF:
return error;
}
-INTERNAL_FUNC int emstorage_query_mail_id_list(const char *input_conditional_clause, int input_transaction, int **output_mail_id_list, int *output_mail_id_count)
+INTERNAL_FUNC int emstorage_query_mail_id_list(char *multi_user_name, const char *input_conditional_clause, int input_transaction, int **output_mail_id_list, int *output_mail_id_count)
{
EM_DEBUG_FUNC_BEGIN("input_conditional_clause [%p], input_transaction [%d], output_mail_id_list [%p], output_mail_id_count [%p]", input_conditional_clause, input_transaction, output_mail_id_list, output_mail_id_count);
@@ -2527,7 +2679,7 @@ INTERNAL_FUNC int emstorage_query_mail_id_list(const char *input_conditional_cla
int *result_mail_id_list = NULL;
char **result = NULL;
char *sql_query_string = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EM_IF_NULL_RETURN_VALUE(input_conditional_clause, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(output_mail_id_list, EMAIL_ERROR_INVALID_PARAM);
@@ -2597,7 +2749,7 @@ FINISH_OFF:
return error;
}
-INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int transaction, email_mail_list_item_t** result_mail_list, int *result_count, int *err_code)
+INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *conditional_clause, int transaction, email_mail_list_item_t** result_mail_list, int *result_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
EM_PROFILE_BEGIN(emstorage_query_mail_list_func);
@@ -2615,7 +2767,7 @@ INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int
char *target_field = NULL;
char *sql_query_string = NULL;
email_mail_list_item_t *mail_list_item_from_tbl = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EM_IF_NULL_RETURN_VALUE(conditional_clause, false);
EM_IF_NULL_RETURN_VALUE(result_count, false);
@@ -2757,7 +2909,7 @@ FINISH_OFF:
EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
- sqlite3_db_release_memory(local_db_handle);
+// sqlite3_db_release_memory(local_db_handle);
EM_SAFE_FREE(sql_query_string);
EM_SAFE_FREE(date_time_string);
@@ -2771,7 +2923,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int transaction, emstorage_mail_tbl_t** result_mail_tbl, int *result_count, int *err_code)
+INTERNAL_FUNC int emstorage_query_mail_tbl(char *multi_user_name, const char *conditional_clause, int transaction, emstorage_mail_tbl_t** result_mail_tbl, int *result_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("conditional_clause[%s], result_mail_tbl[%p], result_count [%p], transaction[%d], err_code[%p]", conditional_clause, result_mail_tbl, result_count, transaction, err_code);
@@ -2786,7 +2938,7 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int t
int error = EMAIL_ERROR_NONE;
char **result = NULL, sql_query_string[QUERY_SIZE] = {0, };
emstorage_mail_tbl_t* p_data_tbl = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -2869,6 +3021,7 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int t
_get_table_field_data_string(result, &(p_data_tbl[i].default_charset), 0, col_index++);
_get_table_field_data_int (result, (int*)&(p_data_tbl[i].eas_data_length), col_index++);
_get_table_field_data_blob (result, (void**)&(p_data_tbl[i].eas_data), p_data_tbl[i].eas_data_length, col_index++);
+ _get_table_field_data_string(result, &(p_data_tbl[i].user_name), 0, col_index++);
}
ret = true;
@@ -2888,7 +3041,7 @@ FINISH_OFF:
EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
- sqlite3_db_release_memory(local_db_handle);
+// sqlite3_db_release_memory(local_db_handle);
if (err_code != NULL)
*err_code = error;
@@ -2898,7 +3051,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_BODY_SEARCH__
-INTERNAL_FUNC int emstorage_query_mail_text_tbl(const char *conditional_clause, int transaction, emstorage_mail_text_tbl_t** result_mail_text_tbl, int *result_count, int *err_code)
+INTERNAL_FUNC int emstorage_query_mail_text_tbl(char *multi_user_name, const char *conditional_clause, int transaction, emstorage_mail_text_tbl_t** result_mail_text_tbl, int *result_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("conditional_clause[%s], result_mail_text_tbl[%p], result_count [%p], transaction[%d], err_code[%p]", conditional_clause, result_mail_text_tbl, result_count, transaction, err_code);
@@ -2918,7 +3071,7 @@ INTERNAL_FUNC int emstorage_query_mail_text_tbl(const char *conditional_clause,
char **result = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
emstorage_mail_text_tbl_t* p_data_tbl = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -2967,7 +3120,7 @@ FINISH_OFF:
EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
- sqlite3_db_release_memory(local_db_handle);
+// sqlite3_db_release_memory(local_db_handle);
if (err_code != NULL)
*err_code = error;
@@ -2977,7 +3130,7 @@ FINISH_OFF:
}
#endif
-INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clause, const char *input_ordering_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count)
+INTERNAL_FUNC int emstorage_query_mailbox_tbl(char *multi_user_name, const char *input_conditional_clause, const char *input_ordering_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count)
{
EM_DEBUG_FUNC_BEGIN("input_conditional_clause[%p], input_ordering_clause [%p], input_get_mail_count[%d], input_transaction[%d], output_mailbox_list[%p], output_mailbox_count[%d]", input_conditional_clause, input_ordering_clause, input_get_mail_count, input_transaction, output_mailbox_list, output_mailbox_count);
@@ -2992,7 +3145,7 @@ INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clau
char sql_query_string[QUERY_SIZE] = {0, };
char *fields = "MBT.mailbox_id, MBT.account_id, local_yn, MBT.mailbox_name, MBT.mailbox_type, alias, deleted_flag, modifiable_yn, total_mail_count_on_server, has_archived_mails, mail_slot_size, no_select, last_sync_time, MBT.eas_data_length, MBT.eas_data ";
emstorage_mailbox_tbl_t* p_data_tbl = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(input_transaction);
@@ -3005,13 +3158,13 @@ INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clau
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s, total, read FROM mail_box_tbl AS MBT LEFT OUTER JOIN (SELECT mailbox_id, count(mail_id) AS total, SUM(flags_seen_field) AS read FROM mail_tbl WHERE flags_deleted_field = 0 GROUP BY mailbox_id) AS MT ON MBT.mailbox_id = MT.mailbox_id %s %s", fields, input_conditional_clause, input_ordering_clause);
}
- EM_DEBUG_LOG_DEV ("query[%s]", sql_query_string);
+ EM_DEBUG_LOG_DEV("query[%s]", sql_query_string);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
("sqlite3_get_table failed [%d] [%s]", rc, sql_query_string))
- EM_DEBUG_LOG_DEV ("result count [%d]", count);
+ EM_DEBUG_LOG_DEV("result count [%d]", count);
if(count == 0) {
EM_DEBUG_LOG_SEC ("Can't find mailbox query[%s]", sql_query_string);
@@ -3063,15 +3216,14 @@ FINISH_OFF:
EMSTORAGE_FINISH_READ_TRANSACTION(input_transaction);
- sqlite3_db_release_memory(local_db_handle);
+// sqlite3_db_release_memory(local_db_handle);
EM_DEBUG_FUNC_END("error [%d]", error);
return error;
}
/* Query series --------------------------------------------------------------*/
-
-INTERNAL_FUNC int emstorage_check_duplicated_account(email_account_t* account, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_check_duplicated_account(char *multi_user_name, email_account_t* account, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int rc = -1, ret = false;
@@ -3088,7 +3240,7 @@ INTERNAL_FUNC int emstorage_check_duplicated_account(email_account_t* account, i
return false;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -3138,7 +3290,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_get_account_count(int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_account_count(char *multi_user_name, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -3155,7 +3307,7 @@ INTERNAL_FUNC int emstorage_get_account_count(int *count, int transaction, int *
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_account_tbl");
EM_DEBUG_LOG_SEC("SQL STMT [%s]", sql_query_string);
@@ -3193,8 +3345,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_tbl_t** account_list, int transaction, int with_password, int *err_code)
+INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_num, emstorage_account_tbl_t **account_list, int transaction, int with_password, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -3216,7 +3367,8 @@ INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_
return false;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
+
EMSTORAGE_START_READ_TRANSACTION(transaction);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
@@ -3414,8 +3566,8 @@ INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_
EM_SAFE_FREE(p_data_tbl[i].outgoing_server_password);
/* get password file name */
- error = _get_password_file_name (p_data_tbl[i].account_id,
- recv_password_file_name,
+ error = _get_password_file_name (multi_user_name, p_data_tbl[i].account_id,
+ recv_password_file_name,
send_password_file_name);
if (error != EMAIL_ERROR_NONE){
EM_DEBUG_EXCEPTION("_get_password_file_name error [%d]", error);
@@ -3477,10 +3629,15 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(int mailbox_id, char *server_mail_id, emstorage_mail_tbl_t** mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(char *multi_user_name,
+ char *server_mail_id,
+ int mailbox_id,
+ emstorage_mail_tbl_t **mail,
+ int transaction,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN_SEC("mailbox_id [%d], server_mail_id[%s], mail[%p], transaction[%d], err_code[%p]", mailbox_id, server_mail_id, mail, transaction, err_code);
+ EM_DEBUG_FUNC_BEGIN_SEC("mailbox_id [%d], server_mail_id[%s], mail[%p], transaction[%d], err_code[%p]",
+ mailbox_id, server_mail_id, mail, transaction, err_code);
int ret = false, error = EMAIL_ERROR_NONE, result_count;
char conditional_clause[QUERY_SIZE] = {0, };
@@ -3492,14 +3649,22 @@ INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(int mailbox_id, char *s
goto FINISH_OFF;
}
- if (mailbox_id == 0)
- SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE UPPER(server_mail_id) =UPPER('%s')", server_mail_id);
- else
- SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE UPPER(server_mail_id) =UPPER('%s') AND mailbox_id = %d", server_mail_id, mailbox_id);
+ SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE UPPER(server_mail_id) = UPPER('%s')", server_mail_id);
- EM_DEBUG_LOG("conditional_clause [%s]", conditional_clause);
+ if (mailbox_id > 0) {
+ SNPRINTF(conditional_clause + strlen(conditional_clause),
+ QUERY_SIZE - strlen(conditional_clause),
+ " AND mailbox_id = %d",
+ mailbox_id);
+ }
- if(!emstorage_query_mail_tbl(conditional_clause, transaction, &p_data_tbl, &result_count, &error)) {
+ EM_DEBUG_LOG("conditional_clause [%s]", conditional_clause);
+ if (!emstorage_query_mail_tbl(multi_user_name,
+ conditional_clause,
+ transaction,
+ &p_data_tbl,
+ &result_count,
+ &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -3507,6 +3672,7 @@ INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(int mailbox_id, char *s
ret = true;
FINISH_OFF:
+
if (ret == true)
*mail = p_data_tbl;
@@ -3664,7 +3830,7 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, int m
*
*
*/
-INTERNAL_FUNC int emstorage_get_mail_list(int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, int transaction, email_mail_list_item_t** mail_list, int *result_count, int *err_code)
+INTERNAL_FUNC int emstorage_get_mail_list(char *multi_user_name, int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, int transaction, email_mail_list_item_t** mail_list, int *result_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
EM_PROFILE_BEGIN(emstorage_get_mail_list_func);
@@ -3682,7 +3848,7 @@ INTERNAL_FUNC int emstorage_get_mail_list(int account_id, int mailbox_id, email_
EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
- if(!emstorage_query_mail_list(conditional_clause_string, transaction, mail_list, result_count, &error)) {
+ if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, transaction, mail_list, result_count, &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", error);
goto FINISH_OFF;
}
@@ -3704,7 +3870,7 @@ FINISH_OFF:
*
*
*/
-INTERNAL_FUNC int emstorage_get_mails(int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, int transaction, emstorage_mail_tbl_t** mail_list, int *result_count, int *err_code)
+INTERNAL_FUNC int emstorage_get_mails(char *multi_user_name, int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, int transaction, emstorage_mail_tbl_t** mail_list, int *result_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
EM_PROFILE_BEGIN(emStorageGetMails);
@@ -3727,7 +3893,7 @@ INTERNAL_FUNC int emstorage_get_mails(int account_id, int mailbox_id, email_emai
EM_DEBUG_LOG("conditional_clause_string [%s]", conditional_clause_string);
- if(!emstorage_query_mail_tbl(conditional_clause_string, transaction, &p_data_tbl, &count, &error)) {
+ if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause_string, transaction, &p_data_tbl, &count, &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -3758,7 +3924,7 @@ FINISH_OFF:
*
*
*/
-INTERNAL_FUNC int emstorage_get_searched_mail_list(int account_id, int mailbox_id, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, email_sort_type_t sorting, int transaction, email_mail_list_item_t** mail_list, int *result_count, int *err_code)
+INTERNAL_FUNC int emstorage_get_searched_mail_list(char *multi_user_name, int account_id, int mailbox_id, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, email_sort_type_t sorting, int transaction, email_mail_list_item_t **mail_list, int *result_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -3783,7 +3949,7 @@ INTERNAL_FUNC int emstorage_get_searched_mail_list(int account_id, int mailbox_i
EM_DEBUG_LOG("conditional_clause[%s]", conditional_clause);
- if(!emstorage_query_mail_list(conditional_clause, transaction, mail_list, result_count, &error)) {
+ if(!emstorage_query_mail_list(multi_user_name, conditional_clause, transaction, mail_list, result_count, &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", error);
goto FINISH_OFF;
}
@@ -3804,7 +3970,7 @@ FINISH_OFF:
}
-static int _get_password_file_name(int account_id, char *recv_password_file_name, char *send_password_file_name)
+static int _get_password_file_name(char *multi_user_name, int account_id, char *recv_password_file_name, char *send_password_file_name)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
@@ -3813,8 +3979,16 @@ static int _get_password_file_name(int account_id, char *recv_password_file_name
return EMAIL_ERROR_INVALID_PARAM;
}
- sprintf(recv_password_file_name, ".email_account_%d_recv", account_id);
- sprintf(send_password_file_name, ".email_account_%d_send", account_id);
+ EM_DEBUG_LOG("MULTI_USER_NAME : [%s]", multi_user_name);
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ sprintf(recv_password_file_name, ".email_account_%d_recv_%s", account_id, multi_user_name);
+ sprintf(send_password_file_name, ".email_account_%d_send_%s", account_id, multi_user_name);
+ } else {
+ sprintf(recv_password_file_name, ".email_account_%d_recv", account_id);
+ sprintf(send_password_file_name, ".email_account_%d_send", account_id);
+ }
+
EM_DEBUG_FUNC_END();
return EMAIL_ERROR_NONE;
}
@@ -3844,8 +4018,7 @@ static int _read_password_from_secure_storage(char *file_name, char **password)
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, emstorage_account_tbl_t **account, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_account_by_id(char *multi_user_name, int account_id, int pulloption, emstorage_account_tbl_t **account, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], pulloption[%d], account[%p], transaction[%d], err_code[%p]", account_id, pulloption, account, transaction, err_code);
@@ -3866,7 +4039,8 @@ INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, em
char recv_password_file_name[MAX_PW_FILE_NAME_LENGTH];
char send_password_file_name[MAX_PW_FILE_NAME_LENGTH];
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
EMSTORAGE_START_READ_TRANSACTION(transaction);
/* Make query string */
@@ -4028,7 +4202,7 @@ INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, em
if (pulloption & EMAIL_ACC_GET_OPT_PASSWORD) {
/* get password file name */
- if ((error = _get_password_file_name(p_data_tbl->account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
+ if ((error = _get_password_file_name(multi_user_name, p_data_tbl->account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_get_password_file_name failed [%d]", error);
goto FINISH_OFF;
}
@@ -4106,7 +4280,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_password_length_of_account(int account_id, int password_type, int *password_length, int *err_code)
+INTERNAL_FUNC int emstorage_get_password_length_of_account(char *multi_user_name, int account_id, int password_type, int *password_length, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], password_length[%p], err_code[%p]", account_id, password_length, err_code);
@@ -4125,7 +4299,7 @@ INTERNAL_FUNC int emstorage_get_password_length_of_account(int account_id, int p
/* get password file name */
- if ((error = _get_password_file_name(account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
+ if ((error = _get_password_file_name(multi_user_name, account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_get_password_file_name failed.");
goto FINISH_OFF;
}
@@ -4164,7 +4338,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_update_account_password(int input_account_id, char *input_incoming_server_password, char *input_outgoing_server_password)
+INTERNAL_FUNC int emstorage_update_account_password(char *multi_user_name, int input_account_id, char *input_incoming_server_password, char *input_outgoing_server_password)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d], input_incoming_server_password[%p], input_outgoing_server_password[%p]", input_account_id, input_incoming_server_password, input_outgoing_server_password);
@@ -4180,7 +4354,7 @@ INTERNAL_FUNC int emstorage_update_account_password(int input_account_id, char *
}
/* get password file name */
- if ((err = _get_password_file_name(input_account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
+ if ((err = _get_password_file_name(multi_user_name, input_account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_get_password_file_name failed.");
goto FINISH_OFF;
}
@@ -4225,7 +4399,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl_t* account_tbl, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_account(char *multi_user_name, int account_id, emstorage_account_tbl_t *account_tbl, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], account[%p], transaction[%d], err_code[%p]", account_id, account_tbl, transaction, err_code);
@@ -4242,8 +4416,9 @@ INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_account_tbl SET"
@@ -4310,6 +4485,7 @@ INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl
", certificate_path = ?"
", cipher_type = ?"
", digest_type = ?"
+ ", user_name = ?"
" WHERE account_id = ?");
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
@@ -4383,6 +4559,7 @@ INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl
_bind_stmt_field_data_string(hStmt, i++, account_tbl->certificate_path, 0, CERTIFICATE_PATH_LEN_IN_MAIL_ACCOUNT_TBL);
_bind_stmt_field_data_int(hStmt, i++, account_tbl->cipher_type);
_bind_stmt_field_data_int(hStmt, i++, account_tbl->digest_type);
+ _bind_stmt_field_data_string(hStmt, i++, account_tbl->user_name, 0, DISPLAY_NAME_FROM_LEN_IN_MAIL_ACCOUNT_TBL);
_bind_stmt_field_data_int(hStmt, i++, account_id);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
@@ -4400,7 +4577,7 @@ INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl
}
if (account_tbl->incoming_server_password || account_tbl->outgoing_server_password) {
- if((error = emstorage_update_account_password(account_id, account_tbl->incoming_server_password, account_tbl->outgoing_server_password)) != EMAIL_ERROR_NONE) {
+ if((error = emstorage_update_account_password(multi_user_name, account_id, account_tbl->incoming_server_password, account_tbl->outgoing_server_password)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_update_account_password failed [%d]", error);
goto FINISH_OFF;
}
@@ -4409,7 +4586,7 @@ INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -4431,7 +4608,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(int account_id, char *field_name, int value, int transaction)
+INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(char *multi_user_name, int account_id, char *field_name, int value, int transaction)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], field_name[%s], value[%d], transaction[%d]", account_id, field_name, value, transaction);
int error = EMAIL_ERROR_NONE;
@@ -4444,7 +4621,7 @@ INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(int account
return EMAIL_ERROR_INVALID_PARAM;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
/* Write query string */
SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_account_tbl SET %s = %d WHERE account_id = %d", field_name, value, account_id);
@@ -4452,7 +4629,7 @@ INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(int account
EM_DEBUG_LOG_SEC("sql_query_string [%s]", sql_query_string);
/* Execute query */
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
if (error != EMAIL_ERROR_NONE) {
@@ -4466,7 +4643,7 @@ INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(int account
FINISH_OFF:
result = (error == EMAIL_ERROR_NONE) ? true : false;
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, result, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, result, error);
if (error == EMAIL_ERROR_NONE) {
if (!emcore_notify_storage_event (NOTI_ACCOUNT_UPDATE, account_id, 0, field_name, value))
@@ -4476,7 +4653,7 @@ FINISH_OFF:
return error;
}
-INTERNAL_FUNC int emstorage_get_sync_status_of_account(int account_id, int *result_sync_status,int *err_code)
+INTERNAL_FUNC int emstorage_get_sync_status_of_account(char *multi_user_name, int account_id, int *result_sync_status,int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], result_sync_status [%p], err_code[%p]", account_id, result_sync_status, err_code);
@@ -4490,7 +4667,7 @@ INTERNAL_FUNC int emstorage_get_sync_status_of_account(int account_id, int *resu
int error = EMAIL_ERROR_NONE, rc, ret = false, sync_status, count, i, col_index;
char sql_query_string[QUERY_SIZE] = {0, };
char **result = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
if(account_id)
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT sync_status FROM mail_account_tbl WHERE account_id = %d", account_id);
@@ -4531,16 +4708,16 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, email_set_type_t set_operator, int sync_status, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_sync_status_of_account(char *multi_user_name, int account_id, email_set_type_t set_operator, int sync_status, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], set_operator[%d], sync_status [%d], transaction[%d], err_code[%p]", account_id, set_operator, sync_status, transaction, err_code);
int error = EMAIL_ERROR_NONE, rc, ret = false, set_value = sync_status, result_sync_status;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
if(set_operator != SET_TYPE_SET && account_id) {
- if(!emstorage_get_sync_status_of_account(account_id, &result_sync_status, &error)) {
+ if(!emstorage_get_sync_status_of_account(multi_user_name, account_id, &result_sync_status, &error)) {
EM_DEBUG_EXCEPTION("emstorage_get_sync_status_of_account failed [%d]", error);
if (err_code != NULL)
*err_code = error;
@@ -4561,7 +4738,7 @@ INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, email_
EM_DEBUG_LOG("set_value [%d]", set_value);
}
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
if(account_id)
SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_account_tbl SET sync_status = %d WHERE account_id = %d", set_value, account_id);
@@ -4587,7 +4764,7 @@ INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, email_
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (error == EMAIL_ERROR_NONE) {
if (!emcore_notify_storage_event (NOTI_ACCOUNT_UPDATE_SYNC_STATUS, account_id, set_value, NULL, 0))
@@ -4601,7 +4778,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account_tbl_t *account_tbl, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account[%p], transaction[%d], err_code[%p]", account_tbl, transaction, err_code);
@@ -4620,9 +4797,9 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, in
char recv_password_file_name[MAX_PW_FILE_NAME_LENGTH];
char send_password_file_name[MAX_PW_FILE_NAME_LENGTH];
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
char *sql = "SELECT max(rowid) FROM mail_account_tbl;";
char **result = NULL;
@@ -4638,7 +4815,7 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, in
account_tbl->account_id = rc;
- if ((error = _get_password_file_name(account_tbl->account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
+ if ((error = _get_password_file_name(multi_user_name, account_tbl->account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_get_password_file_name failed.");
goto FINISH_OFF;
}
@@ -4713,6 +4890,7 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, in
" , ? " /* display_content_status */
" , ? " /* default_ringtone_status */
" , ? " /* alert_ringtone_path */
+ " , ? " /* user_name */
") ");
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
@@ -4787,6 +4965,7 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, in
_bind_stmt_field_data_int(hStmt, i++, account_tbl->options.display_content_status);
_bind_stmt_field_data_int(hStmt, i++, account_tbl->options.default_ringtone_status);
_bind_stmt_field_data_string(hStmt, i++, account_tbl->options.alert_ringtone_path, 0, CERTIFICATE_PATH_LEN_IN_MAIL_ACCOUNT_TBL);
+ _bind_stmt_field_data_string(hStmt, i++, account_tbl->user_name, 0, CERTIFICATE_PATH_LEN_IN_MAIL_ACCOUNT_TBL);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
@@ -4798,9 +4977,8 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, in
/* save passwords to the secure storage */
EM_DEBUG_LOG_SEC("save to the secure storage : recv_file[%s], send_file[%s]", recv_password_file_name, send_password_file_name);
-
- error_from_ssm = ssa_put (recv_password_file_name,
- account_tbl->incoming_server_password,
+ error_from_ssm = ssa_put (recv_password_file_name,
+ account_tbl->incoming_server_password,
EM_SAFE_STRLEN(account_tbl->incoming_server_password)+1, /*must include null*/
ACCOUNT_PASSWORD_SS_GROUP_ID, NULL);
if (error_from_ssm < 0) {
@@ -4823,7 +5001,7 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t* account_tbl, in
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -4845,8 +5023,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_delete_account(int account_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_account(char *multi_user_name, int account_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], transaction[%d], err_code[%p]", account_id, transaction, err_code);
@@ -4861,8 +5038,10 @@ INTERNAL_FUNC int emstorage_delete_account(int account_id, int transaction, int
int rc = -1, ret = false;
int error = EMAIL_ERROR_NONE;
int ssa_err = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
/* TODO : delete password files - file names can be obtained from db or a rule that makes a name */
char sql_query_string[QUERY_SIZE] = {0, };
@@ -4870,7 +5049,7 @@ INTERNAL_FUNC int emstorage_delete_account(int account_id, int transaction, int
char send_password_file_name[MAX_PW_FILE_NAME_LENGTH];
/* get password file name */
- if ((error = _get_password_file_name(account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
+ if ((error = _get_password_file_name(multi_user_name, account_id, recv_password_file_name, send_password_file_name)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_get_password_file_name failed.");
goto FINISH_OFF;
}
@@ -4910,7 +5089,7 @@ INTERNAL_FUNC int emstorage_delete_account(int account_id, int transaction, int
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -4955,6 +5134,7 @@ INTERNAL_FUNC int emstorage_free_account(emstorage_account_tbl_t** account_list,
EM_SAFE_FREE(p[i].options.signature);
EM_SAFE_FREE(p[i].options.alert_ringtone_path);
EM_SAFE_FREE(p[i].certificate_path);
+ EM_SAFE_FREE(p[i].user_name);
}
EM_SAFE_FREE(p);
@@ -4971,7 +5151,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_count(int account_id, int local_yn, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_count(char *multi_user_name, int account_id, int local_yn, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], count[%p], transaction[%d], err_code[%p]", account_id, local_yn, count, transaction, err_code);
@@ -4987,7 +5167,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_count(int account_id, int local_yn, int
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_box_tbl WHERE account_id = %d AND local_yn = %d", account_id, local_yn);
@@ -5015,7 +5195,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_list(int account_id, int local_yn, email_mailbox_sort_type_t sort_type, int *select_num, emstorage_mailbox_tbl_t** mailbox_list, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_list(char *multi_user_name, int account_id, int local_yn, email_mailbox_sort_type_t sort_type, int *select_num, emstorage_mailbox_tbl_t** mailbox_list, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], select_num[%p], mailbox_list[%p], transaction[%d], err_code[%p]", account_id, local_yn, select_num, mailbox_list, transaction, err_code);
@@ -5065,7 +5245,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_list(int account_id, int local_yn, email
EM_DEBUG_LOG("ordering_clause_string[%s]", ordering_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, ordering_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, ordering_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -5081,7 +5261,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_list_ex(int account_id, int local_yn, int with_count, int *select_num, emstorage_mailbox_tbl_t** mailbox_list, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_list_ex(char *multi_user_name, int account_id, int local_yn, int with_count, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], select_num[%p], mailbox_list[%p], transaction[%d], err_code[%p]", account_id, local_yn, select_num, mailbox_list, transaction, err_code);
@@ -5111,11 +5291,14 @@ INTERNAL_FUNC int emstorage_get_mailbox_list_ex(int account_id, int local_yn, in
SNPRINTF(conditional_clause_string + EM_SAFE_STRLEN(conditional_clause_string), sizeof(conditional_clause_string)-(EM_SAFE_STRLEN(conditional_clause_string)+1), " AND account_id = %d ", account_id);
}
- SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY MBT.mailbox_name ");
+ SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY CASE WHEN MBT.mailbox_name"
+ " GLOB \'[][~`!@#$%%^&*()_-+=|\\{}:;<>,.?/ ]*\'"
+ " THEN 2 ELSE 1 END ASC,"
+ " MBT.mailbox_name COLLATE CONVERTUTF8 ASC ");
EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string);
EM_DEBUG_LOG("ordering_clause_string[%s]", ordering_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, ordering_clause_string, 1, 1, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if ((error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, ordering_clause_string, 1, 1, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -5131,7 +5314,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_child_mailbox_list(int account_id, char *parent_mailbox_name, int *select_num, emstorage_mailbox_tbl_t** mailbox_list, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_child_mailbox_list(char *multi_user_name, int account_id, char *parent_mailbox_name, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], parent_mailbox_name[%p], select_num[%p], mailbox_list[%p], transaction[%d], err_code[%p]", account_id, parent_mailbox_name, select_num, mailbox_list, transaction, err_code);
@@ -5149,7 +5332,7 @@ INTERNAL_FUNC int emstorage_get_child_mailbox_list(int account_id, char *parent_
sqlite3_snprintf(sizeof(conditional_clause_string), conditional_clause_string, "WHERE account_id = %d AND UPPER(mailbox_name) LIKE UPPER('%q%%')", account_id, parent_mailbox_name);
EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, " ORDER BY mailbox_name DESC ", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, " ORDER BY mailbox_name DESC ", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -5165,7 +5348,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(int account_id, int local_yn, int *select_num, emstorage_mailbox_tbl_t** mailbox_list, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(char *multi_user_name, int account_id, int local_yn, int *select_num, emstorage_mailbox_tbl_t** mailbox_list, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], select_num[%p], mailbox_list[%p], transaction[%d], err_code[%p]", account_id, local_yn, select_num, mailbox_list, transaction, err_code);
if (account_id < FIRST_ACCOUNT_ID || !select_num || !mailbox_list) {
@@ -5184,7 +5367,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(int account_id, int loc
SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND modifiable_yn = 0", account_id);
EM_DEBUG_LOG("conditional_clause_string [%s]", conditional_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, " ORDER BY mailbox_name", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, " ORDER BY mailbox_name", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -5200,7 +5383,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(int input_mailbox_id, int input_transaction)
+INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(char *multi_user_name, int input_mailbox_id, int input_transaction)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_transaction [%d]", input_mailbox_id, input_transaction);
@@ -5217,12 +5400,11 @@ INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(int input_mailbox_id
time(&current_time);
- local_db_handle = emstorage_get_db_connection();
-
- EMSTORAGE_START_WRITE_TRANSACTION(input_transaction, error);
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, input_transaction, error);
- SNPRINTF(sql_query_string, sizeof(sql_query_string),
- "UPDATE mail_box_tbl SET"
+ SNPRINTF(sql_query_string, sizeof(sql_query_string),
+ "UPDATE mail_box_tbl SET"
" last_sync_time = %d"
" WHERE mailbox_id = %d"
, (int)current_time
@@ -5240,13 +5422,13 @@ FINISH_OFF:
if(error == EMAIL_ERROR_NONE)
result_code = true;
- EMSTORAGE_FINISH_WRITE_TRANSACTION(input_transaction, result_code, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, input_transaction, result_code, error);
EM_DEBUG_FUNC_END("error [%d]", error);
return error;
}
-INTERNAL_FUNC int emstorage_get_mailbox_by_name(int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t** result_mailbox, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_by_name(char *multi_user_name, int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t **result_mailbox, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], local_yn[%d], mailbox_name[%s], result_mailbox[%p], transaction[%d], err_code[%p]", account_id, local_yn, mailbox_name, result_mailbox, transaction, err_code);
EM_PROFILE_BEGIN(profile_emstorage_get_mailbox_by_name);
@@ -5293,7 +5475,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_name(int account_id, int local_yn, ch
EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, "", 0, transaction, result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", 0, transaction, result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -5311,7 +5493,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, emstorage_mailbox_tbl_t **output_mailbox, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, emstorage_mailbox_tbl_t **output_mailbox, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_type[%d], output_mailbox[%p], transaction[%d], err_code[%p]", account_id, mailbox_type, output_mailbox, transaction, err_code);
@@ -5333,7 +5515,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(int account_id, email_ma
EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
- if( (error = emstorage_query_mailbox_tbl(conditional_clause_string, "", true, false, &result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+ if( (error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", true, false, &result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl error [%d]", error);
goto FINISH_OFF;
}
@@ -5351,7 +5533,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_by_id(int input_mailbox_id, emstorage_mailbox_tbl_t** output_mailbox)
+INTERNAL_FUNC int emstorage_get_mailbox_by_id(char *multi_user_name, int input_mailbox_id, emstorage_mailbox_tbl_t** output_mailbox)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], output_mailbox[%p]", input_mailbox_id, output_mailbox);
@@ -5368,7 +5550,9 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_id(int input_mailbox_id, emstorage_ma
EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
- if( (ret = emstorage_query_mailbox_tbl(conditional_clause_string, "", true, false, output_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+ if ((ret = emstorage_query_mailbox_tbl(multi_user_name,
+ conditional_clause_string,
+ "", true, false, output_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", ret);
goto FINISH_OFF;
}
@@ -5379,7 +5563,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_by_keyword(int account_id, char *keyword, emstorage_mailbox_tbl_t** result_mailbox, int * result_count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_by_keyword(char *multi_user_name, int account_id, char *keyword, emstorage_mailbox_tbl_t** result_mailbox, int * result_count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], keyword[%s], result_mailbox[%p], transaction[%d], err_code[%p]", account_id, keyword, result_mailbox, transaction, err_code);
@@ -5404,7 +5588,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_keyword(int account_id, char *keyword
EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
- if ((error = emstorage_query_mailbox_tbl(conditional_clause_string, "", 0, transaction, result_mailbox, result_count)) != EMAIL_ERROR_NONE) {
+ if ((error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", 0, transaction, result_mailbox, result_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -5420,7 +5604,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, int *mailbox_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, int *mailbox_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_type[%d], mailbox_id[%p], transaction[%d], err_code[%p]", account_id, mailbox_type, mailbox_id, transaction, err_code);
if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_id) {
@@ -5436,16 +5620,16 @@ INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(int account_id, email
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
/* Check whether the account exists. */
- if (!emstorage_get_account_by_id(account_id, EMAIL_ACC_GET_OPT_ACCOUNT_NAME, &account, true, &error) || !account) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, EMAIL_ACC_GET_OPT_ACCOUNT_NAME, &account, true, &error) || !account) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", error);
goto FINISH_OFF;
}
- if (account )
+ if (account)
emstorage_free_account(&account, 1, NULL);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT mailbox_id FROM mail_box_tbl WHERE account_id = %d AND mailbox_type = %d ", account_id, mailbox_type);
@@ -5490,7 +5674,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, char **mailbox_name, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, char **mailbox_name, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_type[%d], mailbox_name[%p], transaction[%d], err_code[%p]", account_id, mailbox_type, mailbox_name, transaction, err_code);
if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_name) {
@@ -5506,16 +5690,16 @@ INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(int account_id, ema
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
/* Check whether the account exists. */
- if (!emstorage_get_account_by_id(account_id, EMAIL_ACC_GET_OPT_ACCOUNT_NAME, &account, true, &error) || !account) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, EMAIL_ACC_GET_OPT_ACCOUNT_NAME, &account, true, &error) || !account) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", error);
goto FINISH_OFF;
}
- if (account )
+ if (account)
emstorage_free_account(&account, 1, NULL);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT mailbox_name FROM mail_box_tbl WHERE account_id = %d AND mailbox_type = %d ", account_id, mailbox_type);
@@ -5561,7 +5745,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(int account_id, int local_yn, char *mailbox_name, int modifiable_yn, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(char *multi_user_name, int account_id, int local_yn, char *mailbox_name, int modifiable_yn, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], local_yn [%d], mailbox_name [%p], modifiable_yn [%d], transaction [%d], err_code [%p]", account_id, local_yn, mailbox_name, modifiable_yn, transaction, err_code);
int ret = false;
@@ -5577,9 +5761,9 @@ INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(int account_id, int loc
}
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_box_tbl SET"
@@ -5601,7 +5785,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(int account_id, int loc
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
EM_SAFE_FREE(replaced_mailbox_name);
@@ -5613,25 +5797,32 @@ FINISH_OFF:
}
-
-INTERNAL_FUNC int emstorage_update_mailbox_total_count(int account_id, int input_mailbox_id, int total_count_on_server, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_mailbox_total_count(char *multi_user_name,
+ int account_id,
+ int input_mailbox_id,
+ int total_count_on_server,
+ int transaction,
+ int *err_code)
{
- EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], total_count_on_server[%d], transaction[%d], err_code[%p]", account_id, input_mailbox_id, total_count_on_server, transaction, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], total_count_on_server[%d], "
+ "transaction[%d], err_code[%p]",
+ account_id, input_mailbox_id, total_count_on_server, transaction, err_code);
+
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
if (account_id <= 0 || input_mailbox_id <= 0) {
EM_DEBUG_EXCEPTION("account_id[%d], input_mailbox_id[%d]", account_id, input_mailbox_id);
-
if (err_code != NULL)
*err_code = EMAIL_ERROR_INVALID_PARAM;
EM_DEBUG_FUNC_END("ret [%d]", ret);
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_box_tbl SET"
@@ -5652,7 +5843,8 @@ INTERNAL_FUNC int emstorage_update_mailbox_total_count(int account_id, int input
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -5662,8 +5854,7 @@ FINISH_OFF:
}
-
-INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, int input_mailbox_id, emstorage_mailbox_tbl_t* result_mailbox, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, emstorage_mailbox_tbl_t *result_mailbox, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], input_mailbox_id[%d], result_mailbox[%p], transaction[%d], err_code[%p]", account_id, local_yn, input_mailbox_id, result_mailbox, transaction, err_code);
@@ -5682,8 +5873,8 @@ INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, int inp
DB_STMT hStmt = NULL;
int i = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
if (local_yn != -1) {
SNPRINTF(sql_query_string, sizeof(sql_query_string),
@@ -5745,7 +5936,7 @@ INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, int inp
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -5762,8 +5953,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, int input_mailbox_id, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], local_yn[%d], input_mailbox_id[%d], new_mailbox_type[%d], transaction[%d], err_code[%p]", account_id, local_yn, input_mailbox_id, new_mailbox_type, transaction, err_code);
@@ -5779,8 +5969,8 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, in
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
EM_DEBUG_LOG("emstorage_update_mailbox_type");
@@ -5875,7 +6065,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, in
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt_box_tbl != NULL) {
rc = sqlite3_finalize(hStmt_box_tbl);
@@ -5900,7 +6090,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox, int transaction)
+INTERNAL_FUNC int emstorage_set_local_mailbox(char *multi_user_name, int input_mailbox_id, int input_is_local_mailbox, int transaction)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], new_mailbox_type[%d], transaction[%d], err_code[%p]", input_mailbox_id, input_is_local_mailbox, transaction);
@@ -5913,9 +6103,9 @@ INTERNAL_FUNC int emstorage_set_local_mailbox(int input_mailbox_id, int input_is
return EMAIL_ERROR_INVALID_PARAM;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
EM_DEBUG_LOG("emstorage_update_mailbox_type");
@@ -5955,7 +6145,7 @@ INTERNAL_FUNC int emstorage_set_local_mailbox(int input_mailbox_id, int input_is
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -5969,7 +6159,7 @@ FINISH_OFF:
return error;
}
-INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, char *input_field_name, int input_value, int transaction)
+INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(char *multi_user_name, int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, char *input_field_name, int input_value, int transaction)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d] input_mailbox_id_array[%p] input_mailbox_id_count[%d] input_field_name[%p] input_value[%d] err_code[%p]", input_account_id, input_mailbox_id_array, input_mailbox_id_count, input_field_name, input_value, transaction);
int i = 0;
@@ -5987,7 +6177,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(int input_ac
return EMAIL_ERROR_INVALID_PARAM;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
/* Generating mail id list string */
mailbox_id_string_buffer_length = MAILBOX_ID_STRING_LENGTH * input_mailbox_id_count;
@@ -6023,7 +6213,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(int input_ac
EM_DEBUG_LOG_SEC("sql_query_string [%s]", sql_query_string);
/* Execute query */
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, err);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, err);
err = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_exec_query_by_prepare_v2 failed:[%d]", err);
@@ -6036,7 +6226,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(int input_ac
result = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, result, err);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, result, err);
if (err == EMAIL_ERROR_NONE && parameter_string) {
if (!emcore_notify_storage_event (NOTI_MAILBOX_FIELD_UPDATE, input_account_id, 0, parameter_string, input_value))
@@ -6051,7 +6241,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t* mailbox_tbl, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *mailbox_tbl, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox_tbl[%p], transaction[%d], err_code[%p]", mailbox_tbl, transaction, err_code);
@@ -6067,8 +6257,8 @@ INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t* mailbox_tbl, in
char sql_query_string[QUERY_SIZE] = {0,};
char **result = NULL;
time_t current_time;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
EM_SAFE_STRCPY(sql_query_string, "SELECT max(rowid) FROM mail_box_tbl;");
@@ -6139,7 +6329,7 @@ INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t* mailbox_tbl, in
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -6161,7 +6351,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(int account_id, int modifiable_yn, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(char *multi_user_name, int account_id, int modifiable_yn, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], modifiable_yn[%d], err_code[%p]", account_id, modifiable_yn, err_code);
@@ -6176,8 +6366,8 @@ INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(int account_id, int mo
int rc, ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0,};
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_box_tbl SET modifiable_yn = %d WHERE account_id = %d", modifiable_yn, account_id);
@@ -6196,7 +6386,7 @@ INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(int account_id, int mo
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -6206,7 +6396,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_delete_mailbox(int account_id, int local_yn, int input_mailbox_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_mailbox(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], input_mailbox_id[%d], transaction[%d], err_code[%p]", account_id, local_yn, input_mailbox_id, transaction, err_code);
@@ -6221,8 +6411,8 @@ INTERNAL_FUNC int emstorage_delete_mailbox(int account_id, int local_yn, int inp
int rc, ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
if (local_yn == -1)
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_box_tbl WHERE account_id = %d ", account_id);
@@ -6250,7 +6440,7 @@ INTERNAL_FUNC int emstorage_delete_mailbox(int account_id, int local_yn, int inp
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if(error == EMAIL_ERROR_NONE) {
if (!emcore_notify_storage_event (NOTI_MAILBOX_DELETE, account_id, input_mailbox_id, NULL, 0))
@@ -6301,7 +6491,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_count_read_mail_uid(int account_id, char *mailbox_name, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_count_read_mail_uid(char *multi_user_name, int account_id, char *mailbox_name, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], count[%p], transaction[%d], err_code[%p]", account_id, mailbox_name , count, transaction, err_code);
@@ -6327,7 +6517,7 @@ INTERNAL_FUNC int emstorage_get_count_read_mail_uid(int account_id, char *mailbo
EM_DEBUG_LOG_SEC("replaced_mailbox_name : [%s]", replaced_mailbox_name);
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_read_mail_uid_tbl WHERE account_id = %d AND mailbox_name = '%s' ", account_id, replaced_mailbox_name);
EM_DEBUG_LOG_SEC(">>> SQL [ %s ] ", sql_query_string);
@@ -6355,9 +6545,7 @@ FINISH_OFF:
return ret;
}
-
-
-INTERNAL_FUNC int emstorage_check_read_mail_uid(int account_id, char *mailbox_name, char *uid, int *exist, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_check_read_mail_uid(char *multi_user_name, int account_id, char *mailbox_name, char *uid, int *exist, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], uid[%p], exist[%p], transaction[%d], err_code[%p]", account_id, mailbox_name , uid, exist, transaction, err_code);
@@ -6376,7 +6564,7 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(int account_id, char *mailbox_na
EM_DEBUG_LOG_SEC("replaced_mailbox_name : [%s]", replaced_mailbox_name);
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
if (mailbox_name) {
@@ -6420,7 +6608,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_downloaded_mail(int mail_id, emstorage_mail_tbl_t** mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_downloaded_mail(char *multi_user_name, int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], mail[%p], err_code[%p]", mail_id, mail, err_code);
@@ -6436,7 +6624,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail(int mail_id, emstorage_mail_tbl_
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_read_mail_uid_tbl WHERE local_uid = %d", mail_id);
@@ -6491,7 +6679,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, int mailbox_id, emstorage_read_mail_uid_tbl_t** read_mail_uid, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_downloaded_list(char *multi_user_name, int account_id, int mailbox_id, emstorage_read_mail_uid_tbl_t **read_mail_uid, int *count, int transaction, int *err_code)
{
EM_PROFILE_BEGIN(emStorageGetDownloadList);
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], read_mail_uid[%p], count[%p], transaction[%d], err_code[%p]", account_id, mailbox_id, read_mail_uid, count, transaction, err_code);
@@ -6512,7 +6700,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, int mailbox_id,
emstorage_read_mail_uid_tbl_t* p_data_tbl = NULL;
int i = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
if (mailbox_id)
@@ -6597,7 +6785,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_downloaded_mail_size(int account_id, char *mailbox_id, int local_uid, char *mailbox_name, char *uid, int *mail_size, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_downloaded_mail_size(char *multi_user_name, int account_id, char *mailbox_id, int local_uid, char *mailbox_name, char *uid, int *mail_size, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%p], locacal_uid[%d], mailbox_name[%p], uid[%p], mail_size[%p], transaction[%d], err_code[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, mail_size, transaction, err_code);
@@ -6615,7 +6803,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail_size(int account_id, char *mailb
char sql_query_string[QUERY_SIZE] = {0, };
char *replaced_mailbox_name = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
if (mailbox_name) {
@@ -6686,7 +6874,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* read_mail_uid, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage_read_mail_uid_tbl_t *read_mail_uid, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("read_mail_uid[%p], transaction[%d], err_code[%p]", read_mail_uid, transaction, err_code);
@@ -6702,8 +6890,8 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* r
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
char *sql = "SELECT max(rowid) FROM mail_read_mail_uid_tbl;";
char **result = NULL;
@@ -6766,7 +6954,7 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t* r
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -6783,7 +6971,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_BODY_SEARCH__
-INTERNAL_FUNC int emstorage_add_mail_text(emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_mail_text(char *multi_user_name, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_text[%p], transaction[%d], err_code[%p]", mail_text, transaction, err_code);
@@ -6799,8 +6987,8 @@ INTERNAL_FUNC int emstorage_add_mail_text(emstorage_mail_text_tbl_t* mail_text,
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
char *sql = "SELECT max(rowid) FROM mail_text_tbl;";
char **result = NULL;
@@ -6844,7 +7032,7 @@ INTERNAL_FUNC int emstorage_add_mail_text(emstorage_mail_text_tbl_t* mail_text,
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -6861,7 +7049,7 @@ FINISH_OFF:
}
#endif
-INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, int mailbox_id, int local_uid, char *mailbox_name, char *uid, emstorage_read_mail_uid_tbl_t* read_mail_uid, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_change_read_mail_uid(char *multi_user_name, int account_id, int mailbox_id, int local_uid, char *mailbox_name, char *uid, emstorage_read_mail_uid_tbl_t* read_mail_uid, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], local_uid[%d], mailbox_name[%p], uid[%p], read_mail_uid[%p], transaction[%d], err_code[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, read_mail_uid, transaction, err_code);
@@ -6878,9 +7066,9 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, int mailbox_id,
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_read_mail_uid_tbl SET"
@@ -6929,7 +7117,7 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, int mailbox_id,
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -6945,7 +7133,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_remove_downloaded_mail(int account_id, char *mailbox_name, char *uid, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_remove_downloaded_mail(char *multi_user_name, int account_id, char *mailbox_name, char *uid, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], mailbox_name[%s], uid[%s], transaction[%d], err_code[%p]", account_id, mailbox_name, uid, transaction, err_code);
@@ -6961,9 +7149,9 @@ INTERNAL_FUNC int emstorage_remove_downloaded_mail(int account_id, char *mailbox
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
char *replaced_mailbox_name = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_read_mail_uid_tbl WHERE account_id = %d ", account_id);
@@ -6990,7 +7178,7 @@ INTERNAL_FUNC int emstorage_remove_downloaded_mail(int account_id, char *mailbox
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
EM_SAFE_FREE(replaced_mailbox_name);
@@ -7037,7 +7225,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(int account_id, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(char *multi_user_name, int account_id, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], count[%p], transaction[%d], err_code[%p]", count, transaction, err_code);
@@ -7053,7 +7241,7 @@ INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(int account_id, int *co
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
if (account_id != ALL_ACCOUNT)
@@ -7082,7 +7270,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, int *select_num, int *is_completed, emstorage_rule_tbl_t** rule_list, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_rule(char *multi_user_name, int account_id, int type, int start_idx, int *select_num, int *is_completed, emstorage_rule_tbl_t** rule_list, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], type[%d], start_idx[%d], select_num[%p], is_completed[%p], rule_list[%p], transaction[%d], err_code[%p]", account_id, type, start_idx, select_num, is_completed, rule_list, transaction, err_code);
@@ -7104,7 +7292,7 @@ INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, in
int rc;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
if (account_id != ALL_ACCOUNT) {
@@ -7201,25 +7389,30 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_rule_by_id(int rule_id, emstorage_rule_tbl_t** rule, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_rule_by_id(char *multi_user_name, int rule_id, emstorage_rule_tbl_t** rule, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("rule_id[%d], rule[%p], transaction[%d], err_code[%p]", rule_id, rule, transaction, err_code);
+ int error = EMAIL_ERROR_NONE;
+ int ret = false;
+ DB_STMT hStmt = NULL;
+
+ if (rule_id <= 0) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ error = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
if (!rule) {
EM_DEBUG_EXCEPTION("rule_id[%d], rule[%p]", rule_id, rule);
-
- if (err_code != NULL)
- *err_code = EMAIL_ERROR_INVALID_PARAM;
- return false;
+ error = EMAIL_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
}
emstorage_rule_tbl_t* p_data_tbl = NULL;
- int rc, ret = false;
- int error = EMAIL_ERROR_NONE;
+ int rc;
- DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_rule_tbl WHERE rule_id = %d", rule_id);
@@ -7260,6 +7453,7 @@ INTERNAL_FUNC int emstorage_get_rule_by_id(int rule_id, emstorage_rule_tbl_t** r
ret = true;
FINISH_OFF:
+
if (ret == true)
*rule = p_data_tbl;
@@ -7280,7 +7474,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_change_rule(int rule_id, emstorage_rule_tbl_t* new_rule, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_change_rule(char *multi_user_name, int rule_id, emstorage_rule_tbl_t* new_rule, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("rule_id[%d], new_rule[%p], transaction[%d], err_code[%p]", rule_id, new_rule, transaction, err_code);
@@ -7297,8 +7491,8 @@ INTERNAL_FUNC int emstorage_change_rule(int rule_id, emstorage_rule_tbl_t* new_r
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_rule_tbl SET"
@@ -7342,7 +7536,7 @@ INTERNAL_FUNC int emstorage_change_rule(int rule_id, emstorage_rule_tbl_t* new_r
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -7358,7 +7552,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_find_rule(emstorage_rule_tbl_t* rule, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_find_rule(char *multi_user_name, emstorage_rule_tbl_t* rule, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("rule[%p], transaction[%d], err_code[%p]", rule, transaction, err_code);
@@ -7375,7 +7569,7 @@ INTERNAL_FUNC int emstorage_find_rule(emstorage_rule_tbl_t* rule, int transactio
int rc = 0;
int ret = false;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
switch(rule->action_type) {
@@ -7445,7 +7639,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t* rule, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_rule(char *multi_user_name, emstorage_rule_tbl_t* rule, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("rule[%p], transaction[%d], err_code[%p]", rule, transaction, err_code);
@@ -7461,10 +7655,9 @@ INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t* rule, int transaction
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- sqlite3 *local_db_handle = emstorage_get_db_connection();
-
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
char *sql;
char **result;
@@ -7521,7 +7714,7 @@ INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t* rule, int transaction
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -7537,7 +7730,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_rule(int rule_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_rule(char *multi_user_name, int rule_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("rule_id[%d], transaction[%d], err_code[%p]", rule_id, transaction, err_code);
@@ -7552,8 +7745,8 @@ INTERNAL_FUNC int emstorage_delete_rule(int rule_id, int transaction, int *err_c
int rc, ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_rule_tbl WHERE rule_id = %d", rule_id);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -7573,7 +7766,7 @@ INTERNAL_FUNC int emstorage_delete_rule(int rule_id, int transaction, int *err_c
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -7615,7 +7808,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mail_count(int account_id, int mailbox_id, int *total, int *unseen, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mail_count(char *multi_user_name, int account_id, int mailbox_id, int *total, int *unseen, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], total[%p], unseen[%p], transaction[%d], err_code[%p]", account_id, mailbox_id, total, unseen, transaction, err_code);
@@ -7633,7 +7826,7 @@ INTERNAL_FUNC int emstorage_get_mail_count(int account_id, int mailbox_id, int *
char *replaced_mailbox_name = NULL;
memset(&sql_query_string, 0x00, sizeof(sql_query_string));
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
if (total) {
@@ -7716,7 +7909,7 @@ FINISH_OFF2:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorage_mail_tbl_t** mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail_id, int type, emstorage_mail_tbl_t** mail, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], type[%d], mail[%p], transaction[%d], err_code[%p]", mail_id, type, mail, transaction, err_code);
@@ -7744,28 +7937,52 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag
int rc, ret = false;
int error = EMAIL_ERROR_NONE;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
switch (type) {
case RETRIEVE_SUMMARY:
SNPRINTF(sql_query_string, sizeof(sql_query_string),
- "SELECT account_id, mail_id, mailbox_id, server_mail_status, server_mailbox_name, server_mail_id, file_path_plain, file_path_html, flags_seen_field, save_status, lock_status, thread_id, thread_item_count FROM mail_tbl WHERE mail_id = %d", mail_id);
+ "SELECT account_id, "
+ "mail_id, "
+ "mailbox_id, "
+ "server_mail_status, "
+ "server_mailbox_name, "
+ "server_mail_id, "
+ "file_path_plain, "
+ "file_path_html,"
+ "file_path_mime_entity, "
+ "flags_seen_field, "
+ "save_status, "
+ "lock_status, "
+ "thread_id, "
+ "thread_item_count "
+ "FROM mail_tbl WHERE mail_id = %d", mail_id);
break;
case RETRIEVE_FIELDS_FOR_DELETE:
SNPRINTF(sql_query_string, sizeof(sql_query_string),
- "SELECT account_id, mail_id, server_mail_status, server_mailbox_name, server_mail_id FROM mail_tbl WHERE mail_id = %d", mail_id);
+ "SELECT account_id, "
+ "mail_id, "
+ "server_mail_status, "
+ "server_mailbox_name, "
+ "server_mail_id "
+ "FROM mail_tbl WHERE mail_id = %d", mail_id);
break;
case RETRIEVE_ACCOUNT:
SNPRINTF(sql_query_string, sizeof(sql_query_string),
- "SELECT account_id FROM mail_tbl WHERE mail_id = %d", mail_id);
+ "SELECT account_id "
+ "FROM mail_tbl WHERE mail_id = %d", mail_id);
break;
case RETRIEVE_FLAG:
SNPRINTF(sql_query_string, sizeof(sql_query_string),
- "SELECT account_id, flags_seen_field, thread_id, mailbox_id FROM mail_tbl WHERE mail_id = %d", mail_id);
+ "SELECT account_id, "
+ "flags_seen_field, "
+ "thread_id, "
+ "mailbox_id "
+ "FROM mail_tbl WHERE mail_id = %d", mail_id);
break;
default :
@@ -7800,6 +8017,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag
_get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mail_id), 0, col_index++);
_get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_plain), 0, col_index++);
_get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_html), 0, col_index++);
+ _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_mime_entity), 0, col_index++);
_get_stmt_field_data_char(hStmt, &(p_data_tbl->flags_seen_field), col_index++);
_get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->save_status), col_index++);
_get_stmt_field_data_int(hStmt, &(p_data_tbl->lock_status), col_index++);
@@ -7853,7 +8071,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], int number_of_mails, int type, emstorage_mail_tbl_t** mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_name, int mail_ids[], int number_of_mails, int type, emstorage_mail_tbl_t** mail, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_ids[%p], number_of_mails [%d], type[%d], mail[%p], transaction[%d], err_code[%p]", mail_ids, number_of_mails, type, mail, transaction, err_code);
@@ -7889,20 +8107,40 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i
return false;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
switch (type) {
case RETRIEVE_SUMMARY:
cur_sql_query_string = SNPRINTF(sql_query_string, query_string_length,
- "SELECT account_id, mail_id, mailbox_id, server_mail_status, server_mailbox_name, server_mail_id, file_path_plain, file_path_html, subject, flags_seen_field, save_status, lock_status, thread_id, thread_item_count FROM mail_tbl WHERE mail_id in (");
- field_count = 14;
+ "SELECT account_id, "
+ "mail_id, "
+ "mailbox_id, "
+ "server_mail_status, "
+ "server_mailbox_name, "
+ "server_mail_id, "
+ "file_path_plain, "
+ "file_path_html, "
+ "file_path_mime_entity, "
+ "subject, "
+ "flags_seen_field, "
+ "save_status, "
+ "lock_status, "
+ "thread_id, "
+ "thread_item_count "
+ "FROM mail_tbl WHERE mail_id in (");
+ field_count = 15;
break;
case RETRIEVE_FIELDS_FOR_DELETE:
cur_sql_query_string = SNPRINTF(sql_query_string, query_string_length,
- "SELECT account_id, mail_id, server_mail_status, server_mailbox_name, server_mail_id FROM mail_tbl WHERE mail_id in (");
+ "SELECT account_id, "
+ "mail_id, "
+ "server_mail_status, "
+ "server_mailbox_name, "
+ "server_mail_id "
+ "FROM mail_tbl WHERE mail_id in (");
field_count = 5;
break;
@@ -7914,7 +8152,12 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i
case RETRIEVE_FLAG:
cur_sql_query_string = SNPRINTF(sql_query_string, query_string_length,
- "SELECT account_id, mail_id, mailbox_id, flags_seen_field, thread_id FROM mail_tbl WHERE mail_id in (");
+ "SELECT account_id, "
+ "mail_id, "
+ "mailbox_id, "
+ "flags_seen_field, "
+ "thread_id "
+ "FROM mail_tbl WHERE mail_id in (");
field_count = 5;
break;
@@ -7925,7 +8168,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i
}
for(i = 0; i < number_of_mails; i++)
- cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, QUERY_SIZE, "%d,", mail_ids[i]);
+ cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, query_string_length, "%d,", mail_ids[i]);
sql_query_string[EM_SAFE_STRLEN(sql_query_string) - 1] = ')';
EM_DEBUG_LOG_SEC("Query [%s], Length [%d]", sql_query_string, EM_SAFE_STRLEN(sql_query_string));
@@ -7964,6 +8207,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], i
_get_table_field_data_string(result, &(p_data_tbl[i].server_mail_id), 0, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].file_path_plain), 0, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].file_path_html), 0, col_index++);
+ _get_table_field_data_string(result, &(p_data_tbl[i].file_path_mime_entity), 0, col_index++);
_get_table_field_data_string(result, &(p_data_tbl[i].subject), 0, col_index++);
_get_table_field_data_char(result, &(p_data_tbl[i].flags_seen_field), col_index++);
_get_table_field_data_int(result, (int*)&(p_data_tbl[i].save_status), col_index++);
@@ -8016,7 +8260,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mail_by_id(int mail_id, emstorage_mail_tbl_t** mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mail_by_id(char *multi_user_name, int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], mail[%p], transaction[%d], err_code[%p]", mail_id, mail, transaction, err_code);
@@ -8034,7 +8278,7 @@ INTERNAL_FUNC int emstorage_get_mail_by_id(int mail_id, emstorage_mail_tbl_t** m
SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE mail_id = %d", mail_id);
EM_DEBUG_LOG_SEC("query = [%s]", conditional_clause);
- if(!emstorage_query_mail_tbl(conditional_clause, transaction, &p_data_tbl, &count, &error)) {
+ if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl [%d]", error);
goto FINISH_OFF;
}
@@ -8055,7 +8299,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_BODY_SEARCH__
-INTERNAL_FUNC int emstorage_get_mail_text_by_id(int mail_id, emstorage_mail_text_tbl_t **mail_text, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mail_text_by_id(char *multi_user_name, int mail_id, emstorage_mail_text_tbl_t **mail_text, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], mail_text[%p], transaction[%d], err_code[%p]", mail_id, mail_text, transaction, err_code);
@@ -8075,7 +8319,7 @@ INTERNAL_FUNC int emstorage_get_mail_text_by_id(int mail_id, emstorage_mail_text
SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE mail_id = %d", mail_id);
EM_DEBUG_LOG_SEC("query = [%s]", conditional_clause);
- if(!emstorage_query_mail_text_tbl(conditional_clause, transaction, &p_data_tbl, &count, &error)) {
+ if(!emstorage_query_mail_text_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl [%d]", error);
goto FINISH_OFF;
}
@@ -8096,9 +8340,20 @@ FINISH_OFF:
}
#endif
-INTERNAL_FUNC int emstorage_mail_search_start(emstorage_search_filter_t* search, int account_id, int mailbox_id, int sorting, int *search_handle, int *searched, int transaction, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("search[%p], account_id[%d], mailbox_id[%d], sorting[%d], search_handle[%p], searched[%p], transaction[%d], err_code[%p]", search, account_id, mailbox_id, sorting, search_handle, searched, transaction, err_code);
+INTERNAL_FUNC int emstorage_mail_search_start(char *multi_user_name,
+ emstorage_search_filter_t *search,
+ int account_id,
+ int mailbox_id,
+ int sorting,
+ DB_STMT *search_handle,
+ int *searched,
+ int transaction,
+ int *err_code)
+{
+ EM_DEBUG_FUNC_BEGIN("search[%p], account_id[%d], mailbox_id[%d], sorting[%d], "
+ "search_handle[%p], searched[%p], transaction[%d], err_code[%p]",
+ search, account_id, mailbox_id, sorting, search_handle,
+ searched, transaction, err_code);
if (!search_handle || !searched) {
if (err_code != NULL)
@@ -8115,7 +8370,7 @@ INTERNAL_FUNC int emstorage_mail_search_start(emstorage_search_filter_t* search,
int rc, ret = false;
int and = false, mail_count = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_tbl");
@@ -8180,7 +8435,7 @@ INTERNAL_FUNC int emstorage_mail_search_start(emstorage_search_filter_t* search,
FINISH_OFF:
if (ret == true) {
- *search_handle = (int)hStmt;
+ *search_handle = hStmt;
*searched = mail_count;
EM_DEBUG_LOG("mail_count [%d]", mail_count);
}
@@ -8203,7 +8458,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail_field_type_t type, void** data, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_mail_field_type_t type, void** data, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("search_handle[%d], type[%d], data[%p], transaction[%d], err_code[%p]", search_handle, type, data, transaction, err_code);
@@ -8216,7 +8471,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail
}
emstorage_mail_tbl_t* p_data_tbl = NULL;
- DB_STMT hStmt = (DB_STMT)search_handle;
+ DB_STMT hStmt = search_handle;
int rc, ret = false;
int error = EMAIL_ERROR_NONE;
@@ -8352,7 +8607,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_mail_search_end(int search_handle, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_mail_search_end(DB_STMT search_handle, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("search_handle[%d], transaction[%d], err_code[%p]", search_handle, transaction, err_code);
@@ -8365,8 +8620,7 @@ INTERNAL_FUNC int emstorage_mail_search_end(int search_handle, int transaction,
goto FINISH_OFF;
}
- DB_STMT hStmt = (DB_STMT)search_handle;
-
+ DB_STMT hStmt = search_handle;
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -8386,7 +8640,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_change_mail(char *multi_user_name, int mail_id, emstorage_mail_tbl_t *mail, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], mail[%p], transaction[%d], err_code[%p]", mail_id, mail, transaction, err_code);
@@ -8404,10 +8658,10 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail,
int ret = false;
int error = EMAIL_ERROR_NONE;
int i = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
char mailbox_id_param_string[10] = {0,};
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_tbl SET"
@@ -8429,6 +8683,7 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail,
", body_download_status = ?"
", file_path_plain = ?"
", file_path_html = ?"
+ ", file_path_mime_entity = ?"
", date_time = ?"
", flags_seen_field = ?"
", flags_deleted_field = ?"
@@ -8479,6 +8734,7 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail,
_bind_stmt_field_data_int (hStmt, i++, mail->body_download_status);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL);
+ _bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_int (hStmt, i++, mail->date_time);
_bind_stmt_field_data_char (hStmt, i++, mail->flags_seen_field);
_bind_stmt_field_data_char (hStmt, i++, mail->flags_deleted_field);
@@ -8518,7 +8774,7 @@ INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t* mail,
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -8546,7 +8802,7 @@ FINISH_OFF:
*
*
**/
-INTERNAL_FUNC int emstorage_clean_save_status(int save_status, int *err_code)
+INTERNAL_FUNC int emstorage_clean_save_status(char *multi_user_name, int save_status, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("save_status[%d], err_code[%p]", save_status, err_code);
@@ -8556,7 +8812,7 @@ INTERNAL_FUNC int emstorage_clean_save_status(int save_status, int *err_code)
int error = EMAIL_ERROR_NONE;
int rc = 0;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET save_status = %d WHERE save_status = %d", save_status, EMAIL_MAIL_STATUS_SENDING);
@@ -8585,18 +8841,20 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id, int mail_ids[], int mail_ids_count, char *field_name, int value, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(char *multi_user_name, int account_id, int mail_ids[], int mail_ids_count, char *field_name, int value, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id [%d], mail_ids[%p], mail_ids_count[%d], field_name[%s], value[%d], transaction[%d], err_code[%p]", account_id, mail_ids, mail_ids_count, field_name, value, transaction, err_code);
int i = 0;
int error = EMAIL_ERROR_NONE;
int ret = false;
+ int query_size = 0;
int cur_mail_id_string = 0;
int mail_id_string_buffer_length = 0;
- char sql_query_string[QUERY_SIZE] = {0, };
+ int parameter_string_length = 0;
+ char *sql_query_string = NULL;
char *mail_id_string_buffer = NULL;
char *parameter_string = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
email_mail_attribute_type target_mail_attribute_type = 0;
if (!mail_ids || !field_name || account_id == 0) {
@@ -8632,7 +8890,8 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id
mail_id_string_buffer[EM_SAFE_STRLEN(mail_id_string_buffer) - 1] = NULL_CHAR;
/* Generating notification parameter string */
- parameter_string = em_malloc(mail_id_string_buffer_length + EM_SAFE_STRLEN(field_name) + 2);
+ parameter_string_length = mail_id_string_buffer_length + EM_SAFE_STRLEN(field_name) + 2;
+ parameter_string = em_malloc(parameter_string_length);
if(!parameter_string) {
EM_DEBUG_EXCEPTION("em_malloc failed");
@@ -8642,15 +8901,22 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id
return false;
}
- SNPRINTF(parameter_string, QUERY_SIZE, "%s%c%s", field_name, 0x01, mail_id_string_buffer);
+ SNPRINTF(parameter_string, parameter_string_length, "%s%c%s", field_name, 0x01, mail_id_string_buffer);
+ query_size = EM_SAFE_STRLEN(mail_id_string_buffer) + EM_SAFE_STRLEN(field_name) + 250;
+ sql_query_string = em_malloc(query_size);
+ if (sql_query_string == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
/* Write query string */
- SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_tbl SET %s = %d WHERE mail_id in (%s) AND account_id = %d", field_name, value, mail_id_string_buffer, account_id);
+ SNPRINTF(sql_query_string, query_size, "UPDATE mail_tbl SET %s = %d WHERE mail_id in (%s) AND account_id = %d", field_name, value, mail_id_string_buffer, account_id);
EM_DEBUG_LOG_DEV ("sql_query_string [%s]", sql_query_string);
/* Execute query */
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
if (error != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_exec_query_by_prepare_v2 failed:[%d]", error);
@@ -8663,7 +8929,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (error == EMAIL_ERROR_NONE && parameter_string) {
if (!emcore_notify_storage_event (NOTI_MAIL_FIELD_UPDATE, account_id, target_mail_attribute_type, parameter_string, value))
@@ -8672,6 +8938,8 @@ FINISH_OFF:
EM_SAFE_FREE(mail_id_string_buffer);
EM_SAFE_FREE(parameter_string);
+ EM_SAFE_FREE(sql_query_string);
+
if (err_code != NULL)
*err_code = error;
@@ -8681,7 +8949,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_BODY_SEARCH__
-INTERNAL_FUNC int emstorage_change_mail_text_field(int mail_id, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_change_mail_text_field(char *multi_user_name, int mail_id, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], mail_text[%p], transaction[%d], err_code[%p]", mail_id, mail_text, transaction, err_code);
@@ -8700,8 +8968,8 @@ INTERNAL_FUNC int emstorage_change_mail_text_field(int mail_id, emstorage_mail_t
int i = 0;
int rc = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_text_tbl SET"
@@ -8733,7 +9001,7 @@ INTERNAL_FUNC int emstorage_change_mail_text_field(int mail_id, emstorage_mail_t
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -8752,7 +9020,7 @@ FINISH_OFF:
}
#endif
-INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_type_t type, emstorage_mail_tbl_t* mail, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id, email_mail_change_type_t type, emstorage_mail_tbl_t *mail, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], type[%d], mail[%p], transaction[%d], err_code[%p]", mail_id, type, mail, transaction, err_code);
@@ -8774,9 +9042,9 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
return false;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
switch (type) {
case APPEND_BODY:
@@ -8785,6 +9053,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
" body_download_status = ?"
", file_path_plain = ?"
", file_path_html = ?"
+ ", file_path_mime_entity = ?"
", flags_seen_field = ?"
", flags_deleted_field = ?"
", flags_flagged_field = ?"
@@ -8811,6 +9080,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
_bind_stmt_field_data_int(hStmt, i++, mail->body_download_status);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL);
+ _bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_int(hStmt, i++, mail->flags_seen_field);
_bind_stmt_field_data_int(hStmt, i++, mail->flags_deleted_field);
_bind_stmt_field_data_int(hStmt, i++, mail->flags_flagged_field);
@@ -8831,7 +9101,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
int err;
emstorage_mailbox_tbl_t *mailbox_tbl;
- if ((err = emstorage_get_mailbox_by_id(mail->mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, mail->mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -9020,13 +9290,11 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
break;
case UPDATE_DATETIME: {
- time_t now = time(NULL);
-
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_tbl SET"
- " date_time = '%d'"
+ " date_time = '%ld'"
" WHERE mail_id = %d AND account_id != 0"
- , (int)now
+ , mail->date_time
, mail_id);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
@@ -9097,6 +9365,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
" body_download_status = ?"
", file_path_plain = ?"
", file_path_html = ?"
+ ", file_path_mime_entity = ?"
", attachment_count = ?"
", inline_content_count = ?"
", preview_text = ?"
@@ -9114,6 +9383,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
_bind_stmt_field_data_int(hStmt, i++, mail->body_download_status);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL);
+ _bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_int(hStmt, i++, mail->attachment_count);
_bind_stmt_field_data_int(hStmt, i++, mail->inline_content_count);
_bind_stmt_field_data_nstring(hStmt, i++, (char *)mail->preview_text, 0, PREVIEWBODY_LEN_IN_MAIL_TBL);
@@ -9167,7 +9437,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
if (mail->account_id == 0) {
emstorage_mail_tbl_t* mail_for_account_tbl = NULL;
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_ACCOUNT, &mail_for_account_tbl, true, &error) || !mail_for_account_tbl) {
+ if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_ACCOUNT, &mail_for_account_tbl, true, &error) || !mail_for_account_tbl) {
EM_DEBUG_EXCEPTION ("emstorage_get_mail_field_by_id error [%d]", error);
goto FINISH_OFF;
}
@@ -9179,7 +9449,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -9190,7 +9460,7 @@ FINISH_OFF:
hStmt = NULL;
}
if (error == EMAIL_ERROR_NONE && move_flag != 1 && transaction) {
- if (!emstorage_get_mailbox_id_by_mailbox_type( mail->account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &mailbox_id, false, &error))
+ if (!emstorage_get_mailbox_id_by_mailbox_type(multi_user_name, mail->account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &mailbox_id, false, &error))
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_id_by_mailbox_type error [%d]", error);
if (mail->mailbox_id == mailbox_id) {
@@ -9211,7 +9481,8 @@ FINISH_OFF:
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
-INTERNAL_FUNC int emstorage_increase_mail_id(int *mail_id, int transaction, int *err_code)
+
+INTERNAL_FUNC int emstorage_increase_mail_id(char *multi_user_name, int *mail_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%p], transaction[%d], err_code[%p]", mail_id, transaction, err_code);
@@ -9223,14 +9494,14 @@ INTERNAL_FUNC int emstorage_increase_mail_id(int *mail_id, int transaction, int
char **result = NULL;
#ifdef __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__
- _timedlock_shm_mutex(&mapped_for_generating_mail_id, 2);
+ _timedlock_shm_mutex(mapped_for_generating_mail_id, 2);
#endif /* __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ */
ret = vconf_get_int(VCONF_KEY_LATEST_MAIL_ID, &latest_mail_id);
if (ret < 0 || latest_mail_id == 0) {
EM_DEBUG_LOG("vconf_get_int() failed [%d] or latest_mail_id is zero", ret);
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
@@ -9252,7 +9523,7 @@ INTERNAL_FUNC int emstorage_increase_mail_id(int *mail_id, int transaction, int
*mail_id = latest_mail_id;
#ifdef __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__
- _unlockshm_mutex(&mapped_for_generating_mail_id);
+ _unlockshm_mutex(mapped_for_generating_mail_id);
#endif /* __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ */
ret = true;
@@ -9266,8 +9537,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int get_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t *mail_tbl_data, int get_id, int transaction, int *err_code)
{
EM_PROFILE_BEGIN(profile_emstorage_add_mail);
EM_DEBUG_FUNC_BEGIN("mail_tbl_data[%p], get_id[%d], transaction[%d], err_code[%p]", mail_tbl_data, get_id, transaction, err_code);
@@ -9283,9 +9553,10 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
DB_STMT hStmt = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
if (get_id) {
/* increase unique id */
@@ -9383,6 +9654,7 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge
", ?" /* default charset */
", ?" /* eas_data_length */
", ?" /* eas_data */
+ ", ?" /* user_name */
")");
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle,
@@ -9392,8 +9664,8 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge
NULL),
rc);
if (rc != SQLITE_OK) {
- EM_DEBUG_EXCEPTION ("sqlite3_prepare error [%d] [%s] SQL(%s) ",
- sql_query_string, rc, sqlite3_errmsg(local_db_handle));
+ EM_DEBUG_EXCEPTION ("sqlite3_prepare error [%d] [%s] SQL(%s) ",
+ rc, sql_query_string, sqlite3_errmsg(local_db_handle));
error = EMAIL_ERROR_DB_FAILURE;
goto FINISH_OFF;
}
@@ -9463,6 +9735,7 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge
_bind_stmt_field_data_string(hStmt, DEFAULT_CHARSET_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->default_charset, 0, TEXT_2_LEN_IN_MAIL_TBL);
_bind_stmt_field_data_int (hStmt, EAS_DATA_LENGTH_IDX_IN_MAIL_TBL, mail_tbl_data->eas_data_length);
_bind_stmt_field_data_blob (hStmt, EAS_DATA_IDX_IN_MAIL_TBL, (void*)mail_tbl_data->eas_data, mail_tbl_data->eas_data_length);
+ _bind_stmt_field_data_string(hStmt, USER_NAME_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->user_name, 0, TEXT_2_LEN_IN_MAIL_TBL);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
if (rc == SQLITE_FULL) {
@@ -9478,7 +9751,7 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail_tbl_data, int ge
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -9496,14 +9769,15 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_id, int input_mailbox_id, int mail_ids[], int number_of_mails, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(char *multi_user_name, int input_source_account_id, int input_mailbox_id, int mail_ids[], int number_of_mails, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("input_source_account_id [%d], input_mailbox_id [%d], mail_ids[%p], number_of_mails [%d], transaction[%d], err_code[%p]", input_source_account_id, input_mailbox_id, mail_ids, number_of_mails, transaction, err_code);
int ret = false, i, cur_conditional_clause = 0;
int error = EMAIL_ERROR_NONE;
int target_account_id;
- char sql_query_string[QUERY_SIZE] = {0, }, conditional_clause[QUERY_SIZE] = {0, };
+ int conditional_clause_len = 0;
+ char *sql_query_string = NULL, *conditional_clause = NULL;
emstorage_mailbox_tbl_t *result_mailbox = NULL;
email_mailbox_type_e target_mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED;
char* target_mailbox_name = NULL;
@@ -9515,9 +9789,9 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_i
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- if ((error = emstorage_get_mailbox_by_id(input_mailbox_id, &result_mailbox)) != EMAIL_ERROR_NONE || !result_mailbox) {
+ if ((error = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &result_mailbox)) != EMAIL_ERROR_NONE || !result_mailbox) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", error);
if (err_code != NULL)
*err_code = error;
@@ -9536,21 +9810,33 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_i
target_account_id = result_mailbox->account_id;
emstorage_free_mailbox(&result_mailbox, 1, NULL);
- cur_conditional_clause = SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE mail_id in (");
+ conditional_clause_len = (sizeof(char) * 8 * number_of_mails) + 512;
+ conditional_clause = em_malloc(conditional_clause_len);
+ if (conditional_clause == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ cur_conditional_clause = SNPRINTF(conditional_clause, conditional_clause_len, "WHERE mail_id in (");
for(i = 0; i < number_of_mails; i++)
- cur_conditional_clause += SNPRINTF_OFFSET(conditional_clause, cur_conditional_clause, QUERY_SIZE, "%d,", mail_ids[i]);
+ cur_conditional_clause += SNPRINTF_OFFSET(conditional_clause, cur_conditional_clause, conditional_clause_len, "%d,", mail_ids[i]);
/* prevent 34415 */
char *last_comma = rindex(conditional_clause, ',');
if(last_comma) *last_comma = ')'; /* replace , with ) */
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
/* Updating a mail_tbl */
- memset(sql_query_string, 0x00, QUERY_SIZE);
- SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_tbl SET mailbox_type = %d, mailbox_id = %d, account_id = %d %s", target_mailbox_type, input_mailbox_id, target_account_id, conditional_clause);
+ sql_query_string = em_malloc(conditional_clause_len);
+ if (sql_query_string == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ SNPRINTF(sql_query_string, conditional_clause_len, "UPDATE mail_tbl SET mailbox_type = %d, mailbox_id = %d, account_id = %d %s", target_mailbox_type, input_mailbox_id, target_account_id, conditional_clause);
EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -9560,8 +9846,8 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_i
}
/* Updating a mail_attachment_tbl */
- memset(sql_query_string, 0x00, QUERY_SIZE);
- SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_attachment_tbl SET mailbox_id = '%d', account_id = %d %s", input_mailbox_id, target_account_id, conditional_clause);
+ memset(sql_query_string, 0x00, conditional_clause_len);
+ SNPRINTF(sql_query_string, conditional_clause_len, "UPDATE mail_attachment_tbl SET mailbox_id = '%d', account_id = %d %s", input_mailbox_id, target_account_id, conditional_clause);
EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
if (error != EMAIL_ERROR_NONE) {
@@ -9570,8 +9856,8 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_i
}
/* Updating a mail_meeting_tbl */
- memset(sql_query_string, 0x00, QUERY_SIZE);
- SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_meeting_tbl SET mailbox_id = %d, account_id = %d %s", input_mailbox_id, target_account_id, conditional_clause);
+ memset(sql_query_string, 0x00, conditional_clause_len);
+ SNPRINTF(sql_query_string, conditional_clause_len, "UPDATE mail_meeting_tbl SET mailbox_id = %d, account_id = %d %s", input_mailbox_id, target_account_id, conditional_clause);
EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
if (error != EMAIL_ERROR_NONE) {
@@ -9581,8 +9867,8 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_i
#ifdef __FEATURE_BODY_SEARCH__
/* Updating mail_text_tbl */
- memset(sql_query_string, 0x00, QUERY_SIZE);
- SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_text_tbl SET mailbox_id = %d, account_id = %d %s", input_mailbox_id, target_account_id, conditional_clause);
+ memset(sql_query_string, 0x00, conditional_clause_len);
+ SNPRINTF(sql_query_string, conditional_clause_len, "UPDATE mail_text_tbl SET mailbox_id = %d, account_id = %d %s", input_mailbox_id, target_account_id, conditional_clause);
EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
if (error != EMAIL_ERROR_NONE) {
@@ -9592,18 +9878,18 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_i
#endif
/* Updating a mail_read_mail_uid_tbl */
- memset(conditional_clause, 0x00, QUERY_SIZE);
- cur_conditional_clause = SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE local_uid in (");
+ memset(conditional_clause, 0x00, conditional_clause_len);
+ cur_conditional_clause = SNPRINTF(conditional_clause, conditional_clause_len, "WHERE local_uid in (");
for(i = 0; i < number_of_mails; i++)
- cur_conditional_clause += SNPRINTF_OFFSET(conditional_clause, cur_conditional_clause, QUERY_SIZE, "%d,", mail_ids[i]);
+ cur_conditional_clause += SNPRINTF_OFFSET(conditional_clause, cur_conditional_clause, conditional_clause_len, "%d,", mail_ids[i]);
/* prevent 34415 */
last_comma = rindex(conditional_clause, ',');
if(last_comma) *last_comma = ')'; /* replace , with ) */
- memset(sql_query_string, 0x00, QUERY_SIZE);
- SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_read_mail_uid_tbl SET mailbox_name = '%s', mailbox_id = %d, account_id = %d %s", target_mailbox_name, input_mailbox_id, target_account_id, conditional_clause);
+ memset(sql_query_string, 0x00, conditional_clause_len);
+ SNPRINTF(sql_query_string, conditional_clause_len, "UPDATE mail_read_mail_uid_tbl SET mailbox_name = '%s', mailbox_id = %d, account_id = %d %s", target_mailbox_name, input_mailbox_id, target_account_id, conditional_clause);
EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
if (error != EMAIL_ERROR_NONE) {
@@ -9614,9 +9900,11 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int input_source_account_i
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
EM_SAFE_FREE(target_mailbox_name);
+ EM_SAFE_FREE(conditional_clause);
+ EM_SAFE_FREE(sql_query_string);
if (err_code != NULL)
*err_code = error;
@@ -9625,7 +9913,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_mail(int mail_id, int from_server, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_mail(char *multi_user_name, int mail_id, int from_server, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], transaction[%d], err_code[%p]", mail_id, transaction, err_code);
@@ -9639,8 +9927,8 @@ INTERNAL_FUNC int emstorage_delete_mail(int mail_id, int from_server, int transa
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -9655,7 +9943,7 @@ INTERNAL_FUNC int emstorage_delete_mail(int mail_id, int from_server, int transa
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -9664,13 +9952,14 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_multiple_mails(int mail_ids[], int number_of_mails, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_multiple_mails(char *multi_user_name, int mail_ids[], int number_of_mails, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_ids[%p], number_of_mails [%d], transaction[%d], err_code[%p]", mail_ids, number_of_mails, transaction, err_code);
int ret = false, i, cur_sql_query_string = 0;
int error = EMAIL_ERROR_NONE;
- char sql_query_string[QUERY_SIZE] = {0, };
+ int query_size = 0;
+ char *sql_query_string = NULL;
if (!mail_ids) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -9679,17 +9968,25 @@ INTERNAL_FUNC int emstorage_delete_multiple_mails(int mail_ids[], int number_of_
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
+
+ query_size = (sizeof(char) * 8 * number_of_mails) + 512;
+ sql_query_string = em_malloc(query_size);
+ if (sql_query_string == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
- cur_sql_query_string = SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_tbl WHERE mail_id in (");
+ cur_sql_query_string = SNPRINTF(sql_query_string, query_size, "DELETE FROM mail_tbl WHERE mail_id in (");
for(i = 0; i < number_of_mails; i++)
- cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, QUERY_SIZE, "%d,", mail_ids[i]);
+ cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, query_size, "%d,", mail_ids[i]);
/* prevent 34414 */
char *last_comma = rindex(sql_query_string, ',');
- if (last_comma) *last_comma = ')'; /* replace , with ) */
+ if (last_comma != NULL) *last_comma = ')'; /* replace , with ) */
EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -9700,10 +9997,10 @@ INTERNAL_FUNC int emstorage_delete_multiple_mails(int mail_ids[], int number_of_
#ifdef __FEATURE_BODY_SEARCH__
/* delete mail_text from mail_text_tbl */
- cur_sql_query_string = SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_text_tbl WHERE mail_id in (");
+ cur_sql_query_string = SNPRINTF(sql_query_string, query_size, "DELETE FROM mail_text_tbl WHERE mail_id in (");
for(i = 0; i < number_of_mails; i++)
- cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, QUERY_SIZE, "%d,", mail_ids[i]);
+ cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, query_size, "%d,", mail_ids[i]);
last_comma = rindex(sql_query_string, ',');
*last_comma = ')'; /* replace , with ) */
@@ -9719,8 +10016,9 @@ INTERNAL_FUNC int emstorage_delete_multiple_mails(int mail_ids[], int number_of_
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
+ EM_SAFE_FREE(sql_query_string);
if (err_code != NULL)
*err_code = error;
@@ -9728,7 +10026,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_mail_by_account(char *multi_user_name, int account_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], transaction[%d], err_code[%p]", account_id, transaction, err_code);
@@ -9744,8 +10042,8 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transacti
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_tbl WHERE account_id = %d", account_id);
EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
@@ -9796,7 +10094,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transacti
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (error == EMAIL_ERROR_NONE) {
if (!emcore_notify_storage_event (NOTI_MAIL_DELETE_WITH_ACCOUNT, account_id, 0 , NULL, 0))
@@ -9810,7 +10108,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox[%p], transaction[%d], err_code[%p]", mailbox, transaction, err_code);
@@ -9824,8 +10122,8 @@ INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(emstorage_mailbox_tbl_t *mail
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
if (strcmp(mailbox->mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) == 0) {
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_tbl WHERE account_id = %d AND mailbox_type = %d", mailbox->account_id, mailbox->mailbox_type);
@@ -9876,7 +10174,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(emstorage_mailbox_tbl_t *mail
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (error == EMAIL_ERROR_NONE) {
if (!emcore_notify_storage_event(NOTI_MAIL_DELETE_ALL, mailbox->account_id, mailbox->mailbox_id , mailbox->mailbox_name, 0))
@@ -9928,6 +10226,7 @@ INTERNAL_FUNC int emstorage_free_mail(emstorage_mail_tbl_t** mail_list, int coun
EM_SAFE_FREE(p->default_charset);
EM_SAFE_FREE(p->pgp_password);
EM_SAFE_FREE(p->eas_data);
+ EM_SAFE_FREE(p->user_name);
}
EM_SAFE_FREE(*mail_list);
}
@@ -9963,8 +10262,7 @@ INTERNAL_FUNC void emstorage_free_mail_text(emstorage_mail_text_tbl_t** mail_tex
}
#endif
-
-INTERNAL_FUNC int emstorage_get_attachment_count(int mail_id, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_attachment_count(char *multi_user_name, int mail_id, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], count[%p], transaction[%d], err_code[%p]", mail_id, count, transaction, err_code);
@@ -9979,7 +10277,7 @@ INTERNAL_FUNC int emstorage_get_attachment_count(int mail_id, int *count, int tr
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_attachment_tbl WHERE mail_id = %d", mail_id);
@@ -10005,7 +10303,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_transaction, emstorage_attachment_tbl_t** output_attachment_list, int *output_attachment_count)
+INTERNAL_FUNC int emstorage_get_attachment_list(char *multi_user_name, int input_mail_id, int input_transaction, emstorage_attachment_tbl_t** output_attachment_list, int *output_attachment_count)
{
EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], input_transaction[%d], output_attachment_list[%p], output_attachment_count[%p]", input_mail_id, input_transaction, output_attachment_list, output_attachment_count);
@@ -10021,7 +10319,7 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra
char sql_query_string[QUERY_SIZE] = {0, };
emstorage_attachment_tbl_t* p_data_tbl = NULL;
DB_STMT hStmt = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(input_transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_attachment_tbl WHERE mail_id = %d", input_mail_id);
@@ -10102,7 +10400,7 @@ FINISH_OFF:
return error;
}
-INTERNAL_FUNC int emstorage_get_attachment(int attachment_id, emstorage_attachment_tbl_t** attachment, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_attachment(char *multi_user_name, int attachment_id, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], transaction[%d], err_code[%p]", attachment_id, attachment, transaction, err_code);
@@ -10118,7 +10416,7 @@ INTERNAL_FUNC int emstorage_get_attachment(int attachment_id, emstorage_attachme
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_attachment_tbl WHERE attachment_id = %d", attachment_id);
@@ -10190,7 +10488,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_attachment_tbl_t** attachment_tbl, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_attachment_nth(char *multi_user_name, int mail_id, int nth, emstorage_attachment_tbl_t **attachment_tbl, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], nth[%d], attachment_tbl[%p], transaction[%d], err_code[%p]", mail_id, nth, attachment_tbl, transaction, err_code);
@@ -10208,7 +10506,7 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_a
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_attachment_tbl WHERE mail_id = %d ORDER BY attachment_id LIMIT %d, 1", mail_id, (nth - 1));
@@ -10282,7 +10580,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *attachment_path, emstorage_attachment_tbl_t** attachment, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *multi_user_name, char *attachment_path, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_path[%p], attachment[%p], transaction[%d], err_code[%p]", attachment_path, attachment, transaction, err_code);
@@ -10298,7 +10596,7 @@ INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *attachment_p
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_attachment_tbl WHERE attachment_path = '%s'", attachment_path);
@@ -10370,7 +10668,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, email_mail_change_type_t type, emstorage_attachment_tbl_t* attachment, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int mail_id, email_mail_change_type_t type, emstorage_attachment_tbl_t *attachment, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], type[%d], attachment[%p], transaction[%d], err_code[%p]", mail_id, type, attachment, transaction, err_code);
@@ -10388,9 +10686,9 @@ INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, email_mail_chan
int i = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
switch (type) {
case UPDATE_MAILBOX:
@@ -10454,7 +10752,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, email_mail_chan
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -10470,8 +10768,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_rename_mailbox(int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_transaction)
+INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_transaction)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_new_mailbox_name[%p] input_new_mailbox_alias[%p] input_eas_data[%p] input_eas_data_length[%d] input_transaction[%d]", input_mailbox_id, input_new_mailbox_name, input_new_mailbox_alias, input_eas_data, input_eas_data_length, input_transaction);
@@ -10504,9 +10801,9 @@ INTERNAL_FUNC int emstorage_rename_mailbox(int input_mailbox_id, char *input_new
replaced_alias = strdup(input_new_mailbox_alias);
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
- if ((error = emstorage_get_mailbox_by_id(input_mailbox_id, &old_mailbox_data)) != EMAIL_ERROR_NONE) {
+ if ((error = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &old_mailbox_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", error);
EM_SAFE_FREE (replaced_mailbox_name);
EM_SAFE_FREE (replaced_alias);
@@ -10521,7 +10818,7 @@ INTERNAL_FUNC int emstorage_rename_mailbox(int input_mailbox_id, char *input_new
account_id = old_mailbox_data->account_id;
- EMSTORAGE_START_WRITE_TRANSACTION(input_transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, input_transaction, error);
if(input_eas_data && input_eas_data_length > 0) {
SNPRINTF(sql_query_string, sizeof(sql_query_string),
@@ -10573,7 +10870,7 @@ INTERNAL_FUNC int emstorage_rename_mailbox(int input_mailbox_id, char *input_new
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(input_transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, input_transaction, ret, error);
if (error == EMAIL_ERROR_NONE) {
if (!emcore_notify_storage_event (NOTI_MAILBOX_RENAME, account_id, input_mailbox_id, input_new_mailbox_name, 0))
EM_DEBUG_EXCEPTION ("emcore_notify_storage_event Failed [ NOTI_MAILBOX_RENAME ] >>>> ");
@@ -10601,7 +10898,7 @@ FINISH_OFF:
return error;
}
-INTERNAL_FUNC int emstorage_get_new_attachment_no(int *attachment_no, int *err_code)
+INTERNAL_FUNC int emstorage_get_new_attachment_no(char *multi_user_name, int *attachment_no, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_no [%p], err_code[%p]", attachment_no, err_code);
int rc, ret = false;
@@ -10618,7 +10915,7 @@ INTERNAL_FUNC int emstorage_get_new_attachment_no(int *attachment_no, int *err_c
*attachment_no = -1;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
@@ -10645,7 +10942,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachment_tbl, int iscopy, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_attachment_tbl_t *attachment_tbl, int iscopy, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_tbl[%p], iscopy[%d], transaction[%d], err_code[%p]", attachment_tbl, iscopy, transaction, err_code);
@@ -10656,7 +10953,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen
char sql_query_string[QUERY_SIZE] = {0, };
DB_STMT hStmt = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
if (!attachment_tbl) {
EM_DEBUG_EXCEPTION("attachment_tbl[%p], iscopy[%d]", attachment_tbl, iscopy);
@@ -10665,7 +10962,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen
return false;
}
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
sql = "SELECT max(rowid) FROM mail_attachment_tbl;";
@@ -10740,7 +11037,7 @@ INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t* attachmen
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -10757,7 +11054,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attachment_tbl, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_attachment(char *multi_user_name, emstorage_attachment_tbl_t *attachment_tbl, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_tbl[%p], transaction[%d], err_code[%p]", attachment_tbl, transaction, err_code);
@@ -10773,9 +11070,9 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_attachment_tbl SET "
@@ -10830,7 +11127,7 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t* attach
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -10846,7 +11143,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_attachment_on_db(int attachment_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_attachment_on_db(char *multi_user_name, int attachment_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_id[%d], transaction[%d], err_code[%p]", attachment_id, transaction, err_code);
@@ -10860,9 +11157,9 @@ INTERNAL_FUNC int emstorage_delete_attachment_on_db(int attachment_id, int trans
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_attachment_tbl WHERE attachment_id = %d", attachment_id);
@@ -10875,7 +11172,7 @@ INTERNAL_FUNC int emstorage_delete_attachment_on_db(int attachment_id, int trans
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code)
*err_code = error;
@@ -10884,7 +11181,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(int mail_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(char *multi_user_name, int mail_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], transaction[%d], err_code[%p]", mail_id, transaction, err_code);
int ret = false;
@@ -10899,9 +11196,9 @@ INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(int mail_id, int tran
return false;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_attachment_tbl WHERE mail_id = %d", mail_id);
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -10913,7 +11210,7 @@ INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(int mail_id, int tran
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code)
*err_code = error;
@@ -10922,7 +11219,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mailbox, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(char *multi_user_name, int account_id, char *mailbox, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], transaction[%d], err_code[%p]", account_id, mailbox, transaction, err_code);
@@ -10930,9 +11227,9 @@ INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *ma
int ret = false;
char sql_query_string[QUERY_SIZE] = {0, };
char *replaced_mailbox = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_attachment_tbl");
@@ -10959,7 +11256,7 @@ INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *ma
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -11003,16 +11300,15 @@ INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t** attachm
return true;
}
-
-
-INTERNAL_FUNC int emstorage_begin_transaction(void *d1, void *d2, int *err_code)
+INTERNAL_FUNC int emstorage_begin_transaction(char *multi_user_name, void *d1, void *d2, int *err_code)
{
EM_PROFILE_BEGIN(emStorageBeginTransaction);
int ret = true;
- _timedlock_shm_mutex(&mapped_for_db_lock, 2);
+ _timedlock_shm_mutex(mapped_for_db_lock, 2);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- sqlite3 *local_db_handle = emstorage_get_db_connection();
int rc;
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "BEGIN immediate;", NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {ret = false; },
@@ -11027,13 +11323,13 @@ INTERNAL_FUNC int emstorage_begin_transaction(void *d1, void *d2, int *err_code)
return ret;
}
-INTERNAL_FUNC int emstorage_commit_transaction(void *d1, void *d2, int *err_code)
+INTERNAL_FUNC int emstorage_commit_transaction(char *multi_user_name, void *d1, void *d2, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int ret = true;
int rc;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {ret = false; }, ("SQL(END) exec error:%d -%s", rc, sqlite3_errmsg(local_db_handle)));
@@ -11041,18 +11337,18 @@ INTERNAL_FUNC int emstorage_commit_transaction(void *d1, void *d2, int *err_code
if (ret == false && err_code != NULL)
*err_code = EMAIL_ERROR_DB_FAILURE;
- _unlockshm_mutex(&mapped_for_db_lock);
+ _unlockshm_mutex(mapped_for_db_lock);
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
-INTERNAL_FUNC int emstorage_rollback_transaction(void *d1, void *d2, int *err_code)
+INTERNAL_FUNC int emstorage_rollback_transaction(char *multi_user_name, void *d1, void *d2, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int ret = true;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
int rc;
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "ROLLBACK;", NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {ret = false; },
@@ -11061,13 +11357,13 @@ INTERNAL_FUNC int emstorage_rollback_transaction(void *d1, void *d2, int *err_co
if (ret == false && err_code != NULL)
*err_code = EMAIL_ERROR_DB_FAILURE;
- _unlockshm_mutex(&mapped_for_db_lock);
+ _unlockshm_mutex(mapped_for_db_lock);
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
-INTERNAL_FUNC int emstorage_is_mailbox_full(int account_id, email_mailbox_t *mailbox, int *result, int *err_code)
+INTERNAL_FUNC int emstorage_is_mailbox_full(char *multi_user_name, int account_id, email_mailbox_t *mailbox, int *result, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], result[%p], err_code[%p]", account_id, mailbox, result, err_code);
@@ -11085,7 +11381,7 @@ INTERNAL_FUNC int emstorage_is_mailbox_full(int account_id, email_mailbox_t *mai
int error = EMAIL_ERROR_NONE;
int mail_count = 0;
- if (!emstorage_get_mail_count(account_id, mailbox->mailbox_id, &mail_count, NULL, true, &error)) {
+ if (!emstorage_get_mail_count(multi_user_name, account_id, mailbox->mailbox_id, &mail_count, NULL, true, &error)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_count failed [%d]", error);
goto FINISH_OFF;
}
@@ -11110,7 +11406,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("transaction[%d], err_code[%p]", transaction, err_code);
@@ -11119,8 +11415,9 @@ INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code)
char sql_query_string[QUERY_SIZE] = {0, };
const email_db_object_t* tables = _g_db_tables;
const email_db_object_t* indexes = _g_db_indexes;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
if (!emstorage_delete_dir(MAILHOME, &error)) {
EM_DEBUG_EXCEPTION(" emstorage_delete_dir failed - %d", error);
@@ -11130,6 +11427,7 @@ INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code)
mkdir(MAILHOME, DIRECTORY_PERMISSION);
mkdir(MAILTEMP, DIRECTORY_PERMISSION);
+ chmod(MAILTEMP, 0777);
/* first clear index. */
while (indexes->object_name) {
@@ -11159,7 +11457,7 @@ INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code)
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -11192,9 +11490,10 @@ INTERNAL_FUNC char *emstorage_make_directory_path_from_file_path(char *file_name
return result;
}
-INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_id, char *fname, char *name_buf, int maxlen, int *err_code)
+INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id, int mail_id, int atch_id,
+ char *fname, char *move_buf, char *path_buf, int maxlen, int *err_code)
{
- EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], mail_id[%d], atch_id[%d], fname[%s], name_buf[%p], err_code[%p]", account_id, mail_id, atch_id, fname, name_buf, err_code);
+ EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], mail_id[%d], atch_id[%d], fname[%s], move_buf[%p], path_buf[%p], err_code[%p]", account_id, mail_id, atch_id, fname, move_buf, path_buf, err_code);
EM_PROFILE_BEGIN(profile_emstorage_get_save_name);
int ret = false;
@@ -11202,21 +11501,22 @@ INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_
char *dir_name = NULL;
char create_dir[1024]={0};
char *temp_file = NULL;
+ char *prefix_path = NULL;
- if (!name_buf || account_id < FIRST_ACCOUNT_ID || mail_id < 0 || atch_id < 0) {
- EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d], atch_id[%d], fname[%p], name_buf[%p]", account_id, mail_id, atch_id, fname, name_buf);
+ if (!move_buf || !path_buf || account_id < FIRST_ACCOUNT_ID || mail_id < 0 || atch_id < 0) {
+ EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d], atch_id[%d], fname[%p], move_buf[%p], path_buf[%p]", account_id, mail_id, atch_id, fname, move_buf, path_buf);
error = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- sprintf(name_buf, "%s", MAILHOME);
- sprintf(name_buf+EM_SAFE_STRLEN(name_buf), "%s%d", DIR_SEPERATOR, account_id);
+ sprintf(path_buf, "%s", MAILHOME);
+ sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%d", DIR_SEPERATOR, account_id);
if (mail_id > 0)
- sprintf(name_buf+EM_SAFE_STRLEN(name_buf), "%s%d", DIR_SEPERATOR, mail_id);
+ sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%d", DIR_SEPERATOR, mail_id);
if (atch_id > 0)
- sprintf(name_buf+EM_SAFE_STRLEN(name_buf), "%s%d", DIR_SEPERATOR, atch_id);
+ sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%d", DIR_SEPERATOR, atch_id);
if (fname) {
temp_file = EM_SAFE_STRDUP(fname);
@@ -11226,7 +11526,7 @@ INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_
}
if (dir_name) {
- snprintf(create_dir, sizeof(create_dir), "%s%s%s", name_buf, DIR_SEPERATOR, dir_name);
+ snprintf(create_dir, sizeof(create_dir), "%s%s%s", path_buf, DIR_SEPERATOR, dir_name);
EM_DEBUG_LOG(">>>>> DIR PATH [%s]", create_dir);
mkdir(create_dir, DIRECTORY_PERMISSION);
EM_SAFE_FREE(dir_name);
@@ -11234,9 +11534,9 @@ INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_
if (fname) {
EM_DEBUG_LOG_DEV(">>>>> fname [%s]", fname);
- if (EM_SAFE_STRLEN(fname) + EM_SAFE_STRLEN(name_buf) + strlen(DIR_SEPERATOR) > maxlen - 1) {
+ if (EM_SAFE_STRLEN(fname) + EM_SAFE_STRLEN(path_buf) + strlen(DIR_SEPERATOR) > maxlen - 1) {
char *modified_name = NULL;
- int remain_len = (maxlen - 1) - EM_SAFE_STRLEN(name_buf) - strlen(DIR_SEPERATOR);
+ int remain_len = (maxlen - 1) - EM_SAFE_STRLEN(path_buf) - strlen(DIR_SEPERATOR);
if (remain_len <= 0) {
error = EMAIL_ERROR_MAX_EXCEEDED;
@@ -11254,7 +11554,7 @@ INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_
goto FINISH_OFF;
}
- sprintf(name_buf+EM_SAFE_STRLEN(name_buf), "%s%s", DIR_SEPERATOR, modified_name);
+ sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%s", DIR_SEPERATOR, modified_name);
EM_DEBUG_LOG(">>>>> Modified fname [%s]", modified_name);
EM_SAFE_FREE(modified_name);
} else {
@@ -11267,21 +11567,36 @@ INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_
goto FINISH_OFF;
}
- sprintf(name_buf+EM_SAFE_STRLEN(name_buf), "%s%s", DIR_SEPERATOR, modified_name);
+ sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%s", DIR_SEPERATOR, modified_name);
EM_DEBUG_LOG(">>>>> Modified fname [%s]", modified_name);
EM_SAFE_FREE(modified_name);
} else {
- sprintf(name_buf+EM_SAFE_STRLEN(name_buf), "%s%s", DIR_SEPERATOR, fname);
+ sprintf(path_buf+EM_SAFE_STRLEN(path_buf), "%s%s", DIR_SEPERATOR, fname);
}
}
}
- EM_DEBUG_LOG_SEC(">>>>> name_buf [%s]", name_buf);
+ EM_DEBUG_LOG_SEC(">>>>> path_buf [%s]", path_buf);
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ error = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+ sprintf(move_buf, "%s/%s", prefix_path, path_buf);
+ EM_DEBUG_LOG("move_buf : [%s]", move_buf);
+ } else {
+ sprintf(move_buf, "%s", path_buf);
+ EM_DEBUG_LOG("move_buf : [%s]", move_buf);
+ }
ret = true;
FINISH_OFF:
+
EM_SAFE_FREE(temp_file);
+ EM_SAFE_FREE(prefix_path);
if (err_code != NULL)
*err_code = error;
@@ -11291,7 +11606,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_dele_name(int account_id, int mail_id, int atch_id, char *fname, char *name_buf, int *err_code)
+INTERNAL_FUNC int emstorage_get_dele_name(char *multi_user_name, int account_id, int mail_id, int atch_id, char *fname, char *name_buf, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], atch_id[%d], fname[%p], name_buf[%p], err_code[%p]", account_id, mail_id, atch_id, fname, name_buf, err_code);
@@ -11321,7 +11636,7 @@ FINISH_OFF:
return true;
}
-INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, int *err_code)
+INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, int mail_id, int atch_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], atch_id[%d], err_code[%p]", account_id, mail_id, atch_id, err_code);
EM_PROFILE_BEGIN(profile_emcore_save_create_dir);
@@ -11329,10 +11644,27 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id,
int error = EMAIL_ERROR_NONE;
char buf[512];
struct stat sbuf;
+ char *prefix_path = NULL;
char errno_buf[ERRNO_BUF_SIZE] = {0};
+ memset(buf, 0x00, sizeof(buf));
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ error = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", error);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
if (account_id >= FIRST_ACCOUNT_ID) {
- SNPRINTF(buf, sizeof(buf), "%s%s%d", MAILHOME, DIR_SEPERATOR, account_id);
+ SNPRINTF(buf, sizeof(buf), "%s%s%s%s%d", prefix_path,
+ DIR_SEPERATOR,
+ MAILHOME,
+ DIR_SEPERATOR,
+ account_id);
if (stat(buf, &sbuf) == 0) {
if ((sbuf.st_mode & S_IFMT) != S_IFDIR) {
@@ -11350,35 +11682,50 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id,
error = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
+
+ if (account_id == EML_FOLDER) {
+ chmod(buf, 0777);
+ }
}
}
if (mail_id > 0) {
+ int space_left_in_buffer = sizeof(buf) - EM_SAFE_STRLEN(buf);
+
if (account_id < FIRST_ACCOUNT_ID) {
EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d], atch_id[%d]", account_id, mail_id, atch_id);
error = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
}
- SNPRINTF(buf+EM_SAFE_STRLEN(buf), sizeof(buf)-(EM_SAFE_STRLEN(buf)+1), "%s%d", DIR_SEPERATOR, mail_id);
+ if (space_left_in_buffer + 10 > sizeof(buf)) {
+ EM_DEBUG_EXCEPTION("Buffer overflowed");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ SNPRINTF(buf+EM_SAFE_STRLEN(buf), space_left_in_buffer, "%s%d", DIR_SEPERATOR, mail_id);
if (stat(buf, &sbuf) == 0) {
if ((sbuf.st_mode & S_IFMT) != S_IFDIR) {
EM_DEBUG_EXCEPTION(" a object which isn't directory aleady exists");
-
error = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
}
else {
if (mkdir(buf, DIRECTORY_PERMISSION) != 0) {
- EM_DEBUG_EXCEPTION(" mkdir failed [%s]", buf);
- EM_DEBUG_EXCEPTION("mkdir failed: %s", strerror(errno));
+ EM_DEBUG_EXCEPTION("mkdir failed [%s]", buf);
+ EM_DEBUG_EXCEPTION("mkdir failed [%d][%s]", errno, EM_STRERROR(errno_buf));
error = EMAIL_ERROR_SYSTEM_FAILURE;
if(errno == 28)
error = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
+
+ if (account_id == EML_FOLDER) {
+ chmod(buf, 0777);
+ }
}
}
@@ -11408,12 +11755,19 @@ INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id,
error = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
+
+ if (account_id == EML_FOLDER) {
+ chmod(buf, 0777);
+ }
}
}
ret = true;
FINISH_OFF:
+
+ EM_SAFE_FREE(prefix_path);
+
if (err_code != NULL)
*err_code = error;
@@ -11450,50 +11804,50 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s
goto FINISH_OFF;
}
- error = em_open(src_file, O_RDONLY, 0, &fp_src);
- if (error != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION(">>>> Source Fail em_open %s Failed: %d", src_file, error);
- goto FINISH_OFF;
- }
+ error = em_open(src_file, O_RDONLY, 0, &fp_src);
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(">>>> Source Fail em_open %s Failed: %d", src_file, error);
+ goto FINISH_OFF;
+ }
- error = em_open(dst_file, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, &fp_dst); /*prevent 24474*/
- if (error != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION(">>>> Destination Fail em_open %s: %d", dst_file, error);
- goto FINISH_OFF;
- }
+ error = em_open(dst_file, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, &fp_dst); /*prevent 24474*/
+ if (error != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(">>>> Destination Fail em_open %s: %d", dst_file, error);
+ goto FINISH_OFF;
+ }
- memset(buf, 0x00, FILE_MAX_BUFFER_SIZE);
-
- while ((nread = read(fp_src, buf, FILE_MAX_BUFFER_SIZE)) > 0) {
- if (nread > 0 && nread <= FILE_MAX_BUFFER_SIZE) {
- EM_DEBUG_LOG("Nread Value [%d]", nread);
- char *buf_ptr;
- ssize_t byte_written = 0;
- size_t remain_byte = nread;
- buf_ptr = buf;
- errno = 0;
-
- while(remain_byte > 0 && buf_ptr && errno == 0) {
- byte_written = write(fp_dst, buf_ptr, remain_byte);
-
- if (byte_written < 0) {
- /* interrupted by a signal */
- if (errno == EINTR) {
- errno = 0;
- continue;
- }
-
- EM_DEBUG_EXCEPTION("fwrite failed: %s", EM_STRERROR(errno_buf));
- error = EMAIL_ERROR_UNKNOWN;
- goto FINISH_OFF;
- }
- EM_DEBUG_LOG("NWRITTEN [%d]", byte_written);
- remain_byte -= byte_written;
- buf_ptr += byte_written;
- }
- }
+ memset(buf, 0x00, FILE_MAX_BUFFER_SIZE);
+
+ while ((nread = read(fp_src, buf, FILE_MAX_BUFFER_SIZE)) > 0) {
+ if (nread > 0 && nread <= FILE_MAX_BUFFER_SIZE) {
+ EM_DEBUG_LOG("Nread Value [%d]", nread);
+ char *buf_ptr;
+ ssize_t byte_written = 0;
+ size_t remain_byte = nread;
+ buf_ptr = buf;
+ errno = 0;
+
+ while(remain_byte > 0 && buf_ptr && errno == 0) {
+ byte_written = write(fp_dst, buf_ptr, remain_byte);
- memset(buf, 0x00, FILE_MAX_BUFFER_SIZE);
+ if (byte_written < 0) {
+ /* interrupted by a signal */
+ if (errno == EINTR) {
+ errno = 0;
+ continue;
+ }
+
+ EM_DEBUG_EXCEPTION("fwrite failed: %s", EM_STRERROR(errno_buf));
+ error = EMAIL_ERROR_UNKNOWN;
+ goto FINISH_OFF;
+ }
+ EM_DEBUG_LOG("NWRITTEN [%d]", byte_written);
+ remain_byte -= byte_written;
+ buf_ptr += byte_written;
+ }
+ }
+
+ memset(buf, 0x00, FILE_MAX_BUFFER_SIZE);
}
ret = true;
@@ -11526,6 +11880,7 @@ INTERNAL_FUNC void emstorage_create_dir_if_delete()
mkdir(EMAILPATH, DIRECTORY_PERMISSION);
mkdir(MAILHOME, DIRECTORY_PERMISSION);
mkdir(MAILTEMP, DIRECTORY_PERMISSION);
+ chmod(MAILTEMP, 0777);
EM_DEBUG_FUNC_END();
}
@@ -11916,7 +12271,7 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code)
}
/* faizan.h@samsung.com */
-INTERNAL_FUNC int emstorage_update_server_uid(char *old_server_uid, char *new_server_uid, int *err_code)
+INTERNAL_FUNC int emstorage_update_server_uid(char *multi_user_name, char *old_server_uid, char *new_server_uid, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("new_server_uid[%s], old_server_uid[%s]", new_server_uid, old_server_uid);
int ret = false;
@@ -11931,9 +12286,9 @@ INTERNAL_FUNC int emstorage_update_server_uid(char *old_server_uid, char *new_se
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_tbl SET server_mail_id=\'%s\' WHERE server_mail_id=%s ", new_server_uid, old_server_uid);
@@ -11947,7 +12302,7 @@ INTERNAL_FUNC int emstorage_update_server_uid(char *old_server_uid, char *new_se
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -11957,7 +12312,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_update_read_mail_uid(int mail_id, char *new_server_uid, char *mbox_name, int *err_code)
+INTERNAL_FUNC int emstorage_update_read_mail_uid(char *multi_user_name, int mail_id, char *new_server_uid, char *mbox_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("mail_id[%d], new_server_uid[%s], mbox_name[%s]", mail_id, new_server_uid, mbox_name);
@@ -11973,8 +12328,8 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid(int mail_id, char *new_server_u
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
@@ -11990,7 +12345,7 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid(int mail_id, char *new_server_u
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -12000,7 +12355,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_update_save_status(int account_id, int *err_code)
+INTERNAL_FUNC int emstorage_update_save_status(char *multi_user_name, int account_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -12009,8 +12364,9 @@ INTERNAL_FUNC int emstorage_update_save_status(int account_id, int *err_code)
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0,};
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -12028,7 +12384,7 @@ INTERNAL_FUNC int emstorage_update_save_status(int account_id, int *err_code)
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -12038,7 +12394,7 @@ FINISH_OFF:
}
-int emstorage_get_unread_mailid(int account_id, int vip_mode, int **mail_ids, int *mail_number, int *err_code)
+int emstorage_get_unread_mailid(char *multi_user_name, int account_id, int vip_mode, int **mail_ids, int *mail_number, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -12062,7 +12418,7 @@ int emstorage_get_unread_mailid(int account_id, int vip_mode, int **mail_ids, in
char temp_query_string[QUERY_SIZE] = {0,};
char sql_select_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -12117,8 +12473,7 @@ FINISH_OFF:
EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
- sqlite3_db_release_memory(local_db_handle);
-
+// sqlite3_db_release_memory(local_db_handle);
if (ret == true) {
if (mail_ids != NULL)
@@ -12255,8 +12610,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address_to, char *full_address_cc, char *full_address_bcc, int *err_code)
+INTERNAL_FUNC int emstorage_test(char *multi_user_name, int mail_id, int account_id, char *full_address_to, char *full_address_cc, char *full_address_bcc, int *err_code)
{
DB_STMT hStmt = NULL;
int ret = false;
@@ -12322,9 +12676,9 @@ INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address
")");
int transaction = true;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
@@ -12394,7 +12748,7 @@ INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -12418,10 +12772,17 @@ INTERNAL_FUNC int emstorage_get_max_mail_count()
#define STRIPPED_SUBJECT_BUFFER_SIZE 4086
-INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t *mail_tbl, int *thread_id, int *result_latest_mail_id_in_thread, int *thread_item_count)
+INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name,
+ emstorage_mail_tbl_t *mail_tbl,
+ int *thread_id,
+ int *result_latest_mail_id_in_thread,
+ int *thread_item_count)
{
- EM_DEBUG_FUNC_BEGIN("mail_tbl [%p], thread_id [%p], result_latest_mail_id_in_thread [%p], thread_item_count [%p]", mail_tbl, thread_id, result_latest_mail_id_in_thread, thread_item_count);
+ EM_DEBUG_FUNC_BEGIN("mail_tbl [%p], thread_id [%p], "
+ "result_latest_mail_id_in_thread [%p], thread_item_count [%p]",
+ mail_tbl, thread_id, result_latest_mail_id_in_thread, thread_item_count);
EM_PROFILE_BEGIN(profile_emstorage_get_thread_id_of_thread_mails);
+
int rc = 0, query_size = 0, query_size_account = 0;
int account_id = 0;
int err_code = EMAIL_ERROR_NONE;
@@ -12434,9 +12795,10 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t *
char *sql_format_order_by = " ORDER BY date_time DESC ";
char **result = NULL;
char stripped_subject[STRIPPED_SUBJECT_BUFFER_SIZE];
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EM_DEBUG_LOG_SEC("subject: [%p], mail_id: [%d]", subject, mail_tbl->mail_id);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EM_DEBUG_LOG("subject: [%p], mail_id: [%d]", subject, mail_tbl->mail_id);
EM_IF_NULL_RETURN_VALUE(mail_tbl, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(thread_id, EMAIL_ERROR_INVALID_PARAM);
@@ -12454,7 +12816,9 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t *
goto FINISH_OFF;
}
- if (em_find_pos_stripped_subject_for_thread_view(subject, stripped_subject, STRIPPED_SUBJECT_BUFFER_SIZE) != EMAIL_ERROR_NONE) {
+ if (em_find_pos_stripped_subject_for_thread_view(subject,
+ stripped_subject,
+ STRIPPED_SUBJECT_BUFFER_SIZE) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_find_pos_stripped_subject_for_thread_view is failed");
err_code = EMAIL_ERROR_UNKNOWN;
result_thread_id = -1;
@@ -12463,12 +12827,13 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t *
EM_DEBUG_LOG_SEC("stripped_subject: [%s]", stripped_subject);
- if (EM_SAFE_STRLEN(stripped_subject) < 2) {
+ if (EM_SAFE_STRLEN(stripped_subject) == 0) {
result_thread_id = -1;
goto FINISH_OFF;
}
- EM_DEBUG_LOG_SEC("em_find_pos_stripped_subject_for_thread_view returns[len = %d] = %s", EM_SAFE_STRLEN(stripped_subject), stripped_subject);
+ EM_DEBUG_LOG_SEC("em_find_pos_stripped_subject_for_thread_view returns[len = %d] = %s",
+ EM_SAFE_STRLEN(stripped_subject), stripped_subject);
if (account_id > 0) {
query_size_account = 3 + EM_SAFE_STRLEN(sql_format_account);
@@ -12540,7 +12905,7 @@ FINISH_OFF:
return err_code;
}
-INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(int account_id, int mailbox_id, char *mail_subject, int *thread_id, int *thread_item_count)
+INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(char *multi_user_name, int account_id, int mailbox_id, char *mail_subject, int *thread_id, int *thread_item_count)
{
EM_DEBUG_FUNC_BEGIN("mailbox_id [%d], subject [%p], thread_id [%p], thread_item_count [%p]", mailbox_id, mail_subject, thread_id, thread_item_count);
EM_PROFILE_BEGIN(profile_emstorage_get_thread_id_of_thread_mails);
@@ -12558,7 +12923,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(int account_id, int mailb
char *sql_format_order_by = " ORDER BY date_time DESC ";
char **result = NULL;
char stripped_subject[STRIPPED_SUBJECT_BUFFER_SIZE];
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EM_IF_NULL_RETURN_VALUE(mail_subject, EMAIL_ERROR_INVALID_PARAM);
EM_IF_NULL_RETURN_VALUE(thread_id, EMAIL_ERROR_INVALID_PARAM);
@@ -12573,7 +12938,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(int account_id, int mailb
goto FINISH_OFF;
}
- if (EM_SAFE_STRLEN(stripped_subject) < 2) {
+ if (EM_SAFE_STRLEN(stripped_subject) == 0) {
result_thread_id = -1;
goto FINISH_OFF;
}
@@ -12641,8 +13006,7 @@ FINISH_OFF:
return err_code;
}
-
-INTERNAL_FUNC int emstorage_get_thread_information(int thread_id, emstorage_mail_tbl_t** mail_tbl, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_thread_information(char *multi_user_name, int thread_id, emstorage_mail_tbl_t** mail_tbl, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -12656,7 +13020,7 @@ INTERNAL_FUNC int emstorage_get_thread_information(int thread_id, emstorage_mail
SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE thread_id = %d AND thread_item_count > 0", thread_id);
EM_DEBUG_LOG("conditional_clause [%s]", conditional_clause);
- if(!emstorage_query_mail_tbl(conditional_clause, transaction, &p_data_tbl, &count, &error)) {
+ if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl failed [%d]", error);
goto FINISH_OFF;
}
@@ -12679,8 +13043,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_sender_list(int account_id, int mailbox_id, int search_type, const char *search_value, email_sort_type_t sorting, email_sender_list_t** sender_list, int *sender_count, int *err_code)
+INTERNAL_FUNC int emstorage_get_sender_list(char *multi_user_name, int account_id, int mailbox_id, int search_type, const char *search_value, email_sort_type_t sorting, email_sender_list_t** sender_list, int *sender_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("account_id [%d], mailbox_id [%d], search_type [%d], search_value [%p], sorting [%d], sender_list[%p], sender_count[%p] err_code[%p]"
, account_id , mailbox_id , search_type , search_value , sorting , sender_list, sender_count, err_code);
@@ -12700,7 +13063,7 @@ INTERNAL_FUNC int emstorage_get_sender_list(int account_id, int mailbox_id, int
email_sender_list_t *p_sender_list = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
char **result = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"SELECT email_address_sender, alias_sender, COUNT(email_address_sender), SUM(flags_seen_field = 1) "
@@ -12884,7 +13247,7 @@ INTERNAL_FUNC int emstorage_free_address_info_list(email_address_info_list_t **a
}
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-INTERNAL_FUNC int emstorage_add_pbd_activity(email_event_partial_body_thd* local_activity, int *activity_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_pbd_activity(char *multi_user_name, email_event_partial_body_thd* local_activity, int *activity_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("local_activity[%p], activity_id[%p], transaction[%d], err_code[%p]", local_activity, activity_id, transaction, err_code);
@@ -12902,8 +13265,9 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(email_event_partial_body_thd* local
char sql_query_string[QUERY_SIZE] = {0, };
DB_STMT hStmt = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_partial_body_activity_tbl VALUES "
@@ -12915,6 +13279,7 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(email_event_partial_body_thd* local
",?" /* Activity type*/
",?" /* Mailbox ID*/
",?" /* Mailbox name*/
+ ",?" /* Multi User Name */
") ");
char *sql = "SELECT max(rowid) FROM mail_partial_body_activity_tbl;";
@@ -12945,7 +13310,6 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(email_event_partial_body_thd* local
("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
-
_bind_stmt_field_data_int(hStmt, i++, local_activity->account_id);
_bind_stmt_field_data_int(hStmt, i++, local_activity->mail_id);
_bind_stmt_field_data_int(hStmt, i++, local_activity->server_mail_id);
@@ -12953,6 +13317,7 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(email_event_partial_body_thd* local
_bind_stmt_field_data_int(hStmt, i++, local_activity->activity_type);
_bind_stmt_field_data_int(hStmt, i++, local_activity->mailbox_id);
_bind_stmt_field_data_string(hStmt, i++ , (char *)local_activity->mailbox_name, 0, 3999);
+ _bind_stmt_field_data_string(hStmt, i++ , (char *)local_activity->multi_user_name, 0, MAX_USER_NAME_LENGTH);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
@@ -12965,7 +13330,7 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(email_event_partial_body_thd* local
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
hStmt = NULL;
@@ -12982,8 +13347,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, int **mailbox_list, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(char *multi_user_name, int account_id, int **mailbox_list, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], count[%p] err_code[%p]", account_id, mailbox_list, count, err_code);
@@ -13002,8 +13366,7 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, int **mailbox_l
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
-
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -13086,8 +13449,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_pbd_account_list(char *multi_user_name, int **account_list, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%p] err_code[%p]", account_list, count, err_code);
@@ -13106,7 +13468,8 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count,
int *result_account_list = NULL;
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -13185,9 +13548,7 @@ FINISH_OFF:
return ret;
}
-
-
-INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, int input_mailbox_id, email_event_partial_body_thd** event_start, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_pbd_activity_data(char *multi_user_name, int account_id, int input_mailbox_id, email_event_partial_body_thd** event_start, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], event_start[%p], err_code[%p]", account_id, event_start, err_code);
@@ -13208,7 +13569,7 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, int input_mail
email_event_partial_body_thd* event_list = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -13266,6 +13627,7 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, int input_mail
_get_stmt_field_data_int(hStmt, &(event_list[i].activity_type), ACTIVITY_TYPE_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL);
_get_stmt_field_data_int(hStmt, &(event_list[i].mailbox_id), MAILBOX_ID_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL);
_get_stmt_field_data_string(hStmt, &(event_list[i].mailbox_name), 0, MAILBOX_NAME_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL);
+ _get_stmt_field_data_string(hStmt, &(event_list[i].multi_user_name), 0, MULTI_USER_NAME_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
/* EM_DEBUG_LOG("In emstorage_get_pbd_activity_data() loop, After sqlite3_step(), , i = %d, rc = %d.", i, rc); */
@@ -13305,9 +13667,7 @@ FINISH_OFF:
return ret;
}
-
-
-INTERNAL_FUNC int emstorage_delete_pbd_activity(int account_id, int mail_id, int activity_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_pbd_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d] , activity_id[%d], transaction[%d], err_code[%p]", account_id, mail_id, activity_id, transaction, err_code);
@@ -13324,9 +13684,9 @@ INTERNAL_FUNC int emstorage_delete_pbd_activity(int account_id, int mail_id, int
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
if (activity_id == 0)
@@ -13353,7 +13713,7 @@ INTERNAL_FUNC int emstorage_delete_pbd_activity(int account_id, int mail_id, int
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -13362,7 +13722,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(char *multi_user_name, int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], activity_count[%p], err_code[%p]", account_id, activity_count, err_code);
@@ -13379,7 +13739,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(int account_id, int i
DB_STMT hStmt = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -13425,8 +13785,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_pbd_activity_count(int *activity_count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_pbd_activity_count(char *multi_user_name, int *activity_count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("activity_count[%p], err_code[%p]", activity_count, err_code);
@@ -13442,7 +13801,7 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_count(int *activity_count, int tran
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -13451,13 +13810,11 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_count(int *activity_count, int tran
EM_DEBUG_LOG_DEV(" Query [%s]", sql_query_string);
-
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
EM_DEBUG_LOG_DEV (" before sqlite3_prepare hStmt = %p", hStmt);
EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
-
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
("sqlite3_step fail:%d", rc));
@@ -13488,7 +13845,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(int account_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(char *multi_user_name, int account_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], transaction[%d], err_code[%p]", account_id, transaction, err_code);
if (account_id < FIRST_ACCOUNT_ID) {
@@ -13502,8 +13859,10 @@ INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(int account_id, int tr
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_partial_body_activity_tbl WHERE account_id = %d", account_id);
@@ -13525,7 +13884,8 @@ INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(int account_id, int tr
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -13537,7 +13897,7 @@ FINISH_OFF:
/*Himanshu[h.gahlaut]-> Added below API to update mail_partial_body_activity_tbl
if a mail is moved before its partial body is downloaded.Currently not used but should be used if mail move from server is enabled*/
-INTERNAL_FUNC int emstorage_update_pbd_activity(char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code)
+INTERNAL_FUNC int emstorage_update_pbd_activity(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("old_server_uid[%s], new_server_uid[%s], mbox_name[%s]", old_server_uid, new_server_uid, mbox_name);
@@ -13553,9 +13913,9 @@ INTERNAL_FUNC int emstorage_update_pbd_activity(char *old_server_uid, char *new_
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_partial_body_activity_tbl SET server_mail_id = %s , mailbox_name=\'%s\' WHERE server_mail_id = %s ", new_server_uid, mbox_name, old_server_uid);
@@ -13575,7 +13935,7 @@ INTERNAL_FUNC int emstorage_update_pbd_activity(char *old_server_uid, char *new_
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -13631,8 +13991,7 @@ FINISH_OFF:
#ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
-
-INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code)
+INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
int rc = -1;
@@ -13651,8 +14010,8 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_
EM_DEBUG_LOG_SEC("old_server_uid[%s], new_server_uid[%s], mbox_name[%s]", old_server_uid, new_server_uid, mbox_name);
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
@@ -13676,7 +14035,7 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -13701,8 +14060,7 @@ FINISH_OFF:
* SELECT local_uid, s_uid from mail_read_mail_uid_tbl where local_uid in (12, 13, 56, 78);
* @return This function returns true on success or false on failure.
*/
-
-INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, email_id_set_t** idset, int *id_set_count, int *err_code)
+INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *multi_user_name, char *mail_ids, email_id_set_t** idset, int *id_set_count, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
EM_PROFILE_BEGIN(EmStorageGetIdSetFromMailIds);
@@ -13728,7 +14086,7 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, email_id_se
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
SNPRINTF(sql_query_string, space_left_in_query_buffer, "SELECT local_uid, server_uid FROM mail_read_mail_uid_tbl WHERE local_uid in (%s) ORDER BY server_uid", mail_ids);
@@ -13798,14 +14156,14 @@ FINISH_OFF:
#endif
-INTERNAL_FUNC int emstorage_delete_triggers_from_lucene()
+INTERNAL_FUNC int emstorage_delete_triggers_from_lucene(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int ret = true, transaction = true;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP TRIGGER triggerDelete;");
error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -13831,13 +14189,13 @@ INTERNAL_FUNC int emstorage_delete_triggers_from_lucene()
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
}
-INTERNAL_FUNC int emstorage_update_tag_id(int old_filter_id, int new_filter_id, int *err_code)
+INTERNAL_FUNC int emstorage_update_tag_id(char *multi_user_name, int old_filter_id, int new_filter_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("new_filter_id[%d], old_filter_id[%d]", new_filter_id, old_filter_id);
int ret = false;
@@ -13852,9 +14210,9 @@ INTERNAL_FUNC int emstorage_update_tag_id(int old_filter_id, int new_filter_id,
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_tbl SET tag_id=%d WHERE tag_id=%d ", new_filter_id, old_filter_id);
@@ -13868,7 +14226,7 @@ INTERNAL_FUNC int emstorage_update_tag_id(int old_filter_id, int new_filter_id,
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -13877,7 +14235,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, int dest_mailbox_id, int dest_mailbox_type, int reset, emstorage_rule_tbl_t *rule, int ** filtered_mail_id_list, int *count_of_mails, int *err_code)
+INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int account_id, int dest_mailbox_id, int dest_mailbox_type, int reset, emstorage_rule_tbl_t *rule, int ** filtered_mail_id_list, int *count_of_mails, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], dest_mailbox_id[%d] rule[%p], filtered_mail_id_list[%p], count_of_mails[%p], err_code[%p]", account_id, dest_mailbox_id, rule, filtered_mail_id_list, count_of_mails, err_code);
@@ -13894,7 +14252,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, int dest_mailbo
int tag_id = rule->rule_id;
char **result = NULL, *where_pararaph = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT mail_id FROM mail_tbl ");
@@ -14045,8 +14403,7 @@ FINISH_OFF:
}
#define EMAIL_SLOT_UNIT 25
-
-INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_set_mail_slot_size(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%p] new_slot_size[%d], err_code[%p]", account_id, mailbox_id, new_slot_size, err_code);
int ret = false, err = EMAIL_ERROR_NONE;
@@ -14054,9 +14411,9 @@ INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, int mailbox_id, i
char *where_pararaph = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
int and = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, err);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, err);
if (new_slot_size > 0)
SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_box_tbl SET mail_slot_size = %d ", new_slot_size);
@@ -14094,7 +14451,7 @@ INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, int mailbox_id, i
SNPRINTF(where_pararaph + EM_SAFE_STRLEN(where_pararaph), where_pararaph_length - EM_SAFE_STRLEN(where_pararaph), " %s total_mail_count_on_server > mail_slot_size ", (and ? "AND" : "WHERE"));
if (strlen(sql_query_string) + EM_SAFE_STRLEN(where_pararaph) < QUERY_SIZE) /* prevent 34363 */
- strncat(sql_query_string, where_pararaph, EM_SAFE_STRLEN(where_pararaph));
+ strcat(sql_query_string, where_pararaph);
else {
EM_DEBUG_EXCEPTION("Query buffer overflowed !!!");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -14111,7 +14468,7 @@ INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, int mailbox_id, i
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, err);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, err);
EM_SAFE_FREE(where_pararaph);
@@ -14122,7 +14479,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t* meeting_req, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_meeting_request(char *multi_user_name, int account_id, int input_mailbox_id, email_meeting_request_t* meeting_req, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], meeting_req[%p], transaction[%d], err_code[%p]", account_id, input_mailbox_id, meeting_req, transaction, err_code);
@@ -14144,8 +14501,8 @@ INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, int input_mailbo
int col_index = 0;
time_t temp_unix_time = 0;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_meeting_tbl VALUES "
@@ -14227,7 +14584,7 @@ INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, int input_mailbo
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -14243,7 +14600,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_query_meeting_request(const char *conditional_clause, email_meeting_request_t **output_meeting_req, int *output_result_count, int transaction)
+INTERNAL_FUNC int emstorage_query_meeting_request(char *multi_user_name, const char *conditional_clause, email_meeting_request_t **output_meeting_req, int *output_result_count, int transaction)
{
EM_DEBUG_FUNC_BEGIN("conditional_clause[%s] output_meeting_req[%p] output_result_count[%p] transaction[%d]", conditional_clause, output_meeting_req, output_result_count, transaction);
@@ -14268,7 +14625,7 @@ INTERNAL_FUNC int emstorage_query_meeting_request(const char *conditional_clause
col_index = _field_count_of_table[CREATE_TABLE_MAIL_MEETING_TBL];
EM_DEBUG_LOG("col_index [%d]", col_index);
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -14319,10 +14676,10 @@ INTERNAL_FUNC int emstorage_query_meeting_request(const char *conditional_clause
FINISH_OFF:
- if (result)
+ if(result)
sqlite3_free_table(result);
- if (err == EMAIL_ERROR_NONE) {
+ if (err == EMAIL_ERROR_NONE) {
if (p_temp_meeting_req)
*output_meeting_req = p_temp_meeting_req;
*output_result_count = count;
@@ -14332,14 +14689,13 @@ FINISH_OFF:
EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
- if (local_db_handle)
- sqlite3_db_release_memory(local_db_handle);
+// sqlite3_db_release_memory(local_db_handle);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-INTERNAL_FUNC int emstorage_get_meeting_request(int mail_id, email_meeting_request_t ** meeting_req, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_meeting_request(char *multi_user_name, int mail_id, email_meeting_request_t ** meeting_req, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -14354,7 +14710,7 @@ INTERNAL_FUNC int emstorage_get_meeting_request(int mail_id, email_meeting_reque
SNPRINTF(conditional_clause, QUERY_SIZE, " WHERE mail_id = %d", mail_id);
EM_DEBUG_LOG("conditional_clause [%s]", conditional_clause);
- if((error = emstorage_query_meeting_request(conditional_clause, meeting_req, &count, transaction)) != EMAIL_ERROR_NONE) {
+ if((error = emstorage_query_meeting_request(multi_user_name, conditional_clause, meeting_req, &count, transaction)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_meeting_request failed. [%d]", error);
goto FINISH_OFF;
}
@@ -14383,8 +14739,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_update_meeting_request(email_meeting_request_t* meeting_req, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_meeting_request(char *multi_user_name, email_meeting_request_t* meeting_req, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("meeting_req[%p], transaction[%d], err_code[%p]", meeting_req, transaction, err_code);
@@ -14402,8 +14757,8 @@ INTERNAL_FUNC int emstorage_update_meeting_request(email_meeting_request_t* meet
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string),
@@ -14473,7 +14828,7 @@ INTERNAL_FUNC int emstorage_update_meeting_request(email_meeting_request_t* meet
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -14490,7 +14845,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_meeting_request(int account_id, int mail_id, int input_mailbox_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_meeting_request(char *multi_user_name, int account_id, int mail_id, int input_mailbox_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], input_mailbox_id[%d], transaction[%d], err_code[%p]", account_id, mail_id, input_mailbox_id, transaction, err_code);
@@ -14507,8 +14862,8 @@ INTERNAL_FUNC int emstorage_delete_meeting_request(int account_id, int mail_id,
int and = false;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_meeting_tbl ");
@@ -14533,7 +14888,7 @@ INTERNAL_FUNC int emstorage_delete_meeting_request(int account_id, int mail_id,
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code)
*err_code = error;
@@ -14555,8 +14910,7 @@ INTERNAL_FUNC void emstorage_free_meeting_request(email_meeting_request_t *meeti
EM_DEBUG_FUNC_END();
}
-
-INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(int account_id, int input_mailbox_id, int input_mailbox_type, int mail_slot_size, int **mail_id_list, int *mail_id_count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(char *multi_user_name, int account_id, int input_mailbox_id, int mail_slot_size, int **mail_id_list, int *mail_id_count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], input_mailbox_id [%d], mail_slot_size [%d], mail_id_list [%p], mail_id_count [%p], transaction [%d], err_code [%p]", account_id, input_mailbox_id, mail_slot_size, mail_id_list, mail_id_count, transaction, err_code);
EM_PROFILE_BEGIN(profile_emstorage_get_overflowed_mail_id_list);
@@ -14575,11 +14929,11 @@ INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(int account_id, int inpu
return false;
}
- SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT mail_id FROM mail_tbl WHERE account_id = %d AND mailbox_id = %d AND mailbox_type = %d ORDER BY date_time DESC LIMIT %d, 10000", account_id, input_mailbox_id, input_mailbox_type, mail_slot_size);
+ SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT mail_id FROM mail_tbl WHERE account_id = %d AND mailbox_id = %d ORDER BY date_time DESC LIMIT %d, 10000", account_id, input_mailbox_id, mail_slot_size);
EM_DEBUG_LOG_SEC("query[%s].", sql_query_string);
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_mail_id_count, 0, NULL), rc);
@@ -14634,8 +14988,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(int mail_id, int *thread_id, int *err_code)
+INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(char *multi_user_name, int mail_id, int *thread_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], thread_id[%p], err_code[%p]", mail_id, thread_id, err_code);
@@ -14652,7 +15005,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(int mail_id, int *thread_id
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
memset(sql_query_string, 0, QUERY_SIZE);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT thread_id FROM mail_tbl WHERE mail_id = %d", mail_id);
@@ -14685,9 +15038,22 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int mailbox_id, int thread_id, int *updated_thread_id, int latest_mail_id, int thread_item_count, int noti_type, int transaction, int *err_code)
-{
- EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id [%d], thread_id[%d], updated_thread_id[%p], latest_mail_id [%d], thread_item_count[%d], err_code[%p]", account_id, mailbox_id, thread_id, updated_thread_id, latest_mail_id, thread_item_count, err_code);
+INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name,
+ int account_id,
+ int mailbox_id,
+ int mailbox_type,
+ int thread_id,
+ int *updated_thread_id,
+ int latest_mail_id,
+ int thread_item_count,
+ int noti_type,
+ int transaction,
+ int *err_code)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id [%d], thread_id[%d], updated_thread_id[%p], "
+ "latest_mail_id [%d], thread_item_count[%d], err_code[%p]",
+ account_id, mailbox_id, thread_id, updated_thread_id,
+ latest_mail_id, thread_item_count, err_code);
int rc = -1, ret = false;
int err = EMAIL_ERROR_NONE;
@@ -14702,7 +15068,7 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int mailbo
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
if (thread_item_count == 0 && latest_mail_id == 0) {
memset(sql_query_string, 0, QUERY_SIZE);
@@ -14731,10 +15097,9 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int mailbo
sqlite3_free_table(result);
}
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, err);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, err);
- if (thread_item_count < 0)
- {
+ if (thread_item_count < 0) {
memset(sql_query_string, 0, QUERY_SIZE);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET thread_item_count = 0 WHERE account_id = %d AND thread_id = %d", account_id, thread_id);
EM_DEBUG_LOG_SEC("query[%s]", sql_query_string);
@@ -14776,7 +15141,7 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int mailbo
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, err);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, err);
if (thread_id != latest_mail_id)
{
@@ -14811,7 +15176,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_update_thread_id_of_mail(int account_id, int mailbox_id, int mail_id, int thread_id, int thread_item_count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_thread_id_of_mail(char *multi_user_name, int account_id, int mailbox_id, int mail_id, int thread_id, int thread_item_count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id [%d], mail_id[%d], thread_id[%d], thread_item_count[%d], err_code[%p]", account_id, mailbox_id, mail_id, thread_id, thread_item_count, err_code);
@@ -14826,9 +15191,9 @@ INTERNAL_FUNC int emstorage_update_thread_id_of_mail(int account_id, int mailbox
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, err);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, err);
memset(sql_query_string, 0, QUERY_SIZE);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET thread_item_count = %d, thread_id = %d WHERE account_id = %d AND mail_id = %d", thread_item_count, thread_id, account_id, mail_id);
@@ -14841,7 +15206,7 @@ INTERNAL_FUNC int emstorage_update_thread_id_of_mail(int account_id, int mailbox
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, err);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, err);
if (err_code != NULL)
*err_code = err;
@@ -14850,12 +15215,6 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC void emstorage_flush_db_cache()
-{
- /* sqlite3_release_memory(-1); */
-}
-
#ifdef __FEATURE_LOCAL_ACTIVITY__
/**
* emstorage_add_activity - Add Email Local activity during OFFLINE mode
@@ -14880,10 +15239,11 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- memset(sql_query_string, 0x00 , sizeof(sql_query_string));
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
+
+ memset(sql_query_string, 0x00 , sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string), "INSERT INTO mail_local_activity_tbl VALUES (?, ?, ?, ?, ?, ?, ?)");
EM_DEBUG_LOG(">>>>> ACTIVITY ID [ %d ] ", local_activity->activity_id);
@@ -14922,7 +15282,7 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -14966,7 +15326,7 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -15078,7 +15438,7 @@ INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
/* increase unique id */
@@ -15110,7 +15470,7 @@ INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code
}
-INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int ** activity_id_list, int *activity_id_count, int lowest_activity_type, int highest_activity_type, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_activity_id_list(char *multi_user_name, int account_id, int ** activity_id_list, int *activity_id_count, int lowest_activity_type, int highest_activity_type, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -15130,7 +15490,7 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int ** activity
int *activity_ids = NULL;
int col_index = 0;
char **result = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -15237,8 +15597,8 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
int query_and = 0;
int query_where = 0;
char sql_query_string[8192] = { 0x00, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -15299,7 +15659,7 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -15542,6 +15902,7 @@ static int _make_filter_rule_string(email_list_filter_rule_t *input_list_filter_
mod_field_name_string = em_malloc(sizeof(char) * length_field_name);
if (mod_field_name_string == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
+ EM_SAFE_FREE(temp_field_name_string);
ret = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
@@ -15549,6 +15910,7 @@ static int _make_filter_rule_string(email_list_filter_rule_t *input_list_filter_
mod_value_string = em_malloc(sizeof(char) * length_value);
if (mod_value_string == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
+ EM_SAFE_FREE(temp_field_name_string);
ret = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
@@ -15606,7 +15968,7 @@ FINISH_OFF:
return ret;
}
-static int _make_filter_attach_rule_string(email_list_filter_rule_attach_t *input_list_filter_rule, char **output_string)
+static int _make_filter_attach_rule_string(char *multi_user_name, email_list_filter_rule_attach_t *input_list_filter_rule, char **output_string)
{
EM_DEBUG_FUNC_BEGIN("input_list_filter_rule [%p], output_string [%p]", input_list_filter_rule, output_string);
@@ -15649,7 +16011,8 @@ static int _make_filter_attach_rule_string(email_list_filter_rule_attach_t *inpu
goto FINISH_OFF;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
+
EMSTORAGE_START_READ_TRANSACTION(true);
SNPRINTF(sql_query_string, QUERY_SIZE, "SELECT mail_id FROM mail_attachment_tbl %s", result_rule_string);
@@ -15683,7 +16046,7 @@ static int _make_filter_attach_rule_string(email_list_filter_rule_attach_t *inpu
sqlite3_free_table(result);
EMSTORAGE_FINISH_READ_TRANSACTION(true);
- sqlite3_db_release_memory(local_db_handle);
+// sqlite3_db_release_memory(local_db_handle);
query_size = (10 * count) + strlen("mail_id IN ( ) ");
@@ -15711,7 +16074,7 @@ FINISH_OFF:
return error;
}
-static int _make_filter_fts_rule_string(email_list_filter_rule_fts_t *input_list_filter_rule, char **output_string)
+static int _make_filter_fts_rule_string(char *multi_user_name, email_list_filter_rule_fts_t *input_list_filter_rule, char **output_string)
{
EM_DEBUG_FUNC_BEGIN("input_list_filter_rule [%p], output_string [%p]", input_list_filter_rule, output_string);
char *field_name_string = NULL;
@@ -15752,7 +16115,8 @@ static int _make_filter_fts_rule_string(email_list_filter_rule_fts_t *input_list
goto FINISH_OFF;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
+
EMSTORAGE_START_READ_TRANSACTION(true);
SNPRINTF(sql_query_string, QUERY_SIZE, "SELECT mail_id FROM mail_text_tbl %s", result_rule_string);
@@ -15787,7 +16151,7 @@ static int _make_filter_fts_rule_string(email_list_filter_rule_fts_t *input_list
sqlite3_free_table(result);
EMSTORAGE_FINISH_READ_TRANSACTION(true);
- sqlite3_db_release_memory(local_db_handle);
+// sqlite3_db_release_memory(local_db_handle);
query_size = (10 * count) + strlen("mail_id IN ( ) ");
@@ -15814,7 +16178,7 @@ FINISH_OFF:
return error;
}
-static int _make_order_rule_string(email_list_sorting_rule_t *input_sorting_rule, char **output_string) {
+static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rule_t *input_sorting_rule, char **output_string) {
EM_DEBUG_FUNC_BEGIN("input_sorting_rule [%p], output_string [%p]", input_sorting_rule, output_string);
char result_rule_string[QUERY_SIZE] = { 0 , };
@@ -15828,10 +16192,11 @@ static int _make_order_rule_string(email_list_sorting_rule_t *input_sorting_rule
char *tmp_str2 = NULL;
char query_per_account[QUERY_SIZE] = { 0 , };
- if (input_sorting_rule->force_boolean_check)
+ if(input_sorting_rule->force_boolean_check) {
SNPRINTF(result_rule_string, QUERY_SIZE, "%s = 0 ", emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute));
+ }
else
- SNPRINTF(result_rule_string, QUERY_SIZE, "%s", emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute));
+ EM_SAFE_STRCPY(result_rule_string, emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute));
switch (input_sorting_rule->sort_order) {
case EMAIL_SORT_ORDER_ASCEND :
@@ -15867,7 +16232,7 @@ static int _make_order_rule_string(email_list_sorting_rule_t *input_sorting_rule
break;
case EMAIL_SORT_ORDER_TO_CCBCC_ALL :
- if (!emstorage_get_account_list(&count, &account_tbl_array, true, false, NULL)) {
+ if (!emstorage_get_account_list(multi_user_name, &count, &account_tbl_array, true, false, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed");
goto FINISH_OFF;
}
@@ -15935,7 +16300,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(email_list_filter_t *input_filter_list, int input_filter_count, email_list_sorting_rule_t *input_sorting_rule_list, int input_sorting_rule_count, int input_start_index, int input_limit_count, char **output_conditional_clause)
+INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char *multi_user_name, email_list_filter_t *input_filter_list, int input_filter_count, email_list_sorting_rule_t *input_sorting_rule_list, int input_sorting_rule_count, int input_start_index, int input_limit_count, char **output_conditional_clause)
{
EM_DEBUG_FUNC_BEGIN("input_filter_list [%p], input_filter_count[%d], input_sorting_rule_list[%p], input_sorting_rule_count [%d], input_start_index [%d], input_limit_count [%d], output_conditional_clause [%p]", input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, output_conditional_clause);
int ret = EMAIL_ERROR_NONE;
@@ -15970,12 +16335,12 @@ INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(email
case EMAIL_LIST_FILTER_ITEM_RULE_FTS :
EM_DEBUG_LOG_DEV("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_RULE_FTS", i);
- _make_filter_fts_rule_string(&(input_filter_list[i].list_filter_item.rule_fts), &result_string_for_a_item);
+ _make_filter_fts_rule_string(multi_user_name, &(input_filter_list[i].list_filter_item.rule_fts), &result_string_for_a_item);
break;
case EMAIL_LIST_FILTER_ITEM_RULE_ATTACH :
EM_DEBUG_LOG_DEV("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_RULE_ATTACH", i);
- _make_filter_attach_rule_string(&(input_filter_list[i].list_filter_item.rule_attach), &result_string_for_a_item);
+ _make_filter_attach_rule_string(multi_user_name, &(input_filter_list[i].list_filter_item.rule_attach), &result_string_for_a_item);
break;
case EMAIL_LIST_FILTER_ITEM_OPERATOR :
@@ -16030,7 +16395,7 @@ INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(email
strcat(conditional_clause_string, "ORDER BY ");
for ( i = 0; i < input_sorting_rule_count; i++) {
- if( (ret = _make_order_rule_string(&input_sorting_rule_list[i], &result_string_for_a_item)) != EMAIL_ERROR_NONE) {
+ if( (ret = _make_order_rule_string(multi_user_name, &input_sorting_rule_list[i], &result_string_for_a_item)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_make_order_rule_string failed. [%d]", ret);
goto FINISH_OFF;
}
@@ -16105,7 +16470,7 @@ INTERNAL_FUNC int emstorage_free_list_filter(email_list_filter_t **input_filter_
return err;
}
-INTERNAL_FUNC int emstorage_add_certificate(emstorage_certificate_tbl_t *certificate, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_certificate(char *multi_user_name, emstorage_certificate_tbl_t *certificate, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("certificate:[%p], transaction:[%d], err_code:[%p]", certificate, transaction, err_code);
@@ -16124,9 +16489,10 @@ INTERNAL_FUNC int emstorage_add_certificate(emstorage_certificate_tbl_t *certifi
#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__
char cert_password_file_name[MAX_PW_FILE_NAME_LENGTH];
#endif
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
char *sql = "SELECT max(rowid) FROM mail_certificate_tbl;";
char **result = NULL;
@@ -16193,7 +16559,7 @@ INTERNAL_FUNC int emstorage_add_certificate(emstorage_certificate_tbl_t *certifi
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
if (rc != SQLITE_OK) {
@@ -16253,7 +16619,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_certificate_list(int *select_num, emstorage_certificate_tbl_t **certificate_list, int transaction, int with_password, int *err_code)
+INTERNAL_FUNC int emstorage_get_certificate_list(char *multi_user_name, int *select_num, emstorage_certificate_tbl_t **certificate_list, int transaction, int with_password, int *err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -16270,7 +16636,7 @@ INTERNAL_FUNC int emstorage_get_certificate_list(int *select_num, emstorage_cert
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
char sql_query_string[QUERY_SIZE] = {0, };
@@ -16390,7 +16756,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_certificate_by_email_address(char *email_address, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code)
+INTERNAL_FUNC int emstorage_get_certificate_by_email_address(char *multi_user_name, char *email_address, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("email_address[%s], certificate[%p], transaction[%d], err_code[%p]", email_address, certificate, transaction, err_code);
@@ -16411,7 +16777,8 @@ INTERNAL_FUNC int emstorage_get_certificate_by_email_address(char *email_address
#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__
char cert_password_file_name[MAX_PW_FILE_NAME_LENGTH];
#endif
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
/* Make query string */
@@ -16498,7 +16865,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_get_certificate_by_index(int index, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code)
+INTERNAL_FUNC int emstorage_get_certificate_by_index(char *multi_user_name, int index, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("index[%d], certificate[%p], transaction[%d], err_code[%p]", index, certificate, transaction, err_code);
@@ -16519,7 +16886,8 @@ INTERNAL_FUNC int emstorage_get_certificate_by_index(int index, emstorage_certif
#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__
char cert_password_file_name[MAX_PW_FILE_NAME_LENGTH];
#endif
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
/* Make query string */
@@ -16607,7 +16975,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_delete_certificate(int certificate_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_certificate(char *multi_user_name, int certificate_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("certificate_id[%d], transaction[%d], err_code[%p]", certificate_id, transaction, err_code);
@@ -16620,8 +16988,8 @@ INTERNAL_FUNC int emstorage_delete_certificate(int certificate_id, int transacti
int rc = -1, ret = false;
int error = EMAIL_ERROR_NONE;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
/* TODO : delete password files - file names can be obtained from db or a rule that makes a name */
char sql_query_string[QUERY_SIZE] = {0, };
@@ -16653,7 +17021,7 @@ INTERNAL_FUNC int emstorage_delete_certificate(int certificate_id, int transacti
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -16662,7 +17030,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emstorage_update_certificate(int certificate_id, emstorage_certificate_tbl_t *certificate, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_update_certificate(char *multi_user_name, int certificate_id, emstorage_certificate_tbl_t *certificate, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("certificate_id[%d], certificate[%p], transaction[%d], err_code[%p]", certificate_id, certificate, transaction, err_code);
@@ -16681,8 +17049,9 @@ INTERNAL_FUNC int emstorage_update_certificate(int certificate_id, emstorage_cer
#ifdef __FEATURE_SUPPORT_PRIVATE_CERTIFICATE__
char cert_password_file_name[MAX_PW_FILE_NAME_LENGTH];
#endif
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_certificate_tbl SET"
@@ -16734,7 +17103,7 @@ INTERNAL_FUNC int emstorage_update_certificate(int certificate_id, emstorage_cer
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -16757,7 +17126,7 @@ FINISH_OFF:
}
/* Tasks --------------------------------------------------------------------------*/
-INTERNAL_FUNC int emstorage_add_task(email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int input_transaction, int *output_task_id)
+INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int input_transaction, int *output_task_id)
{
EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_priority[%p], input_task_parameter[%p] input_task_parameter_length[%d] input_transaction[%d] output_task_id[%p]", input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, input_transaction, output_task_id);
int ret = 0;
@@ -16776,8 +17145,8 @@ INTERNAL_FUNC int emstorage_add_task(email_task_type_t input_task_type, email_ta
return EMAIL_ERROR_INVALID_PARAM;
}
- local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(input_transaction, err);
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, input_transaction, err);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
@@ -16830,7 +17199,7 @@ INTERNAL_FUNC int emstorage_add_task(email_task_type_t input_task_type, email_ta
ret = (err == EMAIL_ERROR_NONE);
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(input_transaction, ret, err);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, input_transaction, ret, err);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
@@ -16844,7 +17213,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emstorage_delete_task(int task_id, int transaction)
+INTERNAL_FUNC int emstorage_delete_task(char *multi_user_name, int task_id, int transaction)
{
EM_DEBUG_FUNC_BEGIN("task_id[%d], transaction[%d]", task_id, transaction);
int ret = false;
@@ -16858,9 +17227,9 @@ INTERNAL_FUNC int emstorage_delete_task(int task_id, int transaction)
return EMAIL_ERROR_INVALID_PARAM;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, err);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, err);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_task_tbl WHERE task_id = %d", task_id);
err = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -16872,20 +17241,21 @@ INTERNAL_FUNC int emstorage_delete_task(int task_id, int transaction)
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, err);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, err);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-INTERNAL_FUNC int emstorage_update_task_status(int task_id, email_task_status_type_t task_status, int transaction)
+INTERNAL_FUNC int emstorage_update_task_status(char *multi_user_name, int task_id, email_task_status_type_t task_status, int transaction)
{
EM_DEBUG_FUNC_BEGIN("task_id[%d] task_status[%d] transaction[%d]", task_id, task_status, transaction);
int ret = false;
int err = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, err);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, err);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_task_tbl SET"
@@ -16902,15 +17272,21 @@ INTERNAL_FUNC int emstorage_update_task_status(int task_id, email_task_status_ty
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, err);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, err);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-INTERNAL_FUNC int emstorage_query_task(const char *input_conditional_clause, const char *input_ordering_clause, email_task_t **output_task_list, int *output_task_count)
+INTERNAL_FUNC int emstorage_query_task(char *multi_user_name,
+ const char *input_conditional_clause,
+ const char *input_ordering_clause,
+ email_task_t **output_task_list,
+ int *output_task_count)
{
- EM_DEBUG_FUNC_BEGIN("input_conditional_clause[%p], input_ordering_clause [%p], output_task_list[%p], output_task_count[%d]", input_conditional_clause, input_ordering_clause, output_task_list, output_task_count);
+ EM_DEBUG_FUNC_BEGIN("input_conditional_clause[%p], input_ordering_clause [%p], "
+ "output_task_list[%p], output_task_count[%d]",
+ input_conditional_clause, input_ordering_clause, output_task_list, output_task_count);
int i = 0, count = 0, rc = -1;
int cur_query = 0;
int field_index = 0;
@@ -16925,9 +17301,10 @@ INTERNAL_FUNC int emstorage_query_task(const char *input_conditional_clause, con
EM_IF_NULL_RETURN_VALUE(input_conditional_clause, false);
EM_IF_NULL_RETURN_VALUE(output_task_count, false);
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
- SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, "SELECT COUNT(*) FROM mail_task_tbl %s", input_conditional_clause);
+ SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE,
+ "SELECT COUNT(*) FROM mail_task_tbl %s", input_conditional_clause);
EM_DEBUG_LOG_SEC("emstorage_query_mail_list : query[%s].", sql_query_string);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
@@ -16945,7 +17322,8 @@ INTERNAL_FUNC int emstorage_query_task(const char *input_conditional_clause, con
goto FINISH_OFF;
}
- SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE, "SELECT %s FROM mail_task_tbl %s %s", field_list, input_conditional_clause, input_ordering_clause);
+ SNPRINTF_OFFSET(sql_query_string, cur_query, QUERY_SIZE,
+ "SELECT %s FROM mail_task_tbl %s %s", field_list, input_conditional_clause, input_ordering_clause);
EM_DEBUG_LOG_SEC("emstorage_query_mail_list : query[%s].", sql_query_string);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
@@ -16958,7 +17336,7 @@ INTERNAL_FUNC int emstorage_query_task(const char *input_conditional_clause, con
EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
("sqlite3_step fail:%d", rc));
- if (rc == SQLITE_DONE) {
+ if (rc == SQLITE_DONE) {
EM_DEBUG_EXCEPTION("no task found...");
err = EMAIL_ERROR_TASK_NOT_FOUND;
count = 0;
@@ -16989,17 +17367,20 @@ INTERNAL_FUNC int emstorage_query_task(const char *input_conditional_clause, con
}
FINISH_OFF:
+
if (err == EMAIL_ERROR_NONE) {
if (output_task_list)
*output_task_list = task_item_from_tbl;
*output_task_count = count;
+ } else {
+ if (task_item_from_tbl) {
+ for (i = 0; i < count; i++)
+ EM_SAFE_FREE(task_item_from_tbl[i].task_parameter);
+
+ free(task_item_from_tbl);
+ }
}
- else {
- for (i = 0; i < count; i++) {
- EM_SAFE_FREE(task_item_from_tbl[i].task_parameter);
- }
- EM_SAFE_FREE(task_item_from_tbl);
- }
+
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
hStmt = NULL;
@@ -17009,12 +17390,11 @@ FINISH_OFF:
}
}
-
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(int account_id, email_mailbox_type_e input_mailbox_type, char *message_id, char *server_uid, int *mail_id)
+INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *multi_user_name, int account_id, email_mailbox_type_e input_mailbox_type, char *message_id, char *server_uid, int *mail_id)
{
EM_DEBUG_FUNC_BEGIN("account_id:[%d], mailbox_type:[%d], message_id:[%s], server_uid:[%s]", account_id, input_mailbox_type, message_id, server_uid);
int err = EMAIL_ERROR_NONE;
@@ -17032,7 +17412,7 @@ INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(int accoun
char *where_pararaph = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
char **result = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT mail_id from mail_tbl ");
@@ -17098,7 +17478,7 @@ FINISH_OFF:
/* Tasks --------------------------------------------------------------------------*/
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
-INTERNAL_FUNC int emstorage_add_auto_download_activity(email_event_auto_download *local_activity, int *activity_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_add_auto_download_activity(char *multi_user_name, email_event_auto_download *local_activity, int *activity_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("local_activity[%p], activity_id[%p], transaction[%d], err_code[%p]", local_activity, activity_id, transaction, err_code);
@@ -17116,8 +17496,10 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(email_event_auto_download
char sql_query_string[QUERY_SIZE] = {0, };
DB_STMT hStmt = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
+
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_auto_download_activity_tbl VALUES "
@@ -17128,6 +17510,7 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(email_event_auto_download
",?" /* Local Mail ID */
",?" /* Server mail ID */
",?" /* Mailbox ID*/
+ ",?" /* Multi USER NAME */
") ");
char *sql = "SELECT max(rowid) FROM mail_auto_download_activity_tbl;";
@@ -17164,6 +17547,7 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(email_event_auto_download
_bind_stmt_field_data_int(hStmt, i++, local_activity->mail_id);
_bind_stmt_field_data_int(hStmt, i++, local_activity->server_mail_id);
_bind_stmt_field_data_int(hStmt, i++, local_activity->mailbox_id);
+ _bind_stmt_field_data_string(hStmt, i++, (char *)local_activity->multi_user_name, 0, MAX_USER_NAME_LENGTH);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
@@ -17176,7 +17560,7 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(email_event_auto_download
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (hStmt != NULL) {
rc = sqlite3_finalize(hStmt);
hStmt = NULL;
@@ -17194,7 +17578,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_delete_auto_download_activity(int account_id, int mail_id, int activity_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_auto_download_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d] , activity_id[%d], transaction[%d], err_code[%p]", account_id, mail_id, activity_id, transaction, err_code);
@@ -17210,9 +17594,9 @@ INTERNAL_FUNC int emstorage_delete_auto_download_activity(int account_id, int ma
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
if (activity_id == 0)
@@ -17239,7 +17623,7 @@ INTERNAL_FUNC int emstorage_delete_auto_download_activity(int account_id, int ma
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -17248,8 +17632,7 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC int emstorage_delete_all_auto_download_activity(int account_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_all_auto_download_activity(char *multi_user_name, int account_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], transaction[%d], err_code[%p]", account_id, transaction, err_code);
@@ -17264,8 +17647,10 @@ INTERNAL_FUNC int emstorage_delete_all_auto_download_activity(int account_id, in
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_auto_download_activity_tbl WHERE account_id = %d", account_id);
@@ -17287,7 +17672,7 @@ INTERNAL_FUNC int emstorage_delete_all_auto_download_activity(int account_id, in
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -17297,7 +17682,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_delete_auto_download_activity_by_mailbox(int account_id, int mailbox_id, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_delete_auto_download_activity_by_mailbox(char *multi_user_name, int account_id, int mailbox_id, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], transaction[%d], err_code[%p]", account_id, mailbox_id, transaction, err_code);
@@ -17312,8 +17697,10 @@ INTERNAL_FUNC int emstorage_delete_auto_download_activity_by_mailbox(int account
int ret = false;
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
+
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_auto_download_activity_tbl WHERE account_id = %d AND mailbox_id = %d", account_id, mailbox_id);
@@ -17335,7 +17722,7 @@ INTERNAL_FUNC int emstorage_delete_auto_download_activity_by_mailbox(int account
ret = true;
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -17345,7 +17732,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_get_auto_download_activity(int account_id, int input_mailbox_id, email_event_auto_download **event_start, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_auto_download_activity(char *multi_user_name, int account_id, int input_mailbox_id, email_event_auto_download **event_start, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], event_start[%p], err_code[%p]", account_id, event_start, err_code);
@@ -17366,7 +17753,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity(int account_id, int input
email_event_auto_download *event_list = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -17458,7 +17845,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_get_auto_download_activity_count(int *activity_count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_auto_download_activity_count(char *multi_user_name, int *activity_count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("activity_count[%p], err_code[%p]", activity_count, err_code);
@@ -17475,7 +17862,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity_count(int *activity_count
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -17521,7 +17908,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_get_auto_download_account_list(int **account_list, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_auto_download_account_list(char *multi_user_name, int **account_list, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%p] err_code[%p]", account_list, count, err_code);
@@ -17540,7 +17927,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_account_list(int **account_list, i
int *result_account_list = NULL;
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -17619,7 +18006,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(int account_id, int **mailbox_list, int *count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(char *multi_user_name, int account_id, int **mailbox_list, int *count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], count[%p] err_code[%p]", account_id, mailbox_list, count, err_code);
@@ -17638,7 +18025,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(int account_id, int *
DB_STMT hStmt = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
@@ -17721,7 +18108,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_get_auto_download_activity_count_by_mailbox(int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code)
+INTERNAL_FUNC int emstorage_get_auto_download_activity_count_by_mailbox(char *multi_user_name, int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], activity_count[%p], err_code[%p]", account_id, activity_count, err_code);
@@ -17737,7 +18124,8 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity_count_by_mailbox(int acco
int error = EMAIL_ERROR_NONE;
char sql_query_string[QUERY_SIZE] = {0, };
DB_STMT hStmt = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_START_READ_TRANSACTION(transaction);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
@@ -17781,7 +18169,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emstorage_update_auto_download_activity(char *old_server_uid, char *new_server_uid, char *mailbox_name, int mailbox_id, int *err_code)
+INTERNAL_FUNC int emstorage_update_auto_download_activity(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mailbox_name, int mailbox_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("old_server_uid[%s], new_server_uid[%s], mailbox_id[%d]", old_server_uid, new_server_uid, mailbox_id);
@@ -17796,9 +18184,9 @@ INTERNAL_FUNC int emstorage_update_auto_download_activity(char *old_server_uid,
return false;
}
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
- EMSTORAGE_START_WRITE_TRANSACTION(transaction, error);
+ EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
memset(sql_query_string, 0x00, sizeof(sql_query_string));
if (mailbox_id > 0)
@@ -17824,7 +18212,7 @@ INTERNAL_FUNC int emstorage_update_auto_download_activity(char *old_server_uid,
FINISH_OFF:
- EMSTORAGE_FINISH_WRITE_TRANSACTION(transaction, ret, error);
+ EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
if (err_code != NULL)
*err_code = error;
@@ -17893,7 +18281,7 @@ FINISH_OFF:
return 0;
}
-static int emstorage_get_column_information_from_table(const char *input_table_name, GList **output_column_info)
+static int emstorage_get_column_information_from_table(char *multi_user_name, const char *input_table_name, GList **output_column_info)
{
EM_DEBUG_FUNC_BEGIN("input_table_name[%p] output_column_info[%p]", input_table_name, output_column_info);
int err = EMAIL_ERROR_NONE;
@@ -17901,7 +18289,7 @@ static int emstorage_get_column_information_from_table(const char *input_table_n
char *error_message_from_sqlite = NULL;
char sql_query_string[QUERY_SIZE] = {0, };
GList *new_list = NULL;
- sqlite3 *local_db_handle = emstorage_get_db_connection();
+ sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
SNPRINTF(sql_query_string, QUERY_SIZE, "pragma table_info(%s);", input_table_name);
@@ -17921,7 +18309,7 @@ static int emstorage_get_column_information_from_table(const char *input_table_n
return err;
}
-static int emstorage_create_renamed_table(char **input_full_query, int input_query_index, char *input_source_table_name, char *input_new_table_name)
+static int emstorage_create_renamed_table(char *multi_user_name, char **input_full_query, int input_query_index, char *input_source_table_name, char *input_new_table_name)
{
EM_DEBUG_FUNC_BEGIN("input_full_query [%p] input_query_index[%d] input_source_table_name[%p] input_new_table_name[%p]", input_full_query, input_query_index, input_source_table_name, input_new_table_name);
int error = EMAIL_ERROR_NONE;
@@ -17935,7 +18323,7 @@ static int emstorage_create_renamed_table(char **input_full_query, int input_qu
goto FINISH_OFF;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "BEGIN;", NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {goto FINISH_OFF; }, ("SQL(BEGIN EXCLUSIVE) exec fail:%d -%s", rc, sqlite3_errmsg(local_db_handle)));
@@ -17959,7 +18347,7 @@ FINISH_OFF:
return error;
}
-static int emstorage_add_column(char *input_table_name, email_column_info_t *input_new_column)
+static int emstorage_add_column(char *multi_user_name, char *input_table_name, email_column_info_t *input_new_column)
{
EM_DEBUG_FUNC_BEGIN("input_table_name[%p] input_new_column[%p]", input_table_name, input_new_column);
int error = EMAIL_ERROR_NONE;
@@ -17973,7 +18361,7 @@ static int emstorage_add_column(char *input_table_name, email_column_info_t *inp
goto FINISH_OFF;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "BEGIN;", NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {goto FINISH_OFF; }, ("SQL(BEGIN EXCLUSIVE) exec fail:%d -%s", rc, sqlite3_errmsg(local_db_handle)));
@@ -17992,7 +18380,7 @@ FINISH_OFF:
return error;
}
-static int emstorage_drop_table(char *input_table_name)
+static int emstorage_drop_table(char *multi_user_name, char *input_table_name)
{
EM_DEBUG_FUNC_BEGIN("input_table_name[%p]", input_table_name);
int error = EMAIL_ERROR_NONE;
@@ -18006,7 +18394,7 @@ static int emstorage_drop_table(char *input_table_name)
goto FINISH_OFF;
}
- local_db_handle = emstorage_get_db_connection();
+ local_db_handle = emstorage_get_db_connection(multi_user_name);
EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "BEGIN;", NULL, NULL, NULL), rc);
EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {goto FINISH_OFF; }, ("SQL(BEGIN EXCLUSIVE) exec fail:%d -%s", rc, sqlite3_errmsg(local_db_handle)));
@@ -18037,7 +18425,7 @@ gint glist_compare_column_name(gconstpointer old_column_info, gconstpointer new_
return EM_SAFE_STRCMP((char*)left_one->column_name, (char*)right_one->column_name);
}
-INTERNAL_FUNC int emstorage_update_db_table_schema()
+INTERNAL_FUNC int emstorage_update_db_table_schema(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int i = 0;
@@ -18100,15 +18488,15 @@ INTERNAL_FUNC int emstorage_update_db_table_schema()
EM_DEBUG_LOG("table [%s] new_table [%s]", table_names[i][0], table_names[i][1]);
if (EM_SAFE_STRLEN(table_names[i][0]) && EM_SAFE_STRLEN(table_names[i][1])) {
/* Check existing of _new table */
- emstorage_drop_table(table_names[i][1]);
- error = emstorage_create_renamed_table(create_table_query, i, table_names[i][0], table_names[i][1]);
+ emstorage_drop_table(multi_user_name, table_names[i][1]);
+ error = emstorage_create_renamed_table(multi_user_name, create_table_query, i, table_names[i][0], table_names[i][1]);
if (error != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_create_renamed_table failed [%d]", error);
goto FINISH_OFF;
}
- emstorage_get_column_information_from_table(table_names[i][0], &column_list_of_old_table);
- emstorage_get_column_information_from_table(table_names[i][1], &column_list_of_new_table);
+ emstorage_get_column_information_from_table(multi_user_name, table_names[i][0], &column_list_of_old_table);
+ emstorage_get_column_information_from_table(multi_user_name, table_names[i][1], &column_list_of_new_table);
/* Compare fields and add new field */
for (j = 0; j < g_list_length(column_list_of_new_table); j++) {
@@ -18116,11 +18504,11 @@ INTERNAL_FUNC int emstorage_update_db_table_schema()
found_data = g_list_find_custom(column_list_of_old_table, (gconstpointer)new_column_info, glist_compare_column_name);
if (found_data == NULL) {
/* add new field*/
- emstorage_add_column(table_names[i][0], new_column_info);
+ emstorage_add_column(multi_user_name, table_names[i][0], new_column_info);
}
}
- emstorage_drop_table(table_names[i][1]);
+ emstorage_drop_table(multi_user_name, table_names[i][1]);
}
else
EM_DEBUG_LOG("Skipped");
@@ -18162,8 +18550,6 @@ FINISH_OFF:
EM_DEBUG_FUNC_END("error [%d]", error);
return error;
}
-
-
#endif /* __FEATURE_UPDATE_DB_TABLE_SCHEMA__ */
/*EOF*/
diff --git a/email-core/email-storage/include/email-storage.h b/email-core/email-storage/include/email-storage.h
index 679f537..bef9c21 100755
--- a/email-core/email-storage/include/email-storage.h
+++ b/email-core/email-storage/include/email-storage.h
@@ -55,6 +55,8 @@ extern "C"
#define MAX_INTEGER_LENGTH 5 /* 32767 -> 5 bytes */
#define FILE_MAX_BUFFER_SIZE 16 * 1024 /* 16 Kbyte */
+#define DB_STMT sqlite3_stmt *
+
typedef struct
{
int mail_id;
@@ -131,6 +133,9 @@ typedef struct
char *certificate_path; /* Sepeifies the certificate path of private*/
email_cipher_type cipher_type; /* Sepeifies the encryption algorithm*/
email_digest_type digest_type; /* Sepeifies the digest algorithm*/
+
+ /* Multi user and KNOX options */
+ char *user_name; /* Specifies the container name */
} emstorage_account_tbl_t;
typedef struct
@@ -267,6 +272,7 @@ typedef struct
int eas_data_length;
char *eas_data;
char *pgp_password;
+ char *user_name;
} emstorage_mail_tbl_t;
/* mail_attachment_tbl entity */
@@ -362,7 +368,7 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name);
* em_db_open
* description : open db and register busy handler
*/
-INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code);
+INTERNAL_FUNC int em_db_open(char *db_file_path, sqlite3 **sqlite_handle, int *err_code);
/*
* emstorage_db_open
@@ -371,7 +377,7 @@ INTERNAL_FUNC int em_db_open(sqlite3 **sqlite_handle, int *err_code);
* arguments :
* return :
*/
-INTERNAL_FUNC sqlite3* emstorage_db_open(int *err_code);
+INTERNAL_FUNC sqlite3* emstorage_db_open(char *multi_user_name, int *err_code);
/*
* emstorage_db_close
@@ -380,7 +386,7 @@ INTERNAL_FUNC sqlite3* emstorage_db_open(int *err_code);
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_db_close(int *err_code);
+INTERNAL_FUNC int emstorage_db_close(char *multi_user_name, int *err_code);
/*
* emstorage_open
@@ -389,7 +395,7 @@ INTERNAL_FUNC int emstorage_db_close(int *err_code);
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_open(int *err_code);
+INTERNAL_FUNC int emstorage_open(char *multi_user_name, int *err_code);
/*
* emstorage_close
@@ -407,8 +413,7 @@ INTERNAL_FUNC int emstorage_close(int *err_code);
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_create_table(emstorage_create_db_type_t type, int *err_code);
-
+INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create_db_type_t type, int *err_code);
INTERNAL_FUNC int emstorage_initialize_field_count();
@@ -421,8 +426,7 @@ INTERNAL_FUNC int emstorage_initialize_field_count();
* @remarks N/A
* @return This function returns true if there is no duplicated account. returns false and set error code if there are duplicated accounts or error
*/
-INTERNAL_FUNC int emstorage_check_duplicated_account(email_account_t *account, int transaction, int *err_code);
-
+INTERNAL_FUNC int emstorage_check_duplicated_account(char *multi_user_name, email_account_t *account, int transaction, int *err_code);
/**
* Get number of accounts from account table.
@@ -432,7 +436,7 @@ INTERNAL_FUNC int emstorage_check_duplicated_account(email_account_t *account, i
* @remarks N/A
* @return This function returns 0 on success or error code on failure.
*/
-INTERNAL_FUNC int emstorage_get_account_count(int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_account_count(char *multi_user_name, int *count, int transaction, int *err_code);
/**
* Get account from account table.
@@ -444,7 +448,7 @@ INTERNAL_FUNC int emstorage_get_account_count(int *count, int transaction, int *
* @remarks N/A
* @return This function returns 0 on success or error code on failure.
*/
-INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_tbl_t **account_list, int transaction, int with_password, int *err_code);
+INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_num, emstorage_account_tbl_t **account_list, int transaction, int with_password, int *err_code);
/*
* emstorage_get_account_by_name
@@ -459,9 +463,7 @@ INTERNAL_FUNC int emstorage_get_account_list(int *select_num, emstorage_account_
* return :
*/
/* sowmya.kr, 281209 Adding signature to options in email_account_t changes */
-
-INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, emstorage_account_tbl_t **account, int transaction, int *err_code);
-
+INTERNAL_FUNC int emstorage_get_account_by_id(char *multi_user_name, int account_id, int pulloption, emstorage_account_tbl_t **account, int transaction, int *err_code);
/*
* emstorage_get_password_length_of_account
@@ -473,9 +475,9 @@ INTERNAL_FUNC int emstorage_get_account_by_id(int account_id, int pulloption, em
* return :
*/
-INTERNAL_FUNC int emstorage_get_password_length_of_account(int account_id, int password_type, int *password_length, int* err_code);
+INTERNAL_FUNC int emstorage_get_password_length_of_account(char *multi_user_name, int account_id, int password_type, int *password_length, int* err_code);
-INTERNAL_FUNC int emstorage_update_account_password(int input_account_id, char *input_incoming_server_password, char *input_outgoing_server_password);
+INTERNAL_FUNC int emstorage_update_account_password(char *multi_user_name, int input_account_id, char *input_incoming_server_password, char *input_outgoing_server_password);
/*
* emstorage_update_account
@@ -486,11 +488,9 @@ INTERNAL_FUNC int emstorage_update_account_password(int input_account_id, char *
* account : buffer to hold selected account
* return :
*/
-INTERNAL_FUNC int emstorage_update_account(int account_id, emstorage_account_tbl_t *account, int transaction, int *err_code);
-
-
-INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(int account_id, char *field_name, int value, int transaction);
+INTERNAL_FUNC int emstorage_update_account(char *multi_user_name, int account_id, emstorage_account_tbl_t *account, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(char *multi_user_name, int account_id, char *field_name, int value, int transaction);
/*
* emstorage_get_sync_status_of_account
*
@@ -500,8 +500,7 @@ INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(int account
* result_sync_status : sync status value
* return :
*/
-
-INTERNAL_FUNC int emstorage_get_sync_status_of_account(int account_id, int *result_sync_status,int *err_code);
+INTERNAL_FUNC int emstorage_get_sync_status_of_account(char *multi_user_name, int account_id, int *result_sync_status,int *err_code);
/*
* emstorage_update_sync_status_of_account
@@ -513,8 +512,8 @@ INTERNAL_FUNC int emstorage_get_sync_status_of_account(int account_id, int *resu
* sync_status : sync status value
* return :
*/
+INTERNAL_FUNC int emstorage_update_sync_status_of_account(char *multi_user_name, int account_id, email_set_type_t set_operator, int sync_status, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, email_set_type_t set_operator, int sync_status, int transaction, int *err_code);
/*
* emstorage_add_account
@@ -523,7 +522,7 @@ INTERNAL_FUNC int emstorage_update_sync_status_of_account(int account_id, email_
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t *account, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account_tbl_t *account, int transaction, int *err_code);
/*
* emstorage_delete_account
@@ -534,7 +533,7 @@ INTERNAL_FUNC int emstorage_add_account(emstorage_account_tbl_t *account, int tr
* account_id : account id to be deteted
* return :
*/
-INTERNAL_FUNC int emstorage_delete_account(int account_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_account(char *multi_user_name, int account_id, int transaction, int *err_code);
/*
* emstorage_free_account
@@ -559,7 +558,7 @@ INTERNAL_FUNC int emstorage_free_account(emstorage_account_tbl_t **account_list,
* count : number of accounts
* return :
*/
-INTERNAL_FUNC int emstorage_get_mailbox_count(int account_id, int local_yn, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mailbox_count(char *multi_user_name, int account_id, int local_yn, int *count, int transaction, int *err_code);
/*
* emstorage_get_mailbox
@@ -574,7 +573,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_count(int account_id, int local_yn, int
* this buffer must be free after it has been used.
* return :
*/
-INTERNAL_FUNC int emstorage_get_mailbox_list(int account_id, int local_yn, email_mailbox_sort_type_t sort_type, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mailbox_list(char *multi_user_name, int account_id, int local_yn, email_mailbox_sort_type_t sort_type, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
/*
* emstorage_get_child_mailbox_list
@@ -588,9 +587,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_list(int account_id, int local_yn, email
* mailbox_list - out : list of mailboxes
* err_code - out : error code, if any
*/
-
-
-INTERNAL_FUNC int emstorage_get_child_mailbox_list(int account_id, char *parent_mailbox_name, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_child_mailbox_list(char *multi_user_name, int account_id, char *parent_mailbox_name, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
/*
* emstorage_get_mailbox_by_name
@@ -603,15 +600,23 @@ INTERNAL_FUNC int emstorage_get_child_mailbox_list(int account_id, char *parent_
* this buffer must be free after it has been used.
* return :
*/
-INTERNAL_FUNC int emstorage_get_mailbox_by_name(int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t **mailbox, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, emstorage_mailbox_tbl_t **mailbox, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_mailbox_by_id(int input_mailbox_id, emstorage_mailbox_tbl_t** output_mailbox);
-INTERNAL_FUNC int emstorage_get_mailbox_by_keyword(int account_id, char *keyword, emstorage_mailbox_tbl_t** result_mailbox, int * result_count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_mailbox_list_ex(int account_id, int local_yn, int with_count, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, int *mailbox_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type, char **mailbox_name, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(int account_id, int local_yn, char *mailbox_name, int modifiable_yn, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_mailbox_total_count(int account_id, int input_mailbox_id, int total_count_on_server, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mailbox_by_name(char *multi_user_name, int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t **mailbox, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, emstorage_mailbox_tbl_t **mailbox, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_mailbox_by_id(char *multi_user_name, int input_mailbox_id, emstorage_mailbox_tbl_t** output_mailbox);
+
+INTERNAL_FUNC int emstorage_get_mailbox_by_keyword(char *multi_user_name, int account_id, char *keyword, emstorage_mailbox_tbl_t** result_mailbox, int * result_count, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_mailbox_list_ex(char *multi_user_name, int account_id, int local_yn, int with_count, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, int *mailbox_id, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, char **mailbox_name, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(char *multi_user_name, int account_id, int local_yn, char *mailbox_name, int modifiable_yn, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_mailbox_total_count(char *multi_user_name, int account_id, int input_mailbox_id, int total_count_on_server, int transaction, int *err_code);
/*
@@ -624,7 +629,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_total_count(int account_id, int input
* mailbox : buffer to hold selected local mailbox
* return :
*/
-INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, int input_mailbox_id, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
/*
* emstorage_update_mailbox_type
@@ -633,7 +638,7 @@ INTERNAL_FUNC int emstorage_update_mailbox(int account_id, int local_yn, int inp
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, int input_mailbox_id, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code);
/*
* emstorage_set_local_mailbox
@@ -642,9 +647,9 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(int account_id, int local_yn, in
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox, int transaction);
+INTERNAL_FUNC int emstorage_set_local_mailbox(char *multi_user_name, int input_mailbox_id, int input_is_local_mailbox, int transaction);
-INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, char *input_field_name, int input_value, int transaction);
+INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(char *multi_user_name, int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, char *input_field_name, int input_value, int transaction);
/*
* emstorage_add_mailbox
@@ -653,7 +658,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(int input_ac
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
/*
* emstorage_delete_mailbox
@@ -664,15 +669,19 @@ INTERNAL_FUNC int emstorage_add_mailbox(emstorage_mailbox_tbl_t *mailbox, int tr
* mailbox_name : mailbox name of record to be deteted
* return :
*/
-INTERNAL_FUNC int emstorage_delete_mailbox(int account_id, int local_yn, int input_mailbox_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_mailbox(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_transaction);
+
+INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(char *multi_user_name, int account_id, int input_mailbox_id, int mail_slot_size, int **mail_id_list, int *mail_id_count, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_set_mail_slot_size(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(char *multi_user_name, int account_id, int modifiable_yn, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_rename_mailbox(int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_transaction);
-INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(int account_id, int input_mailbox_id, int input_mailbox_type, int mail_slot_size, int **mail_id_list, int *mail_id_count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(char *multi_user_name, int account_id, int modifiable_yn, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(int account_id, int modifiable_yn, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(int account_id, int modifiable_yn, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(int input_mailbox_id, int input_transaction);
+INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(char *multi_user_name, int input_mailbox_id, int input_transaction);
/*
* emstorage_free_mailbox
@@ -687,10 +696,7 @@ INTERNAL_FUNC int emstorage_free_mailbox(emstorage_mailbox_tbl_t **mailbox_list,
/************** Read Mail UID Management ******************/
-
-
-
-INTERNAL_FUNC int emstorage_get_count_read_mail_uid(int account_id, char *mailbox_name, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_count_read_mail_uid(char *multi_user_name, int account_id, char *mailbox_name, int *count, int transaction, int *err_code);
/*
@@ -704,7 +710,7 @@ INTERNAL_FUNC int emstorage_get_count_read_mail_uid(int account_id, char *mailbo
* exist : variable to hold checking result. (0 : not exist, 1 : exist)
* return :
*/
-INTERNAL_FUNC int emstorage_check_read_mail_uid(int account_id, char *mailbox_name, char *uid, int *exist, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_check_read_mail_uid(char *multi_user_name, int account_id, char *mailbox_name, char *uid, int *exist, int transaction, int *err_code);
/*
* emstorage_get_read_mail_size
@@ -719,9 +725,9 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(int account_id, char *mailbox_na
* read_mail_uid : variable to hold read mail uid information
* return :
*/
-INTERNAL_FUNC int emstorage_get_downloaded_list(int account_id, int mailbox_id, emstorage_read_mail_uid_tbl_t **read_mail_uid, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_downloaded_list(char *multi_user_name, int account_id, int mailbox_id, emstorage_read_mail_uid_tbl_t **read_mail_uid, int *count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_downloaded_mail(int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_downloaded_mail(char *multi_user_name, int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
/*
* emstorage_get_read_mail_size
@@ -734,7 +740,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail(int mail_id, emstorage_mail_tbl_
* size : variable to hold mail size
* return :
*/
-INTERNAL_FUNC int emstorage_get_downloaded_mail_size(int account_id, char *local_mbox, int local_uid, char *mailbox_name, char *uid, int *mail_size, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_downloaded_mail_size(char *multi_user_name, int account_id, char *local_mbox, int local_uid, char *mailbox_name, char *uid, int *mail_size, int transaction, int *err_code);
/*
* emstorage_add_downloaded_mail
@@ -743,7 +749,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail_size(int account_id, char *local
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t *read_mail_uid, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage_read_mail_uid_tbl_t *read_mail_uid, int transaction, int *err_code);
#ifdef __FEATURE_BODY_SEARCH__
/*
@@ -753,7 +759,7 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(emstorage_read_mail_uid_tbl_t *r
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_add_mail_text(emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_mail_text(char *multi_user_name, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code);
#endif
/*
@@ -763,7 +769,7 @@ INTERNAL_FUNC int emstorage_add_mail_text(emstorage_mail_text_tbl_t* mail_text,
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, int local_mailbox_id, int local_uid, char *mailbox_name, char *uid,
+INTERNAL_FUNC int emstorage_change_read_mail_uid(char *multi_user_name, int account_id, int local_mailbox_id, int local_uid, char *mailbox_name, char *uid,
emstorage_read_mail_uid_tbl_t *read_mail_uid, int transaction, int *err_code);
/*
@@ -773,10 +779,9 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(int account_id, int local_mailb
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_remove_downloaded_mail(int account_id, char *mailbox_name, char *uid, int transaction, int *err_code);
-
+INTERNAL_FUNC int emstorage_remove_downloaded_mail(char *multi_user_name, int account_id, char *mailbox_name, char *uid, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_read_mail_uid(int mail_id, char *new_server_uid, char *mbox_name, int *err_code);
+INTERNAL_FUNC int emstorage_update_read_mail_uid(char *multi_user_name, int mail_id, char *new_server_uid, char *mbox_name, int *err_code);
/*
* free memroy
@@ -796,7 +801,7 @@ INTERNAL_FUNC int emstorage_free_read_mail_uid(emstorage_read_mail_uid_tbl_t **r
* count : number of accounts
* return :
*/
-INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(int account_id, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(char *multi_user_name, int account_id, int *count, int transaction, int *err_code);
/*
* emstorage_get_rule
@@ -810,7 +815,7 @@ INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(int account_id, int *co
* is_completed : is completed ?
* return :
*/
-INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, int *select_num, int *is_completed, emstorage_rule_tbl_t **rule_list, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_rule(char *multi_user_name, int account_id, int type, int start_idx, int *select_num, int *is_completed, emstorage_rule_tbl_t **rule_list, int transaction, int *err_code);
/*
* emstorage_get_rule
@@ -819,7 +824,7 @@ INTERNAL_FUNC int emstorage_get_rule(int account_id, int type, int start_idx, in
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_get_rule_by_id(int rule_id, emstorage_rule_tbl_t **rule, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_rule_by_id(char *multi_user_name, int rule_id, emstorage_rule_tbl_t **rule, int transaction, int *err_code);
/*
* emstorage_change_rule
@@ -831,7 +836,7 @@ INTERNAL_FUNC int emstorage_get_rule_by_id(int rule_id, emstorage_rule_tbl_t **r
* rule : buffer to hold selected rule
* return :
*/
-INTERNAL_FUNC int emstorage_change_rule(int rule_id, emstorage_rule_tbl_t *rule, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_change_rule(char *multi_user_name, int rule_id, emstorage_rule_tbl_t *rule, int transaction, int *err_code);
/*
* emstorage_find_rule
@@ -840,7 +845,7 @@ INTERNAL_FUNC int emstorage_change_rule(int rule_id, emstorage_rule_tbl_t *rule,
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_find_rule(emstorage_rule_tbl_t *rule, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_find_rule(char *multi_user_name, emstorage_rule_tbl_t *rule, int transaction, int *err_code);
/*
* emstorage_add_rule
@@ -849,7 +854,7 @@ INTERNAL_FUNC int emstorage_find_rule(emstorage_rule_tbl_t *rule, int transactio
* arguments :
* return :
*/
-INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t *rule, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_rule(char *multi_user_name, emstorage_rule_tbl_t *rule, int transaction, int *err_code);
/*
* emstorage_delete_rule
@@ -860,7 +865,7 @@ INTERNAL_FUNC int emstorage_add_rule(emstorage_rule_tbl_t *rule, int transaction
* rule : rule to be deteted
* return :
*/
-INTERNAL_FUNC int emstorage_delete_rule(int rule_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_rule(char *multi_user_name, int rule_id, int transaction, int *err_code);
/*
* emstorage_free_rule
@@ -884,7 +889,7 @@ INTERNAL_FUNC int emstorage_free_rule(emstorage_rule_tbl_t **rule_list, int coun
* unseen : unseen mail count
* return :
*/
-INTERNAL_FUNC int emstorage_get_mail_count(int account_id, int mailbox_id, int *total, int *unseen, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mail_count(char *multi_user_name, int account_id, int mailbox_id, int *total, int *unseen, int transaction, int *err_code);
/*
* emstorage_get_mail_by_id
@@ -895,7 +900,7 @@ INTERNAL_FUNC int emstorage_get_mail_count(int account_id, int mailbox_id, int *
* mail : double pointer to hold mail
* return :
*/
-INTERNAL_FUNC int emstorage_get_mail_by_id(int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mail_by_id(char *multi_user_name, int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
#ifdef __FEATURE_BODY_SEARCH__
/*
@@ -907,7 +912,7 @@ INTERNAL_FUNC int emstorage_get_mail_by_id(int mail_id, emstorage_mail_tbl_t **m
* mail_text : double pointer to hold mail_text
* return :
*/
-INTERNAL_FUNC int emstorage_get_mail_text_by_id(int mail_id, emstorage_mail_text_tbl_t **mail_text, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mail_text_by_id(char *multi_user_name, int mail_id, emstorage_mail_text_tbl_t **mail_text, int transaction, int *err_code);
#endif
/*
@@ -921,7 +926,7 @@ INTERNAL_FUNC int emstorage_get_mail_text_by_id(int mail_id, emstorage_mail_text
* mail : double pointer to hold mail
* return :
*/
-INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail_id, int type, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
/*
* emstorage_get_mail_field_by_multiple_mail_id
@@ -936,35 +941,37 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(int mail_id, int type, emstorag
* err_code :
* return :
*/
-INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(int mail_ids[], int number_of_mails, int type, emstorage_mail_tbl_t** mail, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_name, int mail_ids[], int number_of_mails, int type, emstorage_mail_tbl_t** mail, int transaction, int *err_code);
/*
* emstorage_query_mail_count
*
* description : query mail count
*/
-INTERNAL_FUNC int emstorage_query_mail_count(const char *input_conditional_clause, int input_transaction, int *output_total_mail_count, int *output_unseen_mail_count);
-
+INTERNAL_FUNC int emstorage_query_mail_count(char *multi_user_name, const char *input_conditional_clause, int input_transaction, int *output_total_mail_count, int *output_unseen_mail_count);
/*
* emstorage_query_mail_list
*
* description : query mail id list
*/
-INTERNAL_FUNC int emstorage_query_mail_id_list(const char *input_conditional_clause, int input_transaction, int **output_mail_id_list, int *output_mail_id_count);
+INTERNAL_FUNC int emstorage_query_mail_id_list(char *multi_user_name, const char *input_conditional_clause, int input_transaction, int **output_mail_id_list, int *output_mail_id_count);
+
/*
* emstorage_query_mail_list
*
* description : query mail list information
*/
-INTERNAL_FUNC int emstorage_query_mail_list(const char *conditional_clause, int transaction, email_mail_list_item_t** result_mail_list, int *result_count, int *err_code);
+INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *conditional_clause, int transaction, email_mail_list_item_t** result_mail_list, int *result_count, int *err_code);
+
/*
* emstorage_query_mail_tbl
*
* description : query mail table information
*/
-INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int transaction, emstorage_mail_tbl_t** result_mail_tbl, int *result_count, int *err_code);
+INTERNAL_FUNC int emstorage_query_mail_tbl(char *multi_user_name, const char *conditional_clause, int transaction, emstorage_mail_tbl_t** result_mail_tbl, int *result_count, int *err_code);
+
#ifdef __FEATURE_BODY_SEARCH__
/*
@@ -972,7 +979,7 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(const char *conditional_clause, int t
*
* description : query mail_text table information
*/
-INTERNAL_FUNC int emstorage_query_mail_text_tbl(const char *conditional_clause, int transaction, emstorage_mail_text_tbl_t** result_mail_text_tbl, int *result_count, int *err_code);
+INTERNAL_FUNC int emstorage_query_mail_text_tbl(char *multi_user_name, const char *conditional_clause, int transaction, emstorage_mail_text_tbl_t** result_mail_text_tbl, int *result_count, int *err_code);
#endif
/*
@@ -980,26 +987,34 @@ INTERNAL_FUNC int emstorage_query_mail_text_tbl(const char *conditional_clause,
*
* description : query mail box table information
*/
-
-INTERNAL_FUNC int emstorage_query_mailbox_tbl(const char *input_conditional_clause, const char *input_ordering_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count);
+INTERNAL_FUNC int emstorage_query_mailbox_tbl(char *multi_user_name, const char *input_conditional_clause, const char *input_ordering_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count);
/*
* emstorage_get_mail_list
*
* description : search mail list information
*/
+INTERNAL_FUNC int emstorage_get_mail_list(char *multi_user_name, int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, int transaction, email_mail_list_item_t** mail_list, int *result_count, int *err_code);
-INTERNAL_FUNC int emstorage_get_mail_list(int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, int transaction, email_mail_list_item_t** mail_list, int *result_count, int *err_code);
/*
* emstorage_get_mails
*
* description : search mail list information
*/
-INTERNAL_FUNC int emstorage_get_mails(int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, int transaction, emstorage_mail_tbl_t** mail_list, int *result_count, int *err_code);
-INTERNAL_FUNC int emstorage_get_searched_mail_list(int account_id, int mailbox_id, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, email_sort_type_t sorting, int transaction, email_mail_list_item_t **mail_list, int *result_count, int *err_code);
-INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(int account_id, char *server_mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_unread_mailid(int account_id, int vip_mode, int **mail_ids, int *mail_number, int *err_code);
-INTERNAL_FUNC int emstorage_update_save_status(int account_id, int *err_code);
+INTERNAL_FUNC int emstorage_get_mails(char *multi_user_name, int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, int transaction, emstorage_mail_tbl_t** mail_list, int *result_count, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_searched_mail_list(char *multi_user_name, int account_id, int mailbox_id, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, email_sort_type_t sorting, int transaction, email_mail_list_item_t **mail_list, int *result_count, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(char *multi_user_name,
+ char *server_mail_id,
+ int mailbox_id,
+ emstorage_mail_tbl_t **mail,
+ int transaction,
+ int *err_code);
+
+INTERNAL_FUNC int emstorage_get_unread_mailid(char *multi_user_name, int account_id, int vip_mode, int **mail_ids, int *mail_number, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_save_status(char *multi_user_name, int account_id, int *err_code);
/**
@@ -1014,7 +1029,15 @@ INTERNAL_FUNC int emstorage_update_save_status(int account_id, int *err_code);
* @remarks N/A
* @return This function returns 0 on success or error code on failure.
*/
-INTERNAL_FUNC int emstorage_mail_search_start(emstorage_search_filter_t *search, int account_id, int mailbox_id, int sorting, int *search_handle, int *searched, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_mail_search_start(char *multi_user_name,
+ emstorage_search_filter_t *search,
+ int account_id,
+ int mailbox_id,
+ int sorting,
+ DB_STMT *search_handle,
+ int *searched,
+ int transaction,
+ int *err_code);
/*
* emstorage_mail_search_result
@@ -1025,7 +1048,11 @@ INTERNAL_FUNC int emstorage_mail_search_start(emstorage_search_filter_t *search,
* mail : double pointer to hold mail
* return :
*/
-INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail_field_type_t type, void **data, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle,
+ emstorage_mail_field_type_t type,
+ void **data,
+ int transaction,
+ int *err_code);
/*
* emstorage_mail_search_end
@@ -1035,9 +1062,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(int search_handle, emstorage_mail
* search_handle : handle to be finished
* return :
*/
-INTERNAL_FUNC int emstorage_mail_search_end(int search_handle, int transaction, int *err_code);
-
-
+INTERNAL_FUNC int emstorage_mail_search_end(DB_STMT search_handle, int transaction, int *err_code);
/*
* emstorage_set_field_of_mails_with_integer_value
@@ -1051,7 +1076,7 @@ INTERNAL_FUNC int emstorage_mail_search_end(int search_handle, int transaction,
* value : specified value
* return :
*/
-INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id, int mail_ids[], int mail_ids_count, char *field_name, int value, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(char *multi_user_name, int account_id, int mail_ids[], int mail_ids_count, char *field_name, int value, int transaction, int *err_code);
#ifdef __FEATURE_BODY_SEARCH__
/*
@@ -1063,7 +1088,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(int account_id
* mail_text : mail_text pointer
* return :
*/
-INTERNAL_FUNC int emstorage_change_mail_text_field(int mail_id, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_change_mail_text_field(char *multi_user_name, int mail_id, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code);
#endif
/*
@@ -1076,7 +1101,7 @@ INTERNAL_FUNC int emstorage_change_mail_text_field(int mail_id, emstorage_mail_t
* mail : mail pointer
* return :
*/
-INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_type_t type, emstorage_mail_tbl_t *mail, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id, email_mail_change_type_t type, emstorage_mail_tbl_t *mail, int transaction, int *err_code);
/*
* emstorage_increase_mail_id
@@ -1096,11 +1121,13 @@ INTERNAL_FUNC int emstorage_change_mail_field(int mail_id, email_mail_change_typ
* mail : mail pointer
* return :
*/
-INTERNAL_FUNC int emstorage_change_mail(int mail_id, emstorage_mail_tbl_t *mail, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_clean_save_status(int save_status, int *err_code);
-INTERNAL_FUNC int emstorage_update_server_uid(char *old_server_uid, char *new_server_uid, int *err_code);
+INTERNAL_FUNC int emstorage_change_mail(char *multi_user_name, int mail_id, emstorage_mail_tbl_t *mail, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_clean_save_status(char *multi_user_name, int save_status, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_server_uid(char *multi_user_name, char *old_server_uid, char *new_server_uid, int *err_code);
-INTERNAL_FUNC int emstorage_increase_mail_id(int *mail_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_increase_mail_id(char *multi_user_name, int *mail_id, int transaction, int *err_code);
/*
* emstorage_add_mail
@@ -1111,7 +1138,7 @@ INTERNAL_FUNC int emstorage_increase_mail_id(int *mail_id, int transaction, int
* get_id : must get uinque id in function
* return :
*/
-INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail, int get_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t *mail, int get_id, int transaction, int *err_code);
/*
* emstorage_move_multiple_mails_on_db
@@ -1126,7 +1153,7 @@ INTERNAL_FUNC int emstorage_add_mail(emstorage_mail_tbl_t *mail, int get_id, int
* err_code :
* return :
*/
-INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int account_id, int input_mailbox_id, int mail_ids[], int number_of_mails, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(char *multi_user_name, int account_id, int input_mailbox_id, int mail_ids[], int number_of_mails, int transaction, int *err_code);
/*
* emstorage_delete_mail
@@ -1137,7 +1164,7 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(int account_id, int input_
* from_server : delete mail on server.
* return :
*/
-INTERNAL_FUNC int emstorage_delete_mail(int mail_id, int from_server, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_mail(char *multi_user_name, int mail_id, int from_server, int transaction, int *err_code);
/*
* emstorage_delete_mail_by_account
@@ -1147,7 +1174,7 @@ INTERNAL_FUNC int emstorage_delete_mail(int mail_id, int from_server, int transa
* account_id : account id.
* return :
*/
-INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_mail_by_account(char *multi_user_name, int account_id, int transaction, int *err_code);
/*
* emstorage_delete_mail_by_mailbox
@@ -1157,7 +1184,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(int account_id, int transacti
* mailbox : mailbox
* return :
*/
-INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
/*
* emstorage_delete_multiple_mails
@@ -1170,7 +1197,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(emstorage_mailbox_tbl_t *mail
* err_code :
* return :
*/
-INTERNAL_FUNC int emstorage_delete_multiple_mails(int mail_ids[], int number_of_mails, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_multiple_mails(char *multi_user_name, int mail_ids[], int number_of_mails, int transaction, int *err_code);
/*
* emstorage_free_mail
@@ -1206,13 +1233,13 @@ INTERNAL_FUNC void emstorage_free_mail_text(emstorage_mail_text_tbl_t** mail_tex
* attachment : double pointer to hold attachment data
* return :
*/
-INTERNAL_FUNC int emstorage_get_attachment_count(int mail_id, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_attachment_count(char *multi_user_name, int mail_id, int *count, int transaction, int *err_code);
/*
* emstorage_get_attachment_list
*
* description : get attachment list from attachment table
- * arguments :
+ * arguments :
* input_mail_id : mail id
* input_transaction : transaction option
* attachment_list : result attachment list
@@ -1220,7 +1247,7 @@ INTERNAL_FUNC int emstorage_get_attachment_count(int mail_id, int *count, int tr
* return : This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR__XXX) on failure.
*
*/
-INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_transaction, emstorage_attachment_tbl_t** output_attachment_list, int *output_attachment_count);
+INTERNAL_FUNC int emstorage_get_attachment_list(char *multi_user_name, int input_mail_id, int input_transaction, emstorage_attachment_tbl_t** output_attachment_list, int *output_attachment_count);
/*
@@ -1232,7 +1259,7 @@ INTERNAL_FUNC int emstorage_get_attachment_list(int input_mail_id, int input_tra
* attachment : double pointer to hold attachment data
* return :
*/
-INTERNAL_FUNC int emstorage_get_attachment(int attachment_id, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_attachment(char *multi_user_name, int attachment_id, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
/*
* emstorage_get_attachment
@@ -1244,7 +1271,7 @@ INTERNAL_FUNC int emstorage_get_attachment(int attachment_id, emstorage_attachme
* attachment : double pointer to hold attachment data
* return :
*/
-INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_attachment_nth(char *multi_user_name, int mail_id, int nth, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
/*
* emstorage_get_attachment
@@ -1255,7 +1282,7 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(int mail_id, int nth, emstorage_a
* attachment : double pointer to hold attachment data
* return :
*/
-INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *attachment_path, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *multi_user_name, char *attachment_path, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
/*
* emstorage_change_attachment_field
@@ -1267,7 +1294,7 @@ INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *attachment_p
* mail : mail pointer
* return :
*/
-INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, email_mail_change_type_t type, emstorage_attachment_tbl_t *attachment, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int mail_id, email_mail_change_type_t type, emstorage_attachment_tbl_t *attachment, int transaction, int *err_code);
/* Get new attachment id */
/*
@@ -1278,8 +1305,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(int mail_id, email_mail_chan
* attachment_no : attachment id pointer
* return :
*/
-
-INTERNAL_FUNC int emstorage_get_new_attachment_no(int *attachment_no, int *err_code);
+INTERNAL_FUNC int emstorage_get_new_attachment_no(char *multi_user_name, int *attachment_no, int *err_code);
/* insert attachment to mail attachment table */
/*
@@ -1290,10 +1316,9 @@ INTERNAL_FUNC int emstorage_get_new_attachment_no(int *attachment_no, int *err_c
* attachment : attachment pointer
* return :
*/
-INTERNAL_FUNC int emstorage_add_attachment(emstorage_attachment_tbl_t *attachment, int iscopy, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_attachment_tbl_t *attachment, int iscopy, int transaction, int *err_code);
-
-INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t *attachment, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_update_attachment(char *multi_user_name, emstorage_attachment_tbl_t *attachment, int transaction, int *err_code);
/* delete a mail from mail table */
/*
@@ -1304,9 +1329,9 @@ INTERNAL_FUNC int emstorage_update_attachment(emstorage_attachment_tbl_t *attach
* attachment_id : attachment id
* return :
*/
-INTERNAL_FUNC int emstorage_delete_attachment_on_db(int attachment_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_attachment_on_db(char *multi_user_name, int attachment_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(int mail_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(char *multi_user_name, int mail_id, int transaction, int *err_code);
/*
* emstorage_delete_attachment_all_on_db
@@ -1317,7 +1342,7 @@ INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(int mail_id, int tran
* mailbox : mail box
* return :
*/
-INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *mailbox, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(char *multi_user_name, int account_id, char *mailbox, int transaction, int *err_code);
/*
* emstorage_free_attachment
@@ -1330,7 +1355,7 @@ INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(int account_id, char *ma
*/
INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t **attachment_list, int count, int *err_code);
-INTERNAL_FUNC int emstorage_is_mailbox_full(int account_id, email_mailbox_t *mailbox, int *result, int *err_code);
+INTERNAL_FUNC int emstorage_is_mailbox_full(char *multi_user_name, int account_id, email_mailbox_t *mailbox, int *result, int *err_code);
INTERNAL_FUNC int emstorage_get_max_mail_count();
@@ -1345,8 +1370,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_
* @remarks emstorage_commit_transaction or emstorage_commit_transaction must be called after this function.
* @return This function returns 0 on success or error code on failure.
*/
-
-INTERNAL_FUNC int emstorage_begin_transaction(void *d1, void *d2, int *err_code);
+INTERNAL_FUNC int emstorage_begin_transaction(char *multi_user_name, void *d1, void *d2, int *err_code);
/**
* commit a transaction.
@@ -1356,7 +1380,7 @@ INTERNAL_FUNC int emstorage_begin_transaction(void *d1, void *d2, int *err_code)
* @remarks N/A
* @return This function returns 0 on success or error code on failure.
*/
-INTERNAL_FUNC int emstorage_commit_transaction(void *d1, void *d2, int *err_code);
+INTERNAL_FUNC int emstorage_commit_transaction(char *multi_user_name, void *d1, void *d2, int *err_code);
/**
* rollback db.
@@ -1366,7 +1390,7 @@ INTERNAL_FUNC int emstorage_commit_transaction(void *d1, void *d2, int *err_code
* @remarks N/A
* @return This function returns 0 on success or error code on failure.
*/
-INTERNAL_FUNC int emstorage_rollback_transaction(void *d1, void *d2, int *err_code);
+INTERNAL_FUNC int emstorage_rollback_transaction(char *multi_user_name, void *d1, void *d2, int *err_code);
/**
* clear mail data from db.
@@ -1376,8 +1400,7 @@ INTERNAL_FUNC int emstorage_rollback_transaction(void *d1, void *d2, int *err_co
* @remarks N/A
* @return This function returns 0 on success or error code on failure.
*/
-
-INTERNAL_FUNC int emstorage_clear_mail_data(int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transaction, int *err_code);
INTERNAL_FUNC char *emstorage_make_directory_path_from_file_path(char *file_name);
@@ -1394,7 +1417,7 @@ INTERNAL_FUNC char *emstorage_make_directory_path_from_file_path(char *file_name
* name_buf : buffer to hold file name. (MAX : 512Bytes)
* return :
*/
-INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_id, char *fname, char *name_buf, int maxlen, int *err_code);
+INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id, int mail_id, int atch_id, char *fname, char *move_buf, char *path_buf, int maxlen, int *err_code);
/*
* emstorage_get_dele_name
@@ -1408,7 +1431,7 @@ INTERNAL_FUNC int emstorage_get_save_name(int account_id, int mail_id, int atch_
* name_buf : buffer to hold file name. (MAX : 512Bytes)
* return :
*/
-INTERNAL_FUNC int emstorage_get_dele_name(int account_id, int mail_id, int atch_id, char *fname, char *name_buf, int *err_code);
+INTERNAL_FUNC int emstorage_get_dele_name(char *multi_user_name, int account_id, int mail_id, int atch_id, char *fname, char *name_buf, int *err_code);
/*
* emstorage_create_dir
@@ -1419,7 +1442,7 @@ INTERNAL_FUNC int emstorage_get_dele_name(int account_id, int mail_id, int atch_
* no : attachment no.
* return :
*/
-INTERNAL_FUNC int emstorage_create_dir(int account_id, int mail_id, int atch_id, int *err_code);
+INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, int mail_id, int atch_id, int *err_code);
/*
* emstorage_copy_file
@@ -1466,18 +1489,36 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code);
INTERNAL_FUNC void emstorage_flush_db_cache();
-INTERNAL_FUNC int emstorage_test(int mail_id, int account_id, char *full_address_to, char *full_address_cc, char *full_address_bcc, int *err_code);
-INTERNAL_FUNC int emstorage_get_sender_list(int account_id, int mailbox_id, int search_type, const char *search_value, email_sort_type_t sorting, email_sender_list_t** sender_list, int *sender_count, int *err_code);
+INTERNAL_FUNC int emstorage_test(char *multi_user_name, int mail_id, int account_id, char *full_address_to, char *full_address_cc, char *full_address_bcc, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_sender_list(char *multi_user_name, int account_id, int mailbox_id, int search_type, const char *search_value, email_sort_type_t sorting, email_sender_list_t** sender_list, int *sender_count, int *err_code);
+
INTERNAL_FUNC int emstorage_free_sender_list(email_sender_list_t **sender_list, int count);
/* Handling Thread mail */
-INTERNAL_FUNC int emstorage_get_thread_information(int thread_id, emstorage_mail_tbl_t **mail_table_data, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(emstorage_mail_tbl_t *mail_table_data, int *thread_id, int *result_latest_mail_id_in_thread, int *thread_item_count);
-INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(int mail_id, int *thread_id, int *err_code);
-INTERNAL_FUNC int emstorage_update_latest_thread_mail(int account_id, int mailbox_id, int thread_id, int *updated_thread_id, int latest_mail_id, int thread_item_count, int noti_type, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(int account_id, int mailbox_id, char *mail_subject, int *thread_id, int *thread_item_count);
-INTERNAL_FUNC int emstorage_update_thread_id_of_mail(int account_id, int mailbox_id, int mail_id, int thread_id, int thread_item_count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_thread_information(char *multi_user_name, int thread_id, emstorage_mail_tbl_t **mail_table_data, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name, emstorage_mail_tbl_t *mail_table_data, int *thread_id, int *result_latest_mail_id_in_thread, int *thread_item_count);
+
+INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(char *multi_user_name, int mail_id, int *thread_id, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name,
+ int account_id,
+ int mailbox_id,
+ int mailbox_type,
+ int thread_id,
+ int *updated_thread_id,
+ int latest_mail_id,
+ int thread_item_count,
+ int noti_type,
+ int transaction,
+ int *err_code);
+
+INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(char *multi_user_name, int account_id, int mailbox_id, char *mail_subject, int *thread_id, int *thread_item_count);
+
+INTERNAL_FUNC int emstorage_update_thread_id_of_mail(char *multi_user_name, int account_id, int mailbox_id, int mail_id, int thread_id, int thread_item_count, int transaction, int *err_code);
+
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
#define BULK_PARTIAL_BODY_DOWNLOAD_COUNT 10
@@ -1490,18 +1531,27 @@ enum
ACTIVITY_TYPE_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
MAILBOX_ID_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
MAILBOX_NAME_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
+ MULTI_USER_NAME_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL
};
+INTERNAL_FUNC int emstorage_get_pbd_activity_data(char *multi_user_name, int account_id, int input_mailbox_id, email_event_partial_body_thd** event_start, int *count, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_add_pbd_activity(char *multi_user_name, email_event_partial_body_thd *local_activity, int *activity_id, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(char *multi_user_name, int account_id, int **mailbox_list, int *count, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_pbd_account_list(char *multi_user_name, int **account_list, int *count, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_pbd_activity_count(char *multi_user_name, int *activity_id_count, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(char *multi_user_name, int account_id, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_delete_pbd_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(char *multi_user_name, int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_pbd_activity(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code);
-INTERNAL_FUNC int emstorage_get_pbd_activity_data(int account_id, int input_mailbox_id, email_event_partial_body_thd** event_start, int *count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_add_pbd_activity(email_event_partial_body_thd *local_activity, int *activity_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(int account_id, int **mailbox_list, int *count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_pbd_account_list(int **account_list, int *count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_pbd_activity_count(int *activity_id_count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(int account_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_delete_pbd_activity(int account_id, int mail_id, int activity_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_pbd_activity(char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code);
INTERNAL_FUNC int emstorage_create_file(char *buf, size_t file_size, char *dst_file, int *err_code);
#endif
@@ -1511,7 +1561,7 @@ INTERNAL_FUNC int emstorage_free_address_info_list(email_address_info_list_t *
INTERNAL_FUNC void emstorage_create_dir_if_delete();
#ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
-INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code);
+INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code);
/**
* @fn emstorage_get_id_set_from_mail_ids(int mail_ids[], int mail_id_count, email_id_set_t **server_uids, int *id_set_count, int *err_code);
@@ -1527,8 +1577,7 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *old_server_
* SELECT local_uid, server_uid from mail_read_mail_uid_tbl where local_uid in (12, 13, 56, 78);
* @return This function returns true on success or false on failure.
*/
-
-INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, email_id_set_t **idset, int *id_set_count, int *err_code);
+INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *multi_user_name, char *mail_ids, email_id_set_t **idset, int *id_set_count, int *err_code);
#endif
@@ -1549,17 +1598,24 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *mail_ids, email_id_se
* @remarks
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emstorage_filter_mails_by_rule(int account_id, int dest_mailbox_id, int dest_mailbox_type, int reset, emstorage_rule_tbl_t *rule, int **filtered_mail_id_list, int *count_of_mails, int *err_code);
+INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int account_id, int dest_mailbox_id, int dest_mailbox_type, int reset, emstorage_rule_tbl_t *rule, int **filtered_mail_id_list, int *count_of_mails, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_tag_id(char *multi_user_name, int old_filter_id, int new_filter_id, int *err_code);
+
+INTERNAL_FUNC int emstorage_add_meeting_request(char *multi_user_name, int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_query_meeting_request(char *multi_user_name, const char *conditional_clause, email_meeting_request_t **output_meeting_req, int *output_result_count, int transaction);
+
+INTERNAL_FUNC int emstorage_get_meeting_request(char *multi_user_name, int mail_id, email_meeting_request_t **meeting_req, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_update_meeting_request(char *multi_user_name, email_meeting_request_t *meeting_req, int transaction, int *err_code);
+
+INTERNAL_FUNC int emstorage_delete_meeting_request(char *multi_user_name, int account_id, int mail_id, int input_mailbox_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_tag_id(int old_filter_id, int new_filter_id, int *err_code);
-INTERNAL_FUNC int emstorage_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_query_meeting_request(const char *conditional_clause, email_meeting_request_t **output_meeting_req, int *output_result_count, int transaction);
-INTERNAL_FUNC int emstorage_get_meeting_request(int mail_id, email_meeting_request_t **meeting_req, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_meeting_request(email_meeting_request_t *meeting_req, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_delete_meeting_request(int account_id, int mail_id, int input_mailbox_id, int transaction, int *err_code);
INTERNAL_FUNC void emstorage_free_meeting_request(email_meeting_request_t *meeting_req);
-INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(email_list_filter_t *input_filter_list, int input_filter_count, email_list_sorting_rule_t *input_sorting_rule_list, int input_sorting_rule_count, int input_start_index, int input_limit_count, char **output_conditional_clause);
+INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char *multi_user_name, email_list_filter_t *input_filter_list, int input_filter_count, email_list_sorting_rule_t *input_sorting_rule_list, int input_sorting_rule_count, int input_start_index, int input_limit_count, char **output_conditional_clause);
+
INTERNAL_FUNC int emstorage_free_list_filter(email_list_filter_t **input_filter_list, int input_filter_count);
#ifdef __FEATURE_LOCAL_ACTIVITY__
@@ -1616,45 +1672,45 @@ INTERNAL_FUNC int emstorage_free_activity_id_list(int *activity_id_list, int *er
#endif
-INTERNAL_FUNC int emstorage_add_certificate(emstorage_certificate_tbl_t *certificate, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_add_certificate(char *multi_user_name, emstorage_certificate_tbl_t *certificate, int transaction, int *err_code);
INTERNAL_FUNC int emstorage_free_certificate(emstorage_certificate_tbl_t **certificate_list, int count, int *err_code);
-INTERNAL_FUNC int emstorage_get_certificate_list(int *select_num, emstorage_certificate_tbl_t **certificate_list, int transaction, int with_password, int *err_code);
+INTERNAL_FUNC int emstorage_get_certificate_list(char *multi_user_name, int *select_num, emstorage_certificate_tbl_t **certificate_list, int transaction, int with_password, int *err_code);
-INTERNAL_FUNC int emstorage_get_certificate_by_email_address(char *email_address, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code);
+INTERNAL_FUNC int emstorage_get_certificate_by_email_address(char *multi_user_name, char *email_address, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code);
-INTERNAL_FUNC int emstorage_get_certificate_by_index(int index, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code);
+INTERNAL_FUNC int emstorage_get_certificate_by_index(char *multi_user_name, int index, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code);
-INTERNAL_FUNC int emstorage_delete_certificate(int index, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_certificate(char *multi_user_name, int index, int transaction, int *err_code);
/* task begin */
-INTERNAL_FUNC int emstorage_add_task(email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int input_transaction, int *output_task_id);
+INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int input_transaction, int *output_task_id);
-INTERNAL_FUNC int emstorage_delete_task(int task_id, int transaction);
+INTERNAL_FUNC int emstorage_delete_task(char *multi_user_name, int task_id, int transaction);
-INTERNAL_FUNC int emstorage_update_task_status(int task_id, email_task_status_type_t task_status, int transaction);
+INTERNAL_FUNC int emstorage_update_task_status(char *multi_user_name, int task_id, email_task_status_type_t task_status, int transaction);
-INTERNAL_FUNC int emstorage_query_task(const char *input_conditional_clause, const char *input_ordering_clause, email_task_t **output_task_list, int *output_task_count);
+INTERNAL_FUNC int emstorage_query_task(char *multi_user_name, const char *input_conditional_clause, const char *input_ordering_clause, email_task_t **output_task_list, int *output_task_count);
/* task end*/
-INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(int account_id, email_mailbox_type_e input_mailbox_type, char *message_id, char *server_uid, int *searched_mail_id);
+INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *multi_user_name, int account_id, email_mailbox_type_e input_mailbox_type, char *message_id, char *server_uid, int *searched_mail_id);
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
-INTERNAL_FUNC int emstorage_add_auto_download_activity(email_event_auto_download *local_activity, int *activity_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_delete_auto_download_activity(int account_id, int mail_id, int activity_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_delete_all_auto_download_activity(int account_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_delete_auto_download_activity_by_mailbox(int account_id, int mailbox_id, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_auto_download_activity(int account_id, int input_mailbox_id, email_event_auto_download **event_start, int *count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_auto_download_activity_count(int *activity_count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_auto_download_account_list(int **account_list, int *count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(int account_id, int **mailbox_list, int *count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_get_auto_download_activity_count_by_mailbox(int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code);
-INTERNAL_FUNC int emstorage_update_auto_download_activity(char *old_server_uid, char *new_server_uid, char *mailbox_name, int mailbox_id, int *err_code);
+INTERNAL_FUNC int emstorage_add_auto_download_activity(char *multi_user_name, email_event_auto_download *local_activity, int *activity_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_auto_download_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_all_auto_download_activity(char *multi_user_name, int account_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_delete_auto_download_activity_by_mailbox(char *multi_user_name, int account_id, int mailbox_id, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_auto_download_activity(char *multi_user_name, int account_id, int input_mailbox_id, email_event_auto_download **event_start, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_auto_download_activity_count(char *multi_user_name, int *activity_count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_auto_download_account_list(char *multi_user_name, int **account_list, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(char *multi_user_name, int account_id, int **mailbox_list, int *count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_get_auto_download_activity_count_by_mailbox(char *multi_user_name, int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code);
+INTERNAL_FUNC int emstorage_update_auto_download_activity(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mailbox_name, int mailbox_id, int *err_code);
#endif
#ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__
-INTERNAL_FUNC int emstorage_update_db_table_schema();
+INTERNAL_FUNC int emstorage_update_db_table_schema(char *multi_user_name);
#endif /* __FEATURE_UPDATE_DB_TABLE_SCHEMA__ */
#ifdef __cplusplus
diff --git a/email-core/include/email-core-account.h b/email-core/include/email-core-account.h
index 3636eba..befaffb 100755
--- a/email-core/include/email-core-account.h
+++ b/email-core/include/email-core-account.h
@@ -40,13 +40,13 @@ extern "C"
{
#endif /* __cplusplus */
-INTERNAL_FUNC int emcore_validate_account(int account_id, int handle, int *err_code);
+INTERNAL_FUNC int emcore_validate_account(char *multi_user_name, int account_id, int handle, int *err_code);
-INTERNAL_FUNC int emcore_validate_account_with_account_info(email_account_t *account, email_event_type_t event_type, char **output_imap_cap_string, int event_handle, int *err_code);
+INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_name, email_account_t *account, email_event_type_t event_type, char **output_imap_cap_string, int event_handle, int *err_code);
-INTERNAL_FUNC int emcore_create_account(email_account_t *account, int add_account_to_account_svc, int *err_code);
+INTERNAL_FUNC int emcore_create_account(char *multi_user_name, email_account_t *account, int add_account_to_account_svc, int *err_code);
-INTERNAL_FUNC int emcore_delete_account(int account_id, int input_delete_from_account_svc, int *err_code);
+INTERNAL_FUNC int emcore_delete_account(char *multi_user_name, int account_id, int input_delete_from_account_svc, int *err_code);
INTERNAL_FUNC int emcore_free_account_list(email_account_t **account_list, int count, int *err_code);
@@ -56,31 +56,31 @@ INTERNAL_FUNC void emcore_free_account(email_account_t *account_list);
INTERNAL_FUNC void emcore_duplicate_account(const email_account_t *account, email_account_t **account_dup, int *err_code);
-INTERNAL_FUNC int emcore_init_account_reference();
+INTERNAL_FUNC email_account_t *emcore_get_account_reference(char *multi_user_name, int account_id, int with_password);
-INTERNAL_FUNC int emcore_add_account_reference(email_account_t *account);
+INTERNAL_FUNC int emcore_get_account_reference_list(char *multi_user_name, email_account_t **account_list, int *count);
-INTERNAL_FUNC int emcore_free_account_reference();
+INTERNAL_FUNC int emcore_query_server_info(const char* domain_name, email_server_info_t **result_server_info);
-INTERNAL_FUNC email_account_t *emcore_get_account_reference(int account_id);
+INTERNAL_FUNC void emcore_cleanup_query_server_info(void);
-INTERNAL_FUNC int emcore_get_account_reference_list(email_account_t **account_list, int *count, int *err_code);
+INTERNAL_FUNC int emcore_free_server_info(email_server_info_t **target_server_info);
-INTERNAL_FUNC int emcore_save_default_account_id(int input_account_id);
+INTERNAL_FUNC int emcore_save_default_account_id(char *multi_user_name, int input_account_id);
-INTERNAL_FUNC int emcore_load_default_account_id(int *output_account_id);
+INTERNAL_FUNC int emcore_load_default_account_id(char *multi_user_name, int *output_account_id);
-INTERNAL_FUNC int emcore_recover_from_secured_storage_failure();
+INTERNAL_FUNC int emcore_recover_from_secured_storage_failure(char *multi_user_name);
-INTERNAL_FUNC int emcore_update_sync_status_of_account(int input_account_id, email_set_type_t input_set_operator, int input_sync_status);
+INTERNAL_FUNC int emcore_update_sync_status_of_account(char *multi_user_name, int input_account_id, email_set_type_t input_set_operator, int input_sync_status);
-INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(int input_account_id);
+INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(char *multi_user_name, int input_account_id);
#ifdef __FEATURE_BACKUP_ACCOUNT__
-INTERNAL_FUNC int emcore_backup_accounts(const char *file_path, int *error_code);
+INTERNAL_FUNC int emcore_backup_accounts(char *multi_user_name, const char *file_path, int *error_code);
-INTERNAL_FUNC int emcore_restore_accounts(const char *file_path);
+INTERNAL_FUNC int emcore_restore_accounts(char *multi_user_name, const char *file_path);
#endif /* __FEATURE_BACKUP_ACCOUNT_ */
#ifdef __cplusplus
diff --git a/email-core/include/email-core-alarm.h b/email-core/include/email-core-alarm.h
index df2ce6c..d78f2bc 100755
--- a/email-core/include/email-core-alarm.h
+++ b/email-core/include/email-core-alarm.h
@@ -47,11 +47,12 @@ typedef struct _email_alarm_data_t {
int reference_id;
time_t trigger_at_time;
int (*alarm_callback)(struct _email_alarm_data_t*, void *);
+ char *multi_user_name;
void *user_data;
} email_alarm_data_t;
-INTERNAL_FUNC int emcore_add_alarm(time_t input_trigger_at_time, email_alarm_class_t input_class_id, int input_reference_id, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *input_user_data);
+INTERNAL_FUNC int emcore_add_alarm(char *multi_user_name, time_t input_trigger_at_time, email_alarm_class_t input_class_id, int input_reference_id, int (*input_alarm_callback)(email_alarm_data_t*, void *), void *input_user_data);
INTERNAL_FUNC int emcore_delete_alram_data_from_alarm_data_list(email_alarm_data_t *input_alarm_data);
INTERNAL_FUNC int emcore_delete_alram_data_by_reference_id(email_alarm_class_t input_class_id, int input_reference_id);
diff --git a/email-core/include/email-core-auto-download.h b/email-core/include/email-core-auto-download.h
index 268b571..d4b863d 100755
--- a/email-core/include/email-core-auto-download.h
+++ b/email-core/include/email-core-auto-download.h
@@ -35,6 +35,7 @@ typedef struct auto_download_t
int mail_id;
unsigned long server_mail_id;
int mailbox_id;
+ char *multi_user_name;
} email_event_auto_download;
INTERNAL_FUNC int emcore_start_auto_download_loop(int *err_code);
@@ -46,9 +47,9 @@ INTERNAL_FUNC int emcore_is_auto_download_queue_empty(void);
INTERNAL_FUNC int emcore_is_auto_download_queue_full(void);
INTERNAL_FUNC int emcore_clear_auto_download_queue(void);
-INTERNAL_FUNC int emcore_insert_auto_download_job(int account_id, int mailbox_id, int mail_id, int auto_download_on, char *uid, int *err_code);
+INTERNAL_FUNC int emcore_insert_auto_download_job(char *multi_user_name, int account_id, int mailbox_id, int mail_id, int auto_download_on, char *uid, int *err_code);
INTERNAL_FUNC int emcore_insert_auto_download_activity(email_event_auto_download *local_activity, int *activity_id, int *err_code);
-INTERNAL_FUNC int emcore_delete_auto_download_activity(int account_id, int mail_id, int activity_id, int *err_code);
+INTERNAL_FUNC int emcore_delete_auto_download_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int *err_code);
#endif
#ifdef __cplusplus
diff --git a/email-core/include/email-core-cert.h b/email-core/include/email-core-cert.h
index c0732f7..1257fb7 100755
--- a/email-core/include/email-core-cert.h
+++ b/email-core/include/email-core-cert.h
@@ -39,9 +39,9 @@
#include "email-utilities.h"
#include "email-types.h"
-INTERNAL_FUNC int emcore_add_public_certificate(char *public_cert_path, char *save_name, int *err_code);
+INTERNAL_FUNC int emcore_add_public_certificate(char *multi_user_name, char *public_cert_path, char *save_name, int *err_code);
-INTERNAL_FUNC int emcore_delete_public_certificate(char *email_address, int *err_code);
+INTERNAL_FUNC int emcore_delete_public_certificate(char *multi_user_name, char *email_address, int *err_code);
INTERNAL_FUNC int emcore_verify_signature(char *p7s_file_path, char *mime_entity, int *validity, int *err_code);
diff --git a/email-core/include/email-core-container.h b/email-core/include/email-core-container.h
new file mode 100644
index 0000000..663b1f6
--- /dev/null
+++ b/email-core/include/email-core-container.h
@@ -0,0 +1,45 @@
+/*
+* email-service
+*
+* Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+*
+* 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.
+*
+*/
+
+/**
+ *
+ * This file contains functionality related to KNOX
+ * to interact with email-service.
+ * @file email-core-container.c
+ * @author
+ * @version 0.1
+ * @brief This file contains functionality to provide KNOX support in email-service.
+ */
+
+#include <glib.h>
+#include "email-internal-types.h"
+
+INTERNAL_FUNC void emcore_create_container();
+INTERNAL_FUNC void emcore_destroy_container();
+INTERNAL_FUNC void emcore_bind_vsm_context();
+INTERNAL_FUNC int emcore_get_container_path(char *multi_user_name, char **container_path);
+INTERNAL_FUNC int emcore_get_user_name(int pid, char **multi_user_name);
+INTERNAL_FUNC int emcore_lookup_zone_by_name(char *user_name);
+INTERNAL_FUNC void emcore_set_declare_link(const char *file_path);
+INTERNAL_FUNC int emcore_get_zone_name_list(GList **output_name_list);
+INTERNAL_FUNC int emcore_get_canonicalize_path(char *db_path, char **output_path);
+INTERNAL_FUNC int emcore_set_join_zone(char *multi_user_name, void **join_zone);
+INTERNAL_FUNC void emcore_unset_join_zone(void *join_zone);
diff --git a/email-core/include/email-core-event.h b/email-core/include/email-core-event.h
index 43a8ec2..006107e 100755
--- a/email-core/include/email-core-event.h
+++ b/email-core/include/email-core-event.h
@@ -58,7 +58,7 @@ INTERNAL_FUNC int emcore_check_send_mail_thread_status(void);
INTERNAL_FUNC void emcore_get_event_queue_status(int *on_sending, int *on_receiving);
INTERNAL_FUNC int emcore_insert_event_for_sending_mails(email_event_t *event_data, int *handle, int *err_code);
INTERNAL_FUNC int emcore_get_receiving_event_queue(email_event_t **event_queue, int *event_count, int *err);
-INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(int account_id);
+INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(char *multi_user_name, int account_id);
INTERNAL_FUNC int emcore_free_event(email_event_t *event_data);
INTERNAL_FUNC int emcore_get_task_information(email_task_information_t **output_task_information, int *output_task_information_count);
diff --git a/email-core/include/email-core-gmime.h b/email-core/include/email-core-gmime.h
index e542b3c..bb0a130 100644
--- a/email-core/include/email-core-gmime.h
+++ b/email-core/include/email-core-gmime.h
@@ -71,6 +71,11 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
INTERNAL_FUNC int emcore_gmime_check_filename_duplication(char *source_filename, struct _m_content_info *cnt_info);
INTERNAL_FUNC char *emcore_gmime_get_modified_filename_in_duplication(char *source_filename);
INTERNAL_FUNC char *emcore_gmime_get_encoding_to_utf8(const char *text);
+INTERNAL_FUNC char *emcore_gmime_get_decoding_text(const char *text);
+INTERNAL_FUNC void emcore_gmime_get_mime_entity_cb(GMimeObject *parent, GMimeObject *part, gpointer user_data);
+INTERNAL_FUNC char *emcore_gmime_get_mime_entity_signed_message(GMimeObject *multipart);
+INTERNAL_FUNC char *emcore_gmime_get_mime_entity(int fd);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/email-core/include/email-core-imap-mailbox.h b/email-core/include/email-core-imap-mailbox.h
index 58c557d..585cf8b 100755
--- a/email-core/include/email-core-imap-mailbox.h
+++ b/email-core/include/email-core-imap-mailbox.h
@@ -33,7 +33,6 @@
#ifndef __EMAIL_CORE_IMAP_MAILBOX_H__
#define __EMAIL_CORE_IMAP_MAILBOX_H__
-
#ifdef __cplusplus
extern "C"
{
@@ -50,7 +49,7 @@ extern "C"
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox, int event_handle, int *err_code);
+INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id, char *mailbox, int event_handle, int *err_code);
/**
* Download mailbox list from imap server.
@@ -64,12 +63,12 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(int account_id, char *mailbox, int ev
* @return This function returns true on success or false on failure.
*/
INTERNAL_FUNC int emcore_download_mailbox_list(void *mail_stream, char *mailbox, email_internal_mailbox_t **mailbox_list, int *count, int *err_code);
-INTERNAL_FUNC int emcore_delete_imap_mailbox(int input_mailbox_id, int *err_code);
-INTERNAL_FUNC int emcore_create_imap_mailbox(email_mailbox_t *mailbox, int *err_code);
-INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(int input_account_id, int input_mailbox_id, char *input_old_mailbox_path, char *input_new_mailbox_path, int handle_to_be_published);
-INTERNAL_FUNC int emcore_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size, int *err_code);
-INTERNAL_FUNC int emcore_remove_overflowed_mails(emstorage_mailbox_tbl_t *intput_mailbox_tbl, int *err_code);
-INTERNAL_FUNC int emcore_get_default_mail_slot_count(int input_account_id, int *output_count);
+INTERNAL_FUNC int emcore_delete_imap_mailbox(char *multi_user_name, int input_mailbox_id, int *err_code);
+INTERNAL_FUNC int emcore_create_imap_mailbox(char *multi_user_name, email_mailbox_t *mailbox, int *err_code);
+INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(char *multi_user_name, int input_account_id, int input_mailbox_id, char *input_old_mailbox_path, char *input_new_mailbox_path, int handle_to_be_published);
+INTERNAL_FUNC int emcore_set_mail_slot_size(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int *err_code);
+INTERNAL_FUNC int emcore_remove_overflowed_mails(char *multi_user_name, emstorage_mailbox_tbl_t *intput_mailbox_tbl, int *err_code);
+INTERNAL_FUNC int emcore_get_default_mail_slot_count(char *multi_user_name, int input_account_id, int *output_count);
#ifdef __FEATURE_IMAP_QUOTA__
INTERNAL_FUNC int emcore_register_quota_callback();
diff --git a/email-core/include/email-core-mail.h b/email-core/include/email-core-mail.h
index 83fb206..78312db 100755
--- a/email-core/include/email-core-mail.h
+++ b/email-core/include/email-core-mail.h
@@ -217,6 +217,7 @@ struct _m_content_info
int total_body_size;
int total_attachment_size;
int attachment_only;
+ int content_type; /* 1 : signed */
char *sections;
struct text_data
@@ -227,6 +228,7 @@ struct _m_content_info
int html_save_status;
char *html; /* body html text */
char *html_charset; /* charset of html text */
+ char *mime_entity;
} text;
struct attachment_info *file;
@@ -243,33 +245,6 @@ typedef enum {
} pop3_cmd_t;
/**
- * Download email body from server.
- *
- * @param[in] mail_stream Specifies the mail_stream.
- * @param[in] mailbox Specifies the mailbox to contain account ID.
- * @param[in] mail_id Specifies the mail ID.
- * @param[in] callback Specifies the callback function for retrieving download status.
- * @param[in] with_attach Specifies the flag for downloading attachments.
- * @param[in] limited_size Specifies the size to be downloaded.
- * @param[out] err_code Specifies the error code returned.
- * @remarks In POP3 case, body and attachment are downloaded in this function.
- * In IMAP case, body and attachment list are downloaded and
- * attachments must be downloaded in emcore_download_attachment.
- * @return This function returns true on success or false on failure.
- */
-
-INTERNAL_FUNC int emcore_download_body_multi_sections_bulk ( void *mail_stream,
- int account_id,
- int mail_id,
- int verbose,
- int with_attach,
- int limited_size,
- int event_handle,
- int cancellable,
- int *err_code);
-
-
-/**
* Download a email nth-attachment from server.
*
* @param[in] mailbox Specifies the mailbox to contain account ID.
@@ -281,50 +256,49 @@ INTERNAL_FUNC int emcore_download_body_multi_sections_bulk ( void *mail_stream,
* @remarks This function is used for only IMAP mail.
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emcore_download_attachment (int acconut_id, int mail_id, int nth, int cancellable, int event_handle, int *err_code);
-INTERNAL_FUNC int emcore_add_attachment(int mail_id, email_attachment_data_t *attachment, int *err_code); /* TODO : Remove duplicated function */
-INTERNAL_FUNC int emcore_add_attachment_data(int input_mail_id, email_attachment_data_t *input_attachment_data); /* TODO : Remove duplicated function */
-INTERNAL_FUNC int emcore_delete_mail_attachment(int attachment_id, int *err_code);
-INTERNAL_FUNC int emcore_get_attachment_info(int attachment_id, email_attachment_data_t **attachment, int *err_code);
-INTERNAL_FUNC int emcore_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
+INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, email_attachment_data_t *attachment, int *err_code); /* TODO : Remove duplicated function */
+INTERNAL_FUNC int emcore_add_attachment_data(char *multi_user_name, int input_mail_id, email_attachment_data_t *input_attachment_data); /* TODO : Remove duplicated function */
+INTERNAL_FUNC int emcore_delete_mail_attachment(char *multi_user_name, int attachment_id, int *err_code);
+INTERNAL_FUNC int emcore_get_attachment_info(char *multi_user_name, int attachment_id, email_attachment_data_t **attachment, int *err_code);
+INTERNAL_FUNC int emcore_get_attachment_data_list(char *multi_user_name, int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count);
INTERNAL_FUNC int emcore_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count, int *err_code);
-INTERNAL_FUNC int emcore_gmime_download_attachment(int mail_id, int nth,
+INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int mail_id, int nth,
int cancellable, int event_handle, int auto_download, int *err_code);
-INTERNAL_FUNC int emcore_gmime_download_body_sections(void *mail_stream,
+INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name, void *mail_stream,
int account_id, int mail_id, int with_attach, int limited_size,
int event_handle, int cancellable, int auto_download, int *err_code);
-INTERNAL_FUNC int emcore_move_mail(int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int *err_code);
+INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int *err_code);
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
INTERNAL_FUNC int emcore_insert_pbd_activity(email_event_partial_body_thd *local_activity, int *activity_id, int *err_code) ;
-INTERNAL_FUNC int emcore_delete_pbd_activity(int account_id, int mail_id, int activity_id, int *err_code);
+INTERNAL_FUNC int emcore_delete_pbd_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int *err_code);
#endif
-INTERNAL_FUNC int emcore_get_mail_contact_info(email_mail_contact_info_t *contact_info, char *full_address, int *err_code);
-INTERNAL_FUNC int emcore_get_mail_contact_info_with_update(email_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code);
+INTERNAL_FUNC int emcore_get_mail_contact_info(char *multi_user_name, email_mail_contact_info_t *contact_info, char *full_address, int *err_code);
+INTERNAL_FUNC int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_contact_info_t *contact_info, char *full_address, int mail_id, int *err_code);
INTERNAL_FUNC int emcore_free_contact_info(email_mail_contact_info_t *contact_info, int *err_code);
-INTERNAL_FUNC int emcore_sync_contact_info(int mail_id, int *err_code);
-INTERNAL_FUNC GList *emcore_get_recipients_list(GList *old_recipients_list, char *full_address, int *err_code);
-INTERNAL_FUNC int emcore_get_mail_address_info_list(int mail_id, email_address_info_list_t **address_info_list, int *err_code);
+INTERNAL_FUNC int emcore_sync_contact_info(char *multi_user_name, int mail_id, int *err_code);
+INTERNAL_FUNC GList *emcore_get_recipients_list(char *multi_user_name, GList *old_recipients_list, char *full_address, int *err_code);
+INTERNAL_FUNC int emcore_get_mail_address_info_list(char *multi_user_name, int mail_id, email_address_info_list_t **address_info_list, int *err_code);
-INTERNAL_FUNC int emcore_set_sent_contacts_log(emstorage_mail_tbl_t *input_mail_data);
-INTERNAL_FUNC int emcore_set_received_contacts_log(emstorage_mail_tbl_t *input_mail_data);
-INTERNAL_FUNC int emcore_delete_contacts_log(int input_account_id);
+INTERNAL_FUNC int emcore_set_sent_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data);
+INTERNAL_FUNC int emcore_set_received_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data);
+INTERNAL_FUNC int emcore_delete_contacts_log(char *multi_user_name, int input_account_id);
-INTERNAL_FUNC int emcore_get_mail_display_name(char *email_address, char **contact_display_name);
-INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *email_address, char **contact_display_name);
-INTERNAL_FUNC int emcore_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data);
+INTERNAL_FUNC int emcore_get_mail_display_name(char *multi_user_name, char *email_address, char **contact_display_name);
+INTERNAL_FUNC int emcore_get_mail_display_name_internal(char *multi_user_name, char *email_address, char **contact_display_name);
+INTERNAL_FUNC int emcore_get_mail_data(char *multi_user_name, int input_mail_id, email_mail_data_t **output_mail_data);
-INTERNAL_FUNC int emcore_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int sync_server);
+INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int sync_server);
-INTERNAL_FUNC int emcore_delete_mails_from_local_storage(int account_id, int *mail_ids, int num, int noti_param_1, int noti_param_2, int *err_code);
+INTERNAL_FUNC int emcore_delete_mails_from_local_storage(char *multi_user_name, int account_id, int *mail_ids, int num, int noti_param_1, int noti_param_2, int *err_code);
INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(email_account_t *account, email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code);
-INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(int input_mailbox_id);
-INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(int input_account_id, int input_mailbox_id);
+INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(char *multi_user_name, int input_mailbox_id);
+INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(char *multi_user_name, int input_account_id, int input_mailbox_id);
/**
* Delete mails.
@@ -340,7 +314,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(int in
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emcore_delete_mail(int account_id, int mail_id[], int num, int from_server, int noti_param_1, int noti_param_2, int *err_code);
+INTERNAL_FUNC int emcore_delete_mail(char *multi_user_name, int account_id, int mail_id[], int num, int from_server, int noti_param_1, int noti_param_2, int *err_code);
/**
* Delete mails.
@@ -351,38 +325,62 @@ INTERNAL_FUNC int emcore_delete_mail(int account_id, int mail_id[], int num, int
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emcore_delete_all_mails_of_acount(int input_account_id);
-INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(int input_account_id, int input_mailbox_id, int input_from_server, int *err_code);
+INTERNAL_FUNC int emcore_delete_all_mails_of_acount(char *multi_user_name, int input_account_id);
+INTERNAL_FUNC int emcore_delete_all_mails_of_mailbox(char *multi_user_name,
+ int input_account_id,
+ int input_mailbox_id,
+ int input_mailbox_type,
+ int input_from_server,
+ int *err_code);
INTERNAL_FUNC void emcore_free_mail_data_list(email_mail_data_t **mail_list, int count);
INTERNAL_FUNC void emcore_free_mail_data(email_mail_data_t *mail);
INTERNAL_FUNC void emcore_free_content_info(struct _m_content_info *cnt_info);
INTERNAL_FUNC void emcore_free_attachment_info(struct attachment_info *attchment);
-INTERNAL_FUNC int emcore_move_mail_on_server(int account_id, int src_mailbox_id, int mail_ids[], int num, char *dest_mailbox, int *error_code);
+INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_id, int src_mailbox_id, int mail_ids[], int num, char *dest_mailbox, int *error_code);
INTERNAL_FUNC int emcore_move_mail_on_server_by_server_mail_id(void *mail_stream, char *server_mail_id, char *dest_mailbox_name);
-INTERNAL_FUNC int emcore_move_mail_to_another_account(int input_mail_id, int input_source_mailbox_id, int input_target_mailbox_id, int input_task_id);
-INTERNAL_FUNC int emcore_sync_flag_with_server(int mail_id, int event_handle, int *err_code);
-INTERNAL_FUNC int emcore_sync_seen_flag_with_server(int mail_ids[], int num, int event_handle, int *err_code);
+INTERNAL_FUNC int emcore_move_mail_to_another_account(char *multi_user_name, int input_mail_id, int input_source_mailbox_id, int input_target_mailbox_id, int input_task_id);
+INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_id, int event_handle, int *err_code);
+INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int mail_ids[], int num, int event_handle, int *err_code);
-INTERNAL_FUNC int emcore_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
-INTERNAL_FUNC char* emcore_convert_mutf7_to_utf8(char *mailbox_name);
+INTERNAL_FUNC int emcore_set_flags_field(char *multi_user_name, int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
INTERNAL_FUNC int emcore_convert_string_to_structure(const char *encoded_string, void **struct_var, email_convert_struct_type_e type);
-INTERNAL_FUNC int emcore_save_mail_file(int account_id, int mail_id, int attachment_id, char *src_file_path, char *file_name, char *full_path, int max_path_len, int *err_code);
+INTERNAL_FUNC int emcore_save_mail_file(char *multi_user_name, int account_id, int mail_id, int attachment_id, char *src_file_path, char *file_name, char *full_path, char *virtual_path, int *err_code);
#ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
-INTERNAL_FUNC int emcore_sync_flags_field_with_server(int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
-INTERNAL_FUNC int emcore_move_mail_on_server_ex(int account_id, int src_mailbox_id, int mail_ids[], int num, int dest_mailbox_id, int *error_code);
+INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int mail_ids[], int num, email_flags_field_type field_type, int value, int *err_code);
+INTERNAL_FUNC int emcore_move_mail_on_server_ex(char *multi_user_name, int account_id, int src_mailbox_id, int mail_ids[], int num, int dest_mailbox_id, int *error_code);
#endif
#ifdef __ATTACHMENT_OPTI__
INTERNAL_FUNC int emcore_download_attachment_bulk(/*email_mailbox_t *mailbox, */ int account_id, int mail_id, char *nth, int event_handle, int *err_code);
#endif
-INTERNAL_FUNC int emcore_mail_filter_by_rule(email_rule_t *filter_info, int *err_code);
-INTERNAL_FUNC int emcore_add_rule(email_rule_t *filter_info);
-INTERNAL_FUNC int emcore_update_rule(int filter_id, email_rule_t *filter_info);
-INTERNAL_FUNC int emcore_delete_rule(int filter_id);
+INTERNAL_FUNC int emcore_mail_filter_by_rule(char *multi_user_name, email_rule_t *filter_info, int *err_code);
+INTERNAL_FUNC int emcore_add_rule(char *multi_user_name, email_rule_t *filter_info);
+INTERNAL_FUNC int emcore_update_rule(char *multi_user_name, int filter_id, email_rule_t *filter_info);
+INTERNAL_FUNC int emcore_delete_rule(char *multi_user_name, int filter_id);
+
+/**
+ * Search the mails on server
+ *
+ * @param[in] account_id Specifies the id of account
+ * @param[in] mailbox_id Specifies the id of mailbox
+ * @param[in] input_search_filter Specifies the filter list for searching field
+ * @param[in] input_search_filter_count Specifies the filter count
+ * @param[in] cancellable Specifies the cancellable
+ * @param[in] handle Specifies the handle for searching mails
+ * @remarks N/A
+ * @return EMAIL_ERROR_NONE on success or an error code (refer to EMAIL_ERROR_XXX) on failure
+ */
+INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name,
+ int account_id,
+ int mailbox_id,
+ email_search_filter_t *input_search_filter,
+ int input_search_filter_count,
+ int cancellable,
+ int event_handle);
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/email-core/include/email-core-mailbox-sync.h b/email-core/include/email-core-mailbox-sync.h
index 9383257..52d4165 100755
--- a/email-core/include/email-core-mailbox-sync.h
+++ b/email-core/include/email-core-mailbox-sync.h
@@ -77,12 +77,12 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
int emcore_check_rule(const char *input_full_address_from, const char *input_subject, emstorage_rule_tbl_t *rule, int rule_len, int *priority_sender, int *blocked, int *err_code);
-INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(int account_id, MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code);
+INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(char *multi_user_name, int account_id, MAILSTREAM *mail_stream, ENVELOPE *input_envelope, emcore_uid_list *input_uid_elem, emstorage_mail_tbl_t **output_mail_tbl_data, int *err_code);
-INTERNAL_FUNC int emcore_add_mail_to_mailbox(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, int *output_mail_id, int *output_thread_id);
+INTERNAL_FUNC int emcore_add_mail_to_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, int *output_mail_id, int *output_thread_id);
#ifdef __FEATURE_BODY_SEARCH__
-int emcore_add_mail_text(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, char *stripped_text, int *err_code);
+int emcore_add_mail_text(char *multi_user_name, emstorage_mailbox_tbl_t *input_maibox_data, emstorage_mail_tbl_t *input_new_mail_tbl_data, char *stripped_text, int *err_code);
#endif
/**
@@ -96,7 +96,8 @@ int emcore_add_mail_text(emstorage_mailbox_tbl_t *input_maibox_data, emstorage_m
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emcore_sync_header (emstorage_mailbox_tbl_t *input_mailbox_tbl,
+INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
+ emstorage_mailbox_tbl_t *input_mailbox_tbl,
void **stream,
emcore_uid_list **input_uid_list,
int *mail_count,
@@ -126,7 +127,7 @@ typedef enum
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-int emcore_download_uid_all (MAILSTREAM *mail_stream, email_internal_mailbox_t *mailbox, emcore_uid_list **uid_list,
+int emcore_download_uid_all (char *multi_user_name, MAILSTREAM *mail_stream, email_internal_mailbox_t *mailbox, emcore_uid_list **uid_list,
int *total, emstorage_read_mail_uid_tbl_t *read_mail_uids, int count,
emcore_get_uids_for_delete_t for_delete, int *err_code);
@@ -142,7 +143,7 @@ int emcore_download_uid_all (MAILSTREAM *mail_stream, email_internal_mailbox_t *
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-int emcore_download_imap_msgno(email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code);
+int emcore_download_imap_msgno(char *multi_user_name, email_internal_mailbox_t *mailbox, char *uid, int *msgno, int *err_code);
/**
* Get a message number to be related to uid.
@@ -177,12 +178,26 @@ int emcore_get_uid(emcore_uid_list *uid_list, int msgno, char **uid, int *err_co
*/
int emcore_free_uids(emcore_uid_list *uid_list, int *err_code);
-INTERNAL_FUNC char *emcore_guess_charset(char *source_string);
-INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(int mail_id);
-INTERNAL_FUNC int emcore_update_attachment_except_inline(struct _m_content_info *cnt_info, int account_id, int mail_id, int mailbox_id, int *output_total_attachment_size, int *output_attachment_count, int *output_inline_attachment_count);
+INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name, int mail_id);
+INTERNAL_FUNC int emcore_update_attachment_except_inline(char *multi_user_name,
+ struct _m_content_info *cnt_info,
+ int account_id,
+ int mail_id,
+ int mailbox_id,
+ int *output_total_attachment_size,
+ int *output_attachment_count,
+ int *output_inline_attachment_count);
#ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
-INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, email_event_partial_body_thd *pbd_event, int count, int *error);
+INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream,
+ email_event_partial_body_thd *pbd_event,
+ int count,
+ int *error);
+
+INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream,
+ int account_id, int mail_id, char *uid,
+ int input_mailbox_id, char *input_mailbox_name,
+ int *err_code);
#endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */
diff --git a/email-core/include/email-core-mailbox.h b/email-core/include/email-core-mailbox.h
index 6d9babc..3b8aea7 100755
--- a/email-core/include/email-core-mailbox.h
+++ b/email-core/include/email-core-mailbox.h
@@ -53,8 +53,8 @@ INTERNAL_FUNC int emcore_remove_connection_info(int account_id);
#endif /* __FEATURE_KEEP_CONNECTION__ */
/* in SMTP case, path argument must be (ENCODED_PATH_SMTP) */
/* ex) emcore_connect_to_remote_mailbox(xxx, (char *)ENCODED_PATH_SMTP, xxx, xxx); */
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(email_account_t *ref_account, int input_mailbox_id, void **mail_stream, int *err_code);
-INTERNAL_FUNC int emcore_connect_to_remote_mailbox(int account_id, int input_mailbox_id, void **mail_stream, int *err_code);
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi_user_name, email_account_t *ref_account, int input_mailbox_id, void **mail_stream, int *err_code);
+INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name, int account_id, int input_mailbox_id, void **mail_stream, int *err_code);
INTERNAL_FUNC int emcore_close_mailbox(int account_id, void *mail_stream);
#ifdef __FEATURE_KEEP_CONNECTION__
INTERNAL_FUNC void emcore_close_mailbox_receiving_stream();
@@ -62,18 +62,18 @@ INTERNAL_FUNC void emcore_close_mailbox_partial_body_stream();
INTERNAL_FUNC void emcore_reset_streams();
#endif
-INTERNAL_FUNC int emcore_get_mailbox_list_to_be_sync(int account_id, email_mailbox_t **mailbox_list, int *p_count, int *err_code);
-INTERNAL_FUNC int emcore_get_mailbox_list(int account_id, email_mailbox_t **mailbox_list, int *p_count, int *err_code);
-INTERNAL_FUNC int emcore_get_mail_count(email_mailbox_t *mailbox, int *total, int *unseen, int *err_code);
-INTERNAL_FUNC int emcore_create_mailbox(email_mailbox_t *new_mailbox, int on_server, int server_type, int slot_size, int *err_code);
-INTERNAL_FUNC int emcore_delete_mailbox(int input_mailbox_id, int input_on_server, int input_recursive);
-INTERNAL_FUNC int emcore_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, int input_on_server, int input_recursive);
-INTERNAL_FUNC int emcore_delete_mailbox_all(email_mailbox_t *mailbox, int *err_code);
-INTERNAL_FUNC int emcore_rename_mailbox(int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int input_recursive, int handle_to_be_published);
+INTERNAL_FUNC int emcore_get_mailbox_list_to_be_sync(char *multi_user_name, int account_id, email_mailbox_t **mailbox_list, int *p_count, int *err_code);
+INTERNAL_FUNC int emcore_get_mailbox_list(char *multi_user_name, int account_id, email_mailbox_t **mailbox_list, int *p_count, int *err_code);
+INTERNAL_FUNC int emcore_get_mail_count(char *multi_user_name, email_mailbox_t *mailbox, int *total, int *unseen, int *err_code);
+INTERNAL_FUNC int emcore_create_mailbox(char *multi_user_name, email_mailbox_t *new_mailbox, int on_server, int server_type, int slot_size, int *err_code);
+INTERNAL_FUNC int emcore_delete_mailbox(char *multi_user_name, int input_mailbox_id, int input_on_server, int input_recursive);
+INTERNAL_FUNC int emcore_delete_mailbox_ex(char *multi_user_name, int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, int input_on_server, int input_recursive);
+INTERNAL_FUNC int emcore_delete_mailbox_all(char *multi_user_name, email_mailbox_t *mailbox, int *err_code);
+INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name, int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int input_recursive, int handle_to_be_published);
INTERNAL_FUNC int emcore_save_local_activity_sync(int account_id, int *err_code);
INTERNAL_FUNC int emcore_send_mail_event(email_mailbox_t *mailbox, int mail_id , int *err_code);
-INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(int *is_event_inserted, int *err_code);
-INTERNAL_FUNC int emcore_get_mailbox_by_type(int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t *spam_mailbox, int *err_code);
+INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(char *multi_user_name, int *is_event_inserted, int *err_code);
+INTERNAL_FUNC int emcore_get_mailbox_by_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, email_mailbox_t *spam_mailbox, int *err_code);
INTERNAL_FUNC void emcore_free_mailbox_list(email_mailbox_t **mailbox_list, int count);
INTERNAL_FUNC void emcore_free_mailbox(email_mailbox_t *mailbox);
@@ -82,7 +82,7 @@ INTERNAL_FUNC int emcore_free_internal_mailbox(email_internal_mailbox_t **mailb
INTERNAL_FUNC void emcore_close_recv_stream_list (void);
-INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (int account_id, int mailbox_id, int *error);
+INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (char *multi_user_name, int account_id, int mailbox_id, int *error);
#ifdef __FEATURE_LOCAL_ACTIVITY__
INTERNAL_FUNC int emcore_local_activity_sync(int account_id, int *err_code);
diff --git a/email-core/include/email-core-mime.h b/email-core/include/email-core-mime.h
index 0cbee55..05a2601 100755
--- a/email-core/include/email-core-mime.h
+++ b/email-core/include/email-core-mime.h
@@ -41,20 +41,18 @@ extern "C" {
#endif /* __cplusplus */
char *emcore_get_line_from_file(void *stream, char *buf, int size, int *err_code);
-int emcore_parse_mime(void *stream, int is_file, struct _m_content_info *cnt_info, int *err_code);
char *emcore_mime_get_save_file_name(int *err_code);
char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err_code);
INTERNAL_FUNC int emcore_get_content_type_from_mime_string(char *input_mime_string, char **output_content_type);
INTERNAL_FUNC int emcore_get_content_type_from_mail_bodystruct(BODY *input_body, int input_buffer_length, char *output_content_type);
INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param, char *atribute_name, char *output_value, int output_buffer_length, int with_rfc2047_text, int *err_code);
-INTERNAL_FUNC int emcore_get_body_part_list_full(MAILSTREAM *stream, int msg_uid, int account_id, int mail_id, BODY *body, struct _m_content_info *cnt_info, int *err_code, PARTLIST * section_list, int event_handle);
INTERNAL_FUNC int emcore_get_body(MAILSTREAM *stream, int account_id, int mail_id, int msg_uid, BODY *body, char *part_body_type, struct _m_content_info *cnt_info, int *err_code);
INTERNAL_FUNC int emcore_get_body_structure(MAILSTREAM *stream, int msg_uid, BODY **body, int *err_code);
INTERNAL_FUNC char *emcore_decode_rfc2047_text(char *rfc2047_text, int *err_code);
INTERNAL_FUNC int emcore_decode_body_text(char *enc_buf, int enc_len, int enc_type, int *dec_len, int *err_code);
INTERNAL_FUNC int emcore_set_fetch_body_section(BODY *body, int enable_inline_list, int *total_mail_size, int *total_body_size, int *err_code);
INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data, int *output_attachment_count, int *err_code);
-INTERNAL_FUNC int emcore_delete_parsed_data(email_mail_data_t *input_mail_data, int *err_code);
+INTERNAL_FUNC int emcore_delete_parsed_data(char *multi_user_name, email_mail_data_t *input_mail_data, int *err_code);
INTERNAL_FUNC int emcore_get_mime_entity(char *mime_path, char **mime_entity, int *err_code);
INTERNAL_FUNC int emcore_get_utf8_address(char **dest, ADDRESS *address, int *err_code);
INTERNAL_FUNC int emcore_get_digest_type(char *micalg_value);
diff --git a/email-core/include/email-core-smime.h b/email-core/include/email-core-smime.h
index 0c95e92..547f0fa 100755
--- a/email-core/include/email-core-smime.h
+++ b/email-core/include/email-core-smime.h
@@ -39,15 +39,15 @@
INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, char *mime_entity, email_digest_type digest_type, char **file_path, int *err_code);
-INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *other_certificate_list, char *mime_entity, email_cipher_type cipher_type, char **file_path, int *err_code);
+INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *multi_user_name, char *other_certificate_list, char *mime_entity, email_cipher_type cipher_type, char **file_path, int *err_code);
-INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *recipient_list, char *certificate, char *mime_entity, email_cipher_type cipher_type, email_digest_type digest_type, char **file_path, int *err_code);
+INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_name, char *recipient_list, char *certificate, char *mime_entity, email_cipher_type cipher_type, email_digest_type digest_type, char **file_path, int *err_code);
INTERNAL_FUNC int emcore_smime_verify_signed_message(char *signed_message, char *ca_file, char *ca_path, int *verify);
INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message, char *from_address, char **decrypt_message, int *err_code);
-INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(emstorage_account_tbl_t *account_tbl_item, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data_list, int *output_attachment_count);
+INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name, emstorage_account_tbl_t *account_tbl_item, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_mail_data_t **output_mail_data, email_attachment_data_t **output_attachment_data_list, int *output_attachment_count);
INTERNAL_FUNC void emcore_init_openssl_library();
INTERNAL_FUNC void emcore_clean_openssl_library();
diff --git a/email-core/include/email-core-smtp.h b/email-core/include/email-core-smtp.h
index b0dafc5..0e6f8f6 100755
--- a/email-core/include/email-core-smtp.h
+++ b/email-core/include/email-core-smtp.h
@@ -42,31 +42,31 @@ extern "C"
#include "c-client.h"
#include "email-internal-types.h"
-INTERNAL_FUNC int emcore_send_mail(int mail_id, int *err_code);
+INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_code);
-INTERNAL_FUNC int emcore_send_saved_mail(int account_id, char *mailbox, int *err_code);
+INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id, char *mailbox, int *err_code);
-INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(int input_mail_id);
+INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(char *multi_user_name, int input_mail_id);
-INTERNAL_FUNC int emcore_schedule_sending_mail(int input_mail_id, time_t input_time_to_send);
+INTERNAL_FUNC int emcore_schedule_sending_mail(char *multi_user_name, int input_mail_id, time_t input_time_to_send);
-INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(emstorage_mail_tbl_t *input_mail_tbl_data, emstorage_attachment_tbl_t *input_attachment_tbl_t, int input_attachment_count, ENVELOPE **env, char **file_path, email_option_t *sending_option, int *err_code);
+INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emstorage_mail_tbl_t *input_mail_tbl_data, emstorage_attachment_tbl_t *input_attachment_tbl_t, int input_attachment_count, ENVELOPE **env, char **file_path, email_option_t *sending_option, int *err_code);
-INTERNAL_FUNC int emcore_make_rfc822_file(email_mail_data_t *input_mail_tbl_data, email_attachment_data_t *input_attachment_tbl, int input_attachment_count, int mime_entity_status, char **file_path, int *err_code);
+INTERNAL_FUNC int emcore_make_rfc822_file(char *multi_user_name, email_mail_data_t *input_mail_tbl_data, email_attachment_data_t *input_attachment_tbl, int input_attachment_count, int mime_entity_status, char **file_path, int *err_code);
-INTERNAL_FUNC int emcore_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas, int move_flag);
+INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas, int move_flag);
-INTERNAL_FUNC int emcore_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id);
+INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_mail_id, int *output_receipt_mail_id);
-INTERNAL_FUNC int emcore_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int *err_code);
+INTERNAL_FUNC int emcore_add_meeting_request(char *multi_user_name, int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int *err_code);
-INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(int input_alarm_interval_in_second);
+INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(char *multi_user_name, int input_alarm_interval_in_second);
-INTERNAL_FUNC int emcore_query_mail_size_limit(int account_id, int handle, int *err_code);
+INTERNAL_FUNC int emcore_query_mail_size_limit(char *multi_user_name, int account_id, int handle, int *err_code);
INTERNAL_FUNC void emcore_close_smtp_stream_list (void);
-INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (int account_id, int *error);
+INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (char *multi_user_name, int account_id, int *error);
#ifdef __cplusplus
}
diff --git a/email-core/include/email-core-task-manager.h b/email-core/include/email-core-task-manager.h
index 19d97a4..c792ef2 100755
--- a/email-core/include/email-core-task-manager.h
+++ b/email-core/include/email-core-task-manager.h
@@ -38,12 +38,12 @@ INTERNAL_FUNC int emcore_free_task_handler_array();
INTERNAL_FUNC int emcore_encode_task_parameter(email_task_type_t input_task_type, void *input_task_parameter_struct, char **output_byte_stream, int *output_stream_size);
INTERNAL_FUNC int emcore_decode_task_parameter(email_task_type_t input_task_type, char *input_byte_stream, int input_stream_size, void **output_task_parameter_struct);
-INTERNAL_FUNC int emcore_add_task_to_task_table(email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int *output_task_id);
-INTERNAL_FUNC int emcore_remove_task_from_task_table(int input_task_id);
+INTERNAL_FUNC int emcore_add_task_to_task_table(char *multi_user_name, email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int *output_task_id);
+INTERNAL_FUNC int emcore_remove_task_from_task_table(char *multi_user_name, int input_task_id);
INTERNAL_FUNC int emcore_get_active_task_by_thread_id(thread_t input_thread_id, email_active_task_t **output_active_task);
INTERNAL_FUNC void* emcore_default_async_task_handler(void *intput_param);
-INTERNAL_FUNC void* emcore_default_sync_task_handler(void *intput_param);
+INTERNAL_FUNC int emcore_default_sync_task_handler(void *intput_param);
INTERNAL_FUNC int emcore_start_task_manager_loop();
INTERNAL_FUNC int emcore_stop_task_manager_loop();
diff --git a/email-core/include/email-core-tasks.h b/email-core/include/email-core-tasks.h
index 0c4c092..dde99ef 100755
--- a/email-core/include/email-core-tasks.h
+++ b/email-core/include/email-core-tasks.h
@@ -63,6 +63,7 @@ typedef struct
int target_mailbox_id;
int mail_id_count;
int *mail_id_array;
+ char *multi_user_name;
} task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT;
DECLARE_CONVERTER_FOR_TASK_PARAMETER(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT);
@@ -76,6 +77,7 @@ typedef struct
int mailbox_id_count;
int *mailbox_id_array;
int on_server;
+ char *multi_user_name;
} task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX;
DECLARE_CONVERTER_FOR_TASK_PARAMETER(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX);
@@ -85,6 +87,7 @@ INTERNAL_FUNC void* task_handler_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX(void *input_
typedef struct
{
int mail_id;
+ char *multi_user_name;
} task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL;
DECLARE_CONVERTER_FOR_TASK_PARAMETER(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL);
@@ -93,6 +96,7 @@ INTERNAL_FUNC void* task_handler_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATT
/* to handle EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL */
typedef struct
{
+ char *multi_user_name;
int mail_id;
time_t scheduled_time;
} task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL;
@@ -109,6 +113,7 @@ typedef struct
email_mail_attribute_type attribute_type;
int value_length;
email_mail_attribute_value_t value;
+ char *multi_user_name;
} task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE;
DECLARE_CONVERTER_FOR_TASK_PARAMETER(EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE);
diff --git a/email-core/include/email-core-utils.h b/email-core/include/email-core-utils.h
index 3e8e53d..03dd486 100755
--- a/email-core/include/email-core-utils.h
+++ b/email-core/include/email-core-utils.h
@@ -54,29 +54,29 @@ char* emcore_get_alias_of_mailbox(const char *mailbox_path);
/* Parse the Mailbox Path and get the Account Email address */
INTERNAL_FUNC int emcore_get_temp_file_name(char **filename, int *err_code);
-int emcore_get_long_encoded_path(int account_id, char *path, int delimiter, char **long_enc_path, int *err_code);
+int emcore_get_long_encoded_path(char *multi_user_name, int account_id, char *path, int delimiter, char **long_enc_path, int *err_code);
int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code);
int emcore_get_file_name(char *path, char **filename, int *err_code);
INTERNAL_FUNC int emcore_get_file_size(char *path, int *size, int *err_code);
int emcore_get_actual_mail_size(char *pBodyPlane, char *pBodyHtml, struct attachment_info *pAttachment, int *error_code);
-int emcore_calc_mail_size(email_mail_data_t *mail_data_src, email_attachment_data_t *attachment_data_src, int attachment_count, int *error_code);
+int emcore_calc_mail_size(char *multi_user_name, email_mail_data_t *mail_data_src, email_attachment_data_t *attachment_data_src, int attachment_count, int *error_code);
int emcore_get_address_count(char *addr_str, int *to_num, int *err_code);
INTERNAL_FUNC int emcore_is_storage_full();
-int emcore_get_long_encoded_path_with_account_info(email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code);
-void emcore_fill_address_information_of_mail_tbl(emstorage_mail_tbl_t *mail_data);
+int emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code);
+void emcore_fill_address_information_of_mail_tbl(char *multi_user_name, emstorage_mail_tbl_t *mail_data);
INTERNAL_FUNC char* emcore_get_mail_field_name_by_attribute_type(email_mail_attribute_type input_attribute_type);
INTERNAL_FUNC int emcore_get_attribute_type_by_mail_field_name(char *input_mail_field_name, email_mail_attribute_type *output_mail_attribute_type);
INTERNAL_FUNC int emcore_get_mail_attribute_value_type(email_mail_attribute_type input_attribute_type, email_mail_attribute_value_type *output_value_type);
-INTERNAL_FUNC int emcore_get_preview_text_from_file(const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer);
+INTERNAL_FUNC int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer);
#ifdef __FEATURE_BODY_SEARCH__
-INTERNAL_FUNC int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped_text, int *err_code);
+INTERNAL_FUNC int emcore_strip_mail_body_from_file(char *multi_user_name, emstorage_mail_tbl_t *mail, char **stripped_text, int *err_code);
#endif
INTERNAL_FUNC int emcore_get_first_address(const char *full_address, char **alias, char **address);
INTERNAL_FUNC int reg_replace (char *input_source_text, char *input_old_pattern_string, char *input_new_string);
-INTERNAL_FUNC int reg_replace_new (char **input_source_text, char *input_old_pattern_string, char *input_new_string);
+INTERNAL_FUNC char *reg_replace_new (char *input_source_text, char *input_old_pattern_string, char *input_new_string);
int emcore_strip_HTML_tag(const char *input_html_file_path, char *encoding_type, char *output_result_buffer, int input_result_buffer_legnth);
int emcore_send_noti_for_new_mail(int account_id, char *mailbox_name, char *subject, char *from, char *uid, char *datetime);
int emcore_make_attachment_file_name_with_extension(char *source_file_name, char *sub_type, char *result_file_name, int result_file_name_buffer_length, int *err_code);
@@ -86,16 +86,16 @@ INTERNAL_FUNC int emcore_get_empty_session(email_session_t **session);
INTERNAL_FUNC int emcore_clear_session(email_session_t *session);
INTERNAL_FUNC int emcore_get_current_session(email_session_t **session);
-INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_type, int priority_sender, int *total_mail, int *unread_mail, int *err_code);
+INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int account_id, int mailbox_type, int priority_sender, int *total_mail, int *unread_mail, int *err_code);
INTERNAL_FUNC int emcore_check_drm_file(char *path, int *err_code);
INTERNAL_FUNC int emcore_check_drm_is_ringtone(char *ringtone_path, int *err_code);
INTERNAL_FUNC void emcore_display_unread_in_badge(void *data);
-INTERNAL_FUNC int emcore_display_badge_count(int count);
+INTERNAL_FUNC int emcore_display_badge_count(char *multi_user_name, int count);
INTERNAL_FUNC int emcore_set_network_error(int err_code);
-INTERNAL_FUNC int emcore_calc_next_time_to_sync(int input_account_id, time_t input_current_time, time_t *output_time);
+INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input_account_id, time_t input_current_time, time_t *output_time);
/* Transaction Handling */
INTERNAL_FUNC int emcore_add_transaction_info(int mail_id , int handle , int *err_code);
@@ -104,20 +104,18 @@ INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id);
/* For notification bar */
INTERNAL_FUNC int emcore_update_notification_for_unread_mail(int account_id);
-INTERNAL_FUNC int emcore_clear_notifications(int account_id);
+INTERNAL_FUNC int emcore_clear_notifications(char *multi_user_name, int account_id);
//INTERNAL_FUNC int emcore_add_notification_for_unread_mail(emstorage_mail_tbl_t *input_mail_tbl_data);
-INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display);
-INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display);
+INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display);
+INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display);
INTERNAL_FUNC void emcore_update_notification_for_send(int account_id, int mail_id, double progress);
INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id);
-INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id, int with_noti_tray);
-INTERNAL_FUNC void emcore_set_flash_noti();
+INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int with_noti_tray);
+INTERNAL_FUNC int emcore_show_user_message(char *multi_user_name, int id, email_action_t action, int error);
-INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int error);
-
-INTERNAL_FUNC int emcore_connect_contacts_service();
-INTERNAL_FUNC int emcore_disconnect_contacts_service();
+INTERNAL_FUNC int emcore_connect_contacts_service(char *multi_user_name);
+INTERNAL_FUNC int emcore_disconnect_contacts_service(char *multi_user_name);
#ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
@@ -215,15 +213,17 @@ INTERNAL_FUNC int emcore_search_string_from_file(char *file_path, char *search_s
INTERNAL_FUNC int emcore_load_query_from_file(char *file_path, char ***query_array, int *array_len);
-INTERNAL_FUNC int emcore_start_driving_mode(int mail_id);
+#ifdef __FEATURE_DRIVING_MODE__
+INTERNAL_FUNC int emcore_start_driving_mode(char *multi_user_name, int mail_id);
+#endif /* __FEATURE_DRIVING_MODE__ */
#ifdef __FEATURE_BLOCKING_MODE__
INTERNAL_FUNC bool emcore_init_blocking_mode_status();
INTERNAL_FUNC void emcore_set_blocking_mode_of_setting(int input_blocking_mode_of_setting);
INTERNAL_FUNC int emcore_get_blocking_mode_status();
INTERNAL_FUNC void emcore_set_blocking_mode_status(int blocking_mode);
-INTERNAL_FUNC int emcore_check_blocking_mode(char *sender_address, int *blocking_status);
-INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int *blocking_status);
+INTERNAL_FUNC int emcore_check_blocking_mode(char *multi_user_name, char *sender_address, int *blocking_status);
+INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, char *sender_address, int *blocking_status);
#endif /* __FEATURE_BLOCKING_MODE__ */
INTERNAL_FUNC char *emcore_set_mime_entity(char *mime_path);
@@ -231,13 +231,20 @@ INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents,
INTERNAL_FUNC int emcore_set_content_to_file(const char *contents, char *dest_path, int length);
#ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__
-INTERNAL_FUNC int emcore_update_db_table_schema();
+INTERNAL_FUNC int emcore_update_db_table_schema(char *multi_user_name);
#endif /* #ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__ */
INTERNAL_FUNC int emcore_unescape_from_url(char *input_url, char **output_url);
INTERNAL_FUNC char *__em_get_month_in_string(int month);
INTERNAL_FUNC int emcore_make_date_string_for_search(time_t input_time, char *output_date_string);
INTERNAL_FUNC int emcore_make_uid_range_string(emcore_uid_list *uid_list, int total, char **output_uid_range_string);
+#ifdef __FEATURE_DBUS_CALL_STATUS__
+INTERNAL_FUNC int emcore_init_dbus_call_status();
+INTERNAL_FUNC void emcore_shutdown_dbus_call_status();
+INTERNAL_FUNC int emcore_get_call_status();
+#endif /* __FEATURE_DBUS_CALL_STATUS__ */
+
+INTERNAL_FUNC char* emcore_convert_mutf7_to_utf8(char *mailbox_name);
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/email-daemon/CMakeLists.txt b/email-daemon/CMakeLists.txt
index 11b1f94..391e671 100755
--- a/email-daemon/CMakeLists.txt
+++ b/email-daemon/CMakeLists.txt
@@ -15,7 +15,7 @@ ADD_DEFINITIONS("-DSSL_CERT_DIRECTORY=\"/opt/etc/ssl/certs\"")
ADD_DEFINITIONS("-DSSL_KEY_DIRECTORY=\"/opt/etc/ssl/certs\"")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections -fPIE")
##########################################################
@@ -48,10 +48,12 @@ INCLUDE_DIRECTORIES(
)
INCLUDE(FindPkgConfig)
-pkg_check_modules(main_pkgs REQUIRED glib-2.0 dlog dbus-1 gthread-2.0
- openssl uw-imap-toolkit vconf vconf-internal-keys contacts-service2
- alarm-service msg-service
- libwbxml2 libsmack notification capi-network-connection gmime-2.6)
+SET(PKG_MODULES glib-2.0 dlog dbus-1 gthread-2.0 openssl uw-imap-toolkit
+ vconf vconf-internal-keys contacts-service2 alarm-service
+ msg-service libwbxml2 libsmack notification
+ capi-network-connection gmime-2.6)
+
+pkg_check_modules(main_pkgs REQUIRED ${PKG_MODULES})
FOREACH(flag ${main_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/email-daemon/email-daemon-account.c b/email-daemon/email-daemon-account.c
index adcad2a..f1f0d42 100755
--- a/email-daemon/email-daemon-account.c
+++ b/email-daemon/email-daemon-account.c
@@ -50,7 +50,7 @@
#include "email-utilities.h"
#include "email-convert.h"
-static int emdaemon_check_filter_id(int filter_id, int* err_code)
+static int emdaemon_check_filter_id(char *multi_user_name, int filter_id, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_id[%d], err_code[%p]", filter_id, err_code);
@@ -66,9 +66,8 @@ static int emdaemon_check_filter_id(int filter_id, int* err_code)
int err = EMAIL_ERROR_NONE;
emstorage_rule_tbl_t* filter = NULL;
- if (!emstorage_get_rule_by_id(filter_id, &filter, true, &err)) {
+ if (!emstorage_get_rule_by_id(multi_user_name, filter_id, &filter, true, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_rule_by_id failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -85,12 +84,12 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emdaemon_create_account(email_account_t* account, int* err_code)
+INTERNAL_FUNC int emdaemon_create_account(char *multi_user_name, email_account_t* account, int* err_code)
{
int ret = false;
int err = EMAIL_ERROR_NONE;
- if (!emcore_create_account(account, false, &err)) {
+ if (!emcore_create_account(multi_user_name, account, false, &err)) {
EM_DEBUG_EXCEPTION(" emcore_account_add failed [%d]", err);
goto FINISH_OFF;
}
@@ -104,12 +103,12 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emdaemon_delete_account(int account_id, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_account(char *multi_user_name, int account_id, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d] err_code[%p]", account_id, err_code);
int ret = false;
- ret = emcore_delete_account(account_id, false, err_code);
+ ret = emcore_delete_account(multi_user_name, account_id, false, err_code);
EM_DEBUG_FUNC_END("ret[%d]", ret);
return ret;
@@ -141,7 +140,7 @@ static email_account_t* duplicate_account(email_account_t *src)
dst->reply_to_address = EM_SAFE_STRDUP(src->reply_to_address);
dst->return_address = EM_SAFE_STRDUP(src->return_address);
dst->logo_icon_path = EM_SAFE_STRDUP(src->logo_icon_path);
- dst->certificate_path = EM_SAFE_STRDUP(src->certificate_path);
+ dst->certificate_path = EM_SAFE_STRDUP(src->certificate_path);
dst->options.display_name_from = EM_SAFE_STRDUP(src->options.display_name_from);
dst->options.signature = EM_SAFE_STRDUP(src->options.signature);
dst->user_data = (void*) em_malloc(src->user_data_length);
@@ -157,7 +156,7 @@ static email_account_t* duplicate_account(email_account_t *src)
return dst;
}
-INTERNAL_FUNC int emdaemon_validate_account(int account_id, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_validate_account(char *multi_user_name, int account_id, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p], err_code[%p]", account_id, handle, err_code);
@@ -172,23 +171,18 @@ INTERNAL_FUNC int emdaemon_validate_account(int account_id, int *handle, int* er
goto FINISH_OFF;
}
- if (!(ref_account = emcore_get_account_reference(account_id))) {
+ if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION(" emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
event_data = em_malloc(sizeof(email_event_t));
- if (event_data == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
- err = EMAIL_ERROR_OUT_OF_MEMORY;
- goto FINISH_OFF;
- }
-
event_data->type = EMAIL_EVENT_VALIDATE_ACCOUNT;
event_data->event_param_data_1 = NULL;
event_data->event_param_data_3 = NULL;
event_data->account_id = account_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
@@ -217,7 +211,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_validate_account_ex(email_account_t* input_account, int *output_handle)
+INTERNAL_FUNC int emdaemon_validate_account_ex(char *multi_user_name, email_account_t* input_account, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_account[%p], output_handle[%p]", input_account, output_handle);
@@ -237,6 +231,7 @@ INTERNAL_FUNC int emdaemon_validate_account_ex(email_account_t* input_account, i
event_data->event_param_data_1 = (void*)input_account;
event_data->event_param_data_3 = NULL;
event_data->account_id = NEW_ACCOUNT_ID;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)output_handle, &err)) {
EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
@@ -257,7 +252,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_validate_account_and_create(char *multi_user_name, email_account_t* new_account, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account[%p], handle[%p], err_code[%p]", new_account, handle, err_code);
@@ -273,10 +268,11 @@ INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_acco
goto FINISH_OFF;
}
- event_data->type = EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT;
+ event_data->type = EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT;
event_data->event_param_data_1 = (void *)new_account;
event_data->event_param_data_3 = NULL;
- event_data->account_id = NEW_ACCOUNT_ID;
+ event_data->account_id = NEW_ACCOUNT_ID;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
@@ -301,7 +297,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_account, int* err_code)
+INTERNAL_FUNC int emdaemon_update_account(char *multi_user_name, int account_id, email_account_t* new_account, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p], err_code[%p]", account_id, new_account, err_code);
@@ -317,7 +313,7 @@ INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_a
goto FINISH_OFF;
}
- if((old_account_info = emcore_get_account_reference(account_id)) == NULL) {
+ if((old_account_info = emcore_get_account_reference(multi_user_name, account_id, true)) == NULL) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed ");
goto FINISH_OFF;
}
@@ -345,13 +341,11 @@ INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_a
em_convert_account_to_account_tbl(new_account, new_account_tbl);
- if (!emstorage_update_account(account_id, new_account_tbl, true, &err)) {
+ if (!emstorage_update_account(multi_user_name, account_id, new_account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_account failed [%d]", err);
goto FINISH_OFF;
}
- emcore_init_account_reference();
-
#ifdef __FEATURE_AUTO_POLLING__
int change_in_auto_polling_option = 0;
@@ -369,7 +363,7 @@ INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_a
if(!emdaemon_remove_polling_alarm(account_id))
EM_DEBUG_LOG("emdaemon_remove_polling_alarm failed");
- if(!emdaemon_add_polling_alarm(account_id))
+ if(!emdaemon_add_polling_alarm(multi_user_name, account_id))
EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm failed");
#ifdef __FEATURE_IMAP_IDLE__
@@ -397,7 +391,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, int *handle,int *err_code)
+INTERNAL_FUNC int emdaemon_validate_account_and_update(char *multi_user_name, int old_account_id, email_account_t* new_account_info, int *handle,int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account[%d], new_account_info[%p], handle[%p], err_code[%p]", old_account_id, new_account_info, handle, err_code);
@@ -406,8 +400,7 @@ INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email
email_event_t *event_data = NULL;
event_data = em_malloc(sizeof(email_event_t));
-
- if(!event_data) { /*prevent 53094*/
+ if (!event_data) { /*prevent 53094*/
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
@@ -417,6 +410,7 @@ INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email
event_data->event_param_data_1 = (char *) duplicate_account(new_account_info);
event_data->event_param_data_3 = NULL;
event_data->account_id = old_account_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
#if 0
email_account_t *pAccount = (email_account_t *)em_malloc(sizeof(email_account_t));
@@ -469,7 +463,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, email_account_t* account, int* err_code)
+INTERNAL_FUNC int emdaemon_get_account(char *multi_user_name, int account_id, int pulloption, email_account_t* account, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], pulloption [%d], account[%p], err_code[%p]", account_id, pulloption, account, err_code);
@@ -484,7 +478,7 @@ INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, email_acc
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(account_id, pulloption, &account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, pulloption, &account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -502,7 +496,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_get_account_list(email_account_t** account_list, int* count, int* err_code)
+INTERNAL_FUNC int emdaemon_get_account_list(char *multi_user_name, email_account_t** account_list, int* count, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%p], err_code[%p]", account_list, count, err_code);
@@ -516,7 +510,7 @@ INTERNAL_FUNC int emdaemon_get_account_list(email_account_t** account_list, int*
*count = 1000;
- if (!emstorage_get_account_list(count, &account_tbl_array, true, true, &err)) {
+ if (!emstorage_get_account_list(multi_user_name, count, &account_tbl_array, true, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -552,7 +546,7 @@ INTERNAL_FUNC int emdaemon_free_account(email_account_t** account_list, int coun
}
-INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filter_info, int* err_code)
+INTERNAL_FUNC int emdaemon_get_filter(char *multi_user_name, int filter_id, email_rule_t** filter_info, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_id[%d], filter_info[%p], err_code[%p]", filter_id, filter_info, err_code);
@@ -568,7 +562,7 @@ INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filter_info,
int ret = false;
int err = EMAIL_ERROR_NONE;
- if (!emstorage_get_rule_by_id(filter_id, (emstorage_rule_tbl_t**)filter_info, true, &err)) {
+ if (!emstorage_get_rule_by_id(multi_user_name, filter_id, (emstorage_rule_tbl_t**)filter_info, true, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_rule_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -578,11 +572,12 @@ INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filter_info,
FINISH_OFF:
if (err_code)
*err_code = err;
+
EM_DEBUG_FUNC_END();
return ret;
}
-INTERNAL_FUNC int emdaemon_get_filter_list(email_rule_t** filter_info, int* count, int* err_code)
+INTERNAL_FUNC int emdaemon_get_filter_list(char *multi_user_name, email_rule_t** filter_info, int* count, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_info[%p], count[%p], err_code[%p]", filter_info, count, err_code);
@@ -599,7 +594,7 @@ INTERNAL_FUNC int emdaemon_get_filter_list(email_rule_t** filter_info, int* coun
*count = 1000;
- if (!emstorage_get_rule(ALL_ACCOUNT, 0, 0, count, &is_completed, (emstorage_rule_tbl_t**)filter_info, true, &err)) {
+ if (!emstorage_get_rule(multi_user_name, ALL_ACCOUNT, 0, 0, count, &is_completed, (emstorage_rule_tbl_t**)filter_info, true, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_get_rule failed [%d]", err);
goto FINISH_OFF;
}
@@ -613,7 +608,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code)
+INTERNAL_FUNC int emdaemon_find_filter(char *multi_user_name, email_rule_t* filter_info, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_info[%p], err_code[%p]", filter_info, err_code);
@@ -635,7 +630,7 @@ INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code)
filter_info->account_id = ALL_ACCOUNT; /* MUST BE */
- if (!emstorage_find_rule((emstorage_rule_tbl_t*)filter_info, true, &err)) {
+ if (!emstorage_find_rule(multi_user_name, (emstorage_rule_tbl_t*)filter_info, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_find_rule failed [%d]", err);
goto FINISH_OFF;
} else {
@@ -656,7 +651,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filter_info)
+INTERNAL_FUNC int emdaemon_add_filter(char *multi_user_name, email_rule_t* filter_info)
{
EM_DEBUG_FUNC_BEGIN("filter_info[%p]", filter_info);
@@ -668,7 +663,7 @@ INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filter_info)
goto FINISH_OFF;
}
- err = emcore_add_rule(filter_info);
+ err = emcore_add_rule(multi_user_name, filter_info);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_rule failed : [%d]", err);
goto FINISH_OFF;
@@ -680,7 +675,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emdaemon_update_filter(int filter_id, email_rule_t* filter_info, int* err_code)
+INTERNAL_FUNC int emdaemon_update_filter(char *multi_user_name, int filter_id, email_rule_t* filter_info, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_id[%d], filter_info[%p], err_code[%p]", filter_id, filter_info, err_code);
@@ -694,12 +689,12 @@ INTERNAL_FUNC int emdaemon_update_filter(int filter_id, email_rule_t* filter_inf
goto FINISH_OFF;
}
- if (!emdaemon_check_filter_id(filter_id, &err)) {
+ if (!emdaemon_check_filter_id(multi_user_name, filter_id, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_check_filter_id falied [%d]", err);
goto FINISH_OFF;
}
- err = emcore_update_rule(filter_id, filter_info);
+ err = emcore_update_rule(multi_user_name, filter_id, filter_info);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_update_rule failed : [%d]", err);
goto FINISH_OFF;
@@ -714,7 +709,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_delete_filter(int filter_id, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_filter(char *multi_user_name, int filter_id, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_id[%d, err_code[%p]", filter_id, err_code);
@@ -728,7 +723,7 @@ INTERNAL_FUNC int emdaemon_delete_filter(int filter_id, int* err_code)
goto FINISH_OFF;
}
- err = emcore_delete_rule(filter_id);
+ err = emcore_delete_rule(multi_user_name, filter_id);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_delete_rule failed : [%d]", err);
goto FINISH_OFF;
@@ -779,7 +774,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_apply_filter(int filter_id, int *err_code)
+INTERNAL_FUNC int emdaemon_apply_filter(char *multi_user_name, int filter_id, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("filter_id[%d, err_code[%p]", filter_id, err_code);
@@ -794,12 +789,12 @@ INTERNAL_FUNC int emdaemon_apply_filter(int filter_id, int *err_code)
goto FINISH_OFF;
}
- if (!emstorage_get_rule_by_id(filter_id, &filter_info, false, &err)) {
+ if (!emstorage_get_rule_by_id(multi_user_name, filter_id, &filter_info, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_rule_by_id failed : [%d]", err);
goto FINISH_OFF;
}
- if (!emcore_mail_filter_by_rule((email_rule_t *)filter_info, &err)) {
+ if (!emcore_mail_filter_by_rule(multi_user_name, (email_rule_t *)filter_info, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_mail_filter_by_rule failed [%d]", err);
goto FINISH_OFF;
}
@@ -815,38 +810,6 @@ FINISH_OFF:
/* ----- internal functions --------------------------------------------*/
-int emdaemon_initialize_account_reference()
-{
- EM_DEBUG_FUNC_BEGIN();
- int err = EMAIL_ERROR_NONE;
-
- if ((err = emcore_init_account_reference()) != EMAIL_ERROR_NONE) {
- if (err == EMAIL_ERROR_SECURED_STORAGE_FAILURE) {
- EM_DEBUG_EXCEPTION("EMAIL_ERROR_SECURED_STORAGE_FAILURE occured.");
- if ((err = emcore_recover_from_secured_storage_failure()) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_recover_from_secured_storage_failure failed [%d]", err);
- goto FINISH_OFF;
- }
-
- if ((err = emcore_init_account_reference()) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emcore_init_account_reference failed [%d]", err);
- goto FINISH_OFF;
- }
- }
- else {
- if (err == EMAIL_ERROR_ACCOUNT_NOT_FOUND)
- EM_DEBUG_LOG ("no account found");
- else
- EM_DEBUG_EXCEPTION ("emcore_init_account_reference failed [%d]", err);
- goto FINISH_OFF;
- }
- }
-
-FINISH_OFF:
-
- EM_DEBUG_FUNC_END("err [%d]", err);
- return err;
-}
INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(email_account_t* account)
{
@@ -872,7 +835,7 @@ INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_ac
return ret;
}
-INTERNAL_FUNC int emdaemon_query_smtp_mail_size_limit(int account_id, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_query_smtp_mail_size_limit(char *multi_user_name, int account_id, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p], err_code[%p]", account_id, handle, err_code);
@@ -887,10 +850,17 @@ INTERNAL_FUNC int emdaemon_query_smtp_mail_size_limit(int account_id, int *handl
}
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_QUERY_SMTP_MAIL_SIZE_LIMIT;
event_data->event_param_data_1 = NULL;
event_data->event_param_data_3 = NULL;
event_data->account_id = account_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION(" emcore_insert_event falied [%d]", err);
diff --git a/email-daemon/email-daemon-auto-poll.c b/email-daemon/email-daemon-auto-poll.c
index 301afb0..5ab6884 100755
--- a/email-daemon/email-daemon-auto-poll.c
+++ b/email-daemon/email-daemon-auto-poll.c
@@ -44,9 +44,9 @@
static int _emdaemon_get_polling_account_and_timeinterval(email_alarm_data_t *alarm_data, int *account_id, int *timer_interval);
-static int _emdaemon_create_alarm_for_auto_polling(int input_account_id);
+static int _emdaemon_create_alarm_for_auto_polling(char *multi_user_name, int input_account_id);
-INTERNAL_FUNC int emdaemon_add_polling_alarm(int input_account_id)
+INTERNAL_FUNC int emdaemon_add_polling_alarm(char *multi_user_name, int input_account_id)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d]", input_account_id);
int err = EMAIL_ERROR_NONE;
@@ -62,7 +62,7 @@ INTERNAL_FUNC int emdaemon_add_polling_alarm(int input_account_id)
goto FINISH_OFF;
}
- if((err = _emdaemon_create_alarm_for_auto_polling(input_account_id)) != EMAIL_ERROR_NONE) {
+ if((err = _emdaemon_create_alarm_for_auto_polling(multi_user_name, input_account_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_emdaemon_create_alarm_for_auto_polling failed[%d]", err);
goto FINISH_OFF;
}
@@ -125,13 +125,12 @@ INTERNAL_FUNC int emdaemon_alarm_polling_cb(email_alarm_data_t *alarm_data, void
EM_DEBUG_LOG("target account_id [%d]",account_id);
/* create alarm, for polling */
- if ((err = _emdaemon_create_alarm_for_auto_polling(account_id)) != EMAIL_ERROR_NONE) {
+ if ((err = _emdaemon_create_alarm_for_auto_polling(alarm_data->multi_user_name, account_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("_emdaemon_create_alarm_for_auto_polling failed [%d]", err);
return false;
}
- ref_account = emcore_get_account_reference(account_id);
-
+ ref_account = emcore_get_account_reference(alarm_data->multi_user_name, account_id, false);
if (ref_account == NULL) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed");
err = EMAIL_ERROR_ACCOUNT_NOT_FOUND;
@@ -159,12 +158,12 @@ INTERNAL_FUNC int emdaemon_alarm_polling_cb(email_alarm_data_t *alarm_data, void
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_id_by_mailbox_type(account_id,EMAIL_MAILBOX_TYPE_INBOX, &mailbox_id, false, &err)) {
+ if (!emstorage_get_mailbox_id_by_mailbox_type(alarm_data->multi_user_name, account_id,EMAIL_MAILBOX_TYPE_INBOX, &mailbox_id, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
- if (!emdaemon_sync_header(account_id, mailbox_id, &handle, &err)) {
+ if (!emdaemon_sync_header(alarm_data->multi_user_name, account_id, mailbox_id, &handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_sync_header falied [%d]", err);
goto FINISH_OFF;
}
@@ -194,7 +193,7 @@ static int _emdaemon_get_polling_account_and_timeinterval(email_alarm_data_t *al
goto FINISH_OFF;
}
- account = emcore_get_account_reference(alarm_data->reference_id);
+ account = emcore_get_account_reference(alarm_data->multi_user_name, alarm_data->reference_id, false);
if (account == NULL) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]",err);
goto FINISH_OFF;
@@ -213,7 +212,7 @@ FINISH_OFF:
-static int _emdaemon_create_alarm_for_auto_polling(int input_account_id)
+static int _emdaemon_create_alarm_for_auto_polling(char *multi_user_name, int input_account_id)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d]", input_account_id);
int err = EMAIL_ERROR_NONE;
@@ -228,7 +227,7 @@ static int _emdaemon_create_alarm_for_auto_polling(int input_account_id)
time(&current_time);
- if ((err = emcore_calc_next_time_to_sync(input_account_id, current_time, &trigger_at_time)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_calc_next_time_to_sync(multi_user_name, input_account_id, current_time, &trigger_at_time)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
goto FINISH_OFF;
}
@@ -236,7 +235,7 @@ static int _emdaemon_create_alarm_for_auto_polling(int input_account_id)
if (trigger_at_time == 0) {
EM_DEBUG_LOG("trigger_at_time is 0. It means auto polling is disabled");
}
- else if ((err = emcore_add_alarm(trigger_at_time, EMAIL_ALARM_CLASS_AUTO_POLLING, input_account_id, emdaemon_alarm_polling_cb, NULL)) != EMAIL_ERROR_NONE) {
+ else if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_AUTO_POLLING, input_account_id, emdaemon_alarm_polling_cb, NULL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
goto FINISH_OFF;
}
diff --git a/email-daemon/email-daemon-emn.c b/email-daemon/email-daemon-emn.c
index 9e9831c..d6af25a 100755
--- a/email-daemon/email-daemon-emn.c
+++ b/email-daemon/email-daemon-emn.c
@@ -426,7 +426,7 @@ static int _get_emn_account(unsigned char *input_wbxml, int input_wbxml_length,
if(incoming_server_user_name && host_addr)
SNPRINTF((char*)email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", incoming_server_user_name, host_addr);
- if (!emdaemon_get_account_list(&accounts, &count, &err)) {
+ if (!emdaemon_get_account_list(NULL, &accounts, &count, &err)) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_DB_FAILURE");
err = EMAIL_ERROR_DB_FAILURE;
goto FINISH_OFF;
@@ -524,19 +524,19 @@ static int emdaemon_handle_emn_notification(unsigned char* wbxml_b64, int input_
}
if (account.incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && mailbox_name) {
- if (!emstorage_get_mailbox_by_name(account.account_id, -1, mailbox_name, &mailbox_tbl, false, &err)) {
+ if (!emstorage_get_mailbox_by_name(multi_user_name, account.account_id, -1, mailbox_name, &mailbox_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d", err);
goto FINISH_OFF;
}
}
else {
- if (!emstorage_get_mailbox_by_mailbox_type(account.account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl, false, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account.account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d", err);
goto FINISH_OFF;
}
}
- if (!emdaemon_sync_header(mailbox_tbl->account_id, mailbox_tbl->mailbox_id, &handle, &err)) {
+ if (!emdaemon_sync_header(multi_user_name, mailbox_tbl->account_id, mailbox_tbl->mailbox_id, &handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_sync_header failed [%d]", err);
goto FINISH_OFF;
}
diff --git a/email-daemon/email-daemon-etc.c b/email-daemon/email-daemon-etc.c
index ae44aba..63a626d 100755
--- a/email-daemon/email-daemon-etc.c
+++ b/email-daemon/email-daemon-etc.c
@@ -130,7 +130,7 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id,
else {
mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SEND_CANCELED;
- if(!emstorage_set_field_of_mails_with_integer_value(mail_tbl_data->account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_CANCELED, true, &err)) {
+ if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, mail_tbl_data->account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_CANCELED, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]",err);
goto FINISH_OFF;
}
@@ -174,6 +174,65 @@ FINISH_OFF:
return ret;
}
+INTERNAL_FUNC int emdaemon_search_mail_on_server(char *multi_user_name,
+ int input_account_id,
+ int input_mailbox_id,
+ email_search_filter_t *input_search_filter,
+ int input_search_filter_count,
+ unsigned int *output_handle,
+ int *err_code)
+{
+ EM_DEBUG_FUNC_BEGIN("input_account_id [%d], mailbox_id [%d], input_search_filter [%p], "
+ "input_search_filter_count [%d], output_handle [%p]",
+ input_account_id, input_mailbox_id, input_search_filter,
+ input_search_filter_count, output_handle);
+ int error = EMAIL_ERROR_NONE;
+ int ret = false;
+ email_event_t *event_data = NULL;
+
+ if (input_mailbox_id == 0 || input_account_id < 0) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ error = EMAIL_ERROR_INVALID_PARAM;
+ return false;
+ }
+
+ event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("Out of memory");
+ error = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ event_data->type = EMAIL_EVENT_SEARCH_ON_SERVER;
+ event_data->account_id = input_account_id;
+ event_data->event_param_data_1 = (void *)input_search_filter;
+ event_data->event_param_data_5 = input_search_filter_count;
+ event_data->event_param_data_4 = input_mailbox_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
+ if (!emcore_insert_event(event_data, (int *)output_handle, &error)) {
+ EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", error);
+ error = EMAIL_ERROR_NONE;
+ goto FINISH_OFF;
+ }
+
+ ret = true;
+
+FINISH_OFF:
+
+ if (ret == false && event_data) {
+ emcore_free_event(event_data);
+ free(event_data);
+ }
+
+ if (err_code != NULL)
+ *err_code = error;
+
+ EM_DEBUG_FUNC_END("error [%d]", error);
+ return ret;
+}
+
+#if 0
INTERNAL_FUNC int emdaemon_reschedule_sending_mail()
{
EM_DEBUG_FUNC_BEGIN();
@@ -215,21 +274,21 @@ INTERNAL_FUNC int emdaemon_reschedule_sending_mail()
filter_list[6].list_filter_item.operator_type = EMAIL_LIST_FILTER_OPERATOR_RIGHT_PARENTHESIS;
/* Get scheduled mail list */
- if( (err = emstorage_write_conditional_clause_for_getting_mail_list(filter_list, filter_rule_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
- if(!emstorage_query_mail_list(conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
+ if(!emstorage_query_mail_list(NULL, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", err);
goto FINISH_OFF;
}
/* Add alarm for scheduled mail */
for(i = 0; i < result_mail_count; i++) {
- if((err = emcore_schedule_sending_mail(result_mail_list[i].mail_id, result_mail_list[i].scheduled_sending_time)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_schedule_sending_mail(multi_user_name, result_mail_list[i].mail_id, result_mail_list[i].scheduled_sending_time)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_schedule_sending_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -242,16 +301,17 @@ FINISH_OFF:
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
+#endif
-INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code)
+INTERNAL_FUNC int emdaemon_clear_all_mail_data(char *multi_user_name, int* err_code)
{
EM_DEBUG_FUNC_BEGIN();
int ret = false;
int error = EMAIL_ERROR_NONE;
- if (emdaemon_initialize(&error)) {
- if (!emstorage_clear_mail_data(true, &error))
+ if (emdaemon_initialize(multi_user_name, &error)) {
+ if (!emstorage_clear_mail_data(multi_user_name, true, &error))
EM_DEBUG_EXCEPTION("emstorage_clear_mail_data failed [%d]", error);
}
else {
@@ -261,11 +321,11 @@ INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code)
return false;
}
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
ret = true;
- if (!emstorage_create_table(EMAIL_CREATE_DB_NORMAL, &error))
+ if (!emstorage_create_table(multi_user_name, EMAIL_CREATE_DB_NORMAL, &error))
EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error);
emdaemon_finalize(&error);
@@ -289,6 +349,7 @@ INTERNAL_FUNC int emdaemon_check_smack_rule(int app_sockfd, char *file_path)
char *app_label = NULL;
char *file_label = NULL;
char *real_file_path = NULL;
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
int ret = 0;
int result = false;
@@ -316,10 +377,10 @@ INTERNAL_FUNC int emdaemon_check_smack_rule(int app_sockfd, char *file_path)
result = false;
goto FINISH_OFF;
}
-
+
real_file_path = realpath(file_path, NULL);
if (!real_file_path) {
- EM_DEBUG_LOG("realpath failed");
+ EM_DEBUG_LOG("realpath failed [%d][%s]", errno, EM_STRERROR(errno_buf));
result = false;
goto FINISH_OFF;
}
@@ -368,16 +429,16 @@ INTERNAL_FUNC int emdaemon_set_smack_label(char *file_path, char *label)
return result;
}
-INTERNAL_FUNC int emdaemon_finalize_sync(int account_id, int total_mail_count, int unread_mail_count, int vip_total_mail_count, int vip_unread_mail_count, int input_from_eas, int *error)
+INTERNAL_FUNC int emdaemon_finalize_sync(char *multi_user_name, int account_id, int total_mail_count, int unread_mail_count, int vip_total_mail_count, int vip_unread_mail_count, int input_from_eas, int *error)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], total_mail_count [%d], unread_mail_count [%d], error [%p]", account_id, total_mail_count, unread_mail_count, error);
int err = EMAIL_ERROR_NONE, ret = true, result_sync_status = SYNC_STATUS_FINISHED;
int topmost = false;
- if ((err = emcore_update_sync_status_of_account(account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name, account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
- if (!emstorage_get_sync_status_of_account(account_id, &result_sync_status, &err))
+ if (!emstorage_get_sync_status_of_account(multi_user_name, account_id, &result_sync_status, &err))
EM_DEBUG_EXCEPTION("emstorage_get_sync_status_of_account failed [%d]", err);
/* Check the topmost of email app */
@@ -390,11 +451,11 @@ INTERNAL_FUNC int emdaemon_finalize_sync(int account_id, int total_mail_count, i
if (result_sync_status == SYNC_STATUS_SYNCING) {
if (topmost) {
EM_DEBUG_LOG("The email app is topmost");
- if (!emstorage_update_save_status(account_id, &err)) {
+ if (!emstorage_update_save_status(multi_user_name, account_id, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_save_status failed : [%d]", err);
}
} else {
- if ((err = emcore_add_notification(account_id, 0, unread_mail_count, vip_unread_mail_count, 0, EMAIL_ERROR_NONE, NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_add_notification(multi_user_name, account_id, 0, unread_mail_count, vip_unread_mail_count, 0, EMAIL_ERROR_NONE, NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_add_notification failed : [%d]", err);
}
} else*/ if (result_sync_status == SYNC_STATUS_HAVE_NEW_MAILS) {
@@ -402,9 +463,7 @@ INTERNAL_FUNC int emdaemon_finalize_sync(int account_id, int total_mail_count, i
EM_DEBUG_LOG("The email app is topmost");
} else {
- emcore_set_flash_noti();
-
- if ((err = emcore_add_notification(account_id, 0, unread_mail_count, vip_unread_mail_count, 1, EMAIL_ERROR_NONE, NOTIFICATION_DISPLAY_APP_ALL)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_add_notification(multi_user_name, account_id, 0, unread_mail_count, vip_unread_mail_count, 1, EMAIL_ERROR_NONE, NOTIFICATION_DISPLAY_APP_ALL)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_add_notification failed : [%d]", err);
#ifdef __FEATURE_BLOCKING_MODE__
@@ -412,7 +471,7 @@ INTERNAL_FUNC int emdaemon_finalize_sync(int account_id, int total_mail_count, i
#endif /* __FEATURE_BLOCKING_MODE__ */
- if ((err = emcore_update_sync_status_of_account(account_id, SET_TYPE_MINUS, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name, account_id, SET_TYPE_MINUS, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
}
diff --git a/email-daemon/email-daemon-event.c b/email-daemon/email-daemon-event.c
index 7256f90..5d78990 100755
--- a/email-daemon/email-daemon-event.c
+++ b/email-daemon/email-daemon-event.c
@@ -65,26 +65,27 @@ extern pthread_cond_t _auto_downalod_available_signal;
#endif
static void *worker_event_queue(void *arg);
-static int event_handler_EMAIL_EVENT_SYNC_HEADER(int input_account_id, int input_mailbox_id, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(email_account_t *account, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(email_account_t *input_account, int input_handle_to_be_published);
-static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id, email_account_t *new_account_info, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_SET_MAIL_SLOT_SIZE(int account_id, int mailbox_id, int new_slot_size, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED(int input_account_id, int input_mailbox_id);
-static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(int account_id, int mail_id, int option, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(int account_id, int mail_id, int attachment_no, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(int mail_ids[], int num, email_flags_field_type field_type, int value, int *error);
-static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(int account_id, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_UPDATE_MAIL(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas, int handle_to_be_published);
-static int event_handler_EMAIL_EVENT_SAVE_MAIL(int input_account_id, int input_mail_id, int input_handle_to_be_published);
-static int event_handler_EMAIL_EVENT_MOVE_MAIL(int account_id, int *mail_ids, int mail_id_count, int dest_mailbox_id, int src_mailbox_id, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_DELETE_MAILBOX(int mailbox_id, int on_server, int recursive, int handle_to_be_published);
-static int event_handler_EMAIL_EVENT_CREATE_MAILBOX(email_mailbox_t *input_new_mailbox, int on_server, int handle_to_be_published);
-static int event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(int mail_id, int event_handle, int *error);
-static int event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(int input_account_id, int input_mailbox_id, int input_from_server, int *error);
-static int event_handler_EMAIL_EVENT_DELETE_MAIL(int account_id, int *mail_id_list, int mail_id_count, int from_server, int *error);
-static int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(int account_id, char *maibox_name, int handle_to_be_published, int *error);
-static int event_handler_EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER(int input_account_id, int input_mailbox_id, char *input_old_mailbox_path, char *input_new_mailbox_path, char *input_new_mailbox_alias, int handle_to_be_published);
+static int event_handler_EMAIL_EVENT_SYNC_HEADER(char *multi_user_name, int input_account_id, int input_mailbox_id, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(char *multi_user_name, email_account_t *account, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(char *multi_user_name, email_account_t *input_account, int input_handle_to_be_published);
+static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(char *multi_user_name, int account_id, email_account_t *new_account_info, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_SET_MAIL_SLOT_SIZE(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED(char *multi_user_name, int input_account_id, int input_mailbox_id);
+static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(char *multi_user_name, int account_id, int mail_id, int option, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(char *multi_user_name, int account_id, int mail_id, int attachment_no, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(char *multi_user_name, int mail_ids[], int num, email_flags_field_type field_type, int value, int *error);
+static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(char *multi_user_name, int account_id, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_UPDATE_MAIL(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas, int handle_to_be_published);
+static int event_handler_EMAIL_EVENT_SAVE_MAIL(char *multi_user_name, int input_account_id, int input_mail_id, int input_handle_to_be_published);
+static int event_handler_EMAIL_EVENT_MOVE_MAIL(char *multi_user_name, int account_id, int *mail_ids, int mail_id_count, int dest_mailbox_id, int src_mailbox_id, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_DELETE_MAILBOX(char *multi_user_name, int mailbox_id, int on_server, int recursive, int handle_to_be_published);
+static int event_handler_EMAIL_EVENT_CREATE_MAILBOX(char *multi_user_name, email_mailbox_t *input_new_mailbox, int on_server, int handle_to_be_published);
+static int event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(char *multi_user_name, int mail_id, int event_handle, int *error);
+static int event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(char *multi_user_name, int input_account_id, int input_mailbox_id, int input_from_server, int *error);
+static int event_handler_EMAIL_EVENT_DELETE_MAIL(char *multi_user_name, int account_id, int *mail_id_list, int mail_id_count, int from_server, int *error);
+static int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(char *multi_user_name, int account_id, char *maibox_name, int handle_to_be_published, int *error);
+static int event_handler_EMAIL_EVENT_SEARCH_ON_SERVER(char *multi_user_name, int account_id, int mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, int handle_to_be_published);
+static int event_handler_EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER(char *multi_user_name, int input_account_id, int input_mailbox_id, char *input_old_mailbox_path, char *input_new_mailbox_path, char *input_new_mailbox_alias, int handle_to_be_published);
static void* worker_send_event_queue(void *arg);
@@ -278,7 +279,7 @@ static void* worker_event_queue(void *arg)
int pbd_thd_state = 0;
int send_event_que_state = 0;
- if (!emstorage_open(&err)) {
+ if (!emstorage_open(NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_open falied [%d]", err);
return false;
}
@@ -362,7 +363,7 @@ static void* worker_event_queue(void *arg)
if (event_data->account_id > 0) {
- if (!emstorage_get_account_by_id(event_data->account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl, false, &err)) {
+ if (!emstorage_get_account_by_id(event_data->multi_user_name, event_data->account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id [%d]", err);
}
}
@@ -373,109 +374,117 @@ static void* worker_event_queue(void *arg)
if (!account_tbl || account_tbl->sync_disabled == 0) {
switch (event_data->type) {
case EMAIL_EVENT_SYNC_IMAP_MAILBOX: /* get imap mailbox list */
- if (!emcore_sync_mailbox_list(event_data->account_id, event_data->event_param_data_3, handle_to_be_published, &err))
+ if (!emcore_sync_mailbox_list(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_3, handle_to_be_published, &err))
EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list failed [%d]", err);
break;
case EMAIL_EVENT_SYNC_HEADER: /* synchronize mail header */
if (is_storage_full == false)
- event_handler_EMAIL_EVENT_SYNC_HEADER(event_data->account_id, event_data->event_param_data_5, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_SYNC_HEADER(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_5, handle_to_be_published, &err);
break;
case EMAIL_EVENT_SYNC_HEADER_OMA: /* synchronize mail header for OMA */
if (is_storage_full == false)
- event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(event_data->account_id, event_data->event_param_data_1, handle_to_be_published, &err);
+ event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_1, handle_to_be_published, &err);
break;
case EMAIL_EVENT_DOWNLOAD_BODY: /* download mail body */
if (is_storage_full == false)
- event_handler_EMAIL_EVENT_DOWNLOAD_BODY(event_data->account_id, event_data->event_param_data_4, event_data->event_param_data_5, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_DOWNLOAD_BODY(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_4, event_data->event_param_data_5, handle_to_be_published, &err);
break;
case EMAIL_EVENT_DOWNLOAD_ATTACHMENT: /* download attachment */
if (is_storage_full == false)
- event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(event_data->account_id, (int)event_data->event_param_data_4, event_data->event_param_data_5, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(event_data->multi_user_name, event_data->account_id, (int)event_data->event_param_data_4, event_data->event_param_data_5, handle_to_be_published, &err);
break;
case EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER: /* Sync flags field */
- event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER((int*)event_data->event_param_data_3, event_data->event_param_data_4 , event_data->event_param_data_5, event_data->event_param_data_6, &err);
+ event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(event_data->multi_user_name, (int*)event_data->event_param_data_3, event_data->event_param_data_4 , event_data->event_param_data_5, event_data->event_param_data_6, &err);
break;
case EMAIL_EVENT_DELETE_MAIL: /* delete mails */
- event_handler_EMAIL_EVENT_DELETE_MAIL(event_data->account_id, (int*)event_data->event_param_data_3, event_data->event_param_data_4, event_data->event_param_data_5, &err);
+ event_handler_EMAIL_EVENT_DELETE_MAIL(event_data->multi_user_name, event_data->account_id, (int*)event_data->event_param_data_3, event_data->event_param_data_4, event_data->event_param_data_5, &err);
break;
case EMAIL_EVENT_DELETE_MAIL_ALL: /* delete all mails */
- event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(event_data->account_id, event_data->event_param_data_4, (int)event_data->event_param_data_5, &err);
+ event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_4, (int)event_data->event_param_data_5, &err);
break;
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
case EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER:
- event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER((int)event_data->event_param_data_4, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(event_data->multi_user_name, (int)event_data->event_param_data_4, handle_to_be_published, &err);
break;
#endif
case EMAIL_EVENT_CREATE_MAILBOX:
- err = event_handler_EMAIL_EVENT_CREATE_MAILBOX((email_mailbox_t *)event_data->event_param_data_1, event_data->event_param_data_4, handle_to_be_published);
+ err = event_handler_EMAIL_EVENT_CREATE_MAILBOX(event_data->multi_user_name, (email_mailbox_t *)event_data->event_param_data_1, event_data->event_param_data_4, handle_to_be_published);
break;
case EMAIL_EVENT_DELETE_MAILBOX:
- err = event_handler_EMAIL_EVENT_DELETE_MAILBOX(event_data->event_param_data_4, event_data->event_param_data_5, event_data->event_param_data_6,handle_to_be_published);
+ err = event_handler_EMAIL_EVENT_DELETE_MAILBOX(event_data->multi_user_name, event_data->event_param_data_4, event_data->event_param_data_5, event_data->event_param_data_6,handle_to_be_published);
break;
case EMAIL_EVENT_SAVE_MAIL:
- err = event_handler_EMAIL_EVENT_SAVE_MAIL(event_data->account_id, event_data->event_param_data_4, handle_to_be_published);
+ err = event_handler_EMAIL_EVENT_SAVE_MAIL(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_4, handle_to_be_published);
break;
case EMAIL_EVENT_MOVE_MAIL:
- event_handler_EMAIL_EVENT_MOVE_MAIL(event_data->account_id, (int *)event_data->event_param_data_3, event_data->event_param_data_4, event_data->event_param_data_5, event_data->event_param_data_8, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_MOVE_MAIL(event_data->multi_user_name, event_data->account_id, (int *)event_data->event_param_data_3, event_data->event_param_data_4, event_data->event_param_data_5, event_data->event_param_data_8, handle_to_be_published, &err);
break;
case EMAIL_EVENT_VALIDATE_ACCOUNT:
- event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(event_data->account_id, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(event_data->multi_user_name, event_data->account_id, handle_to_be_published, &err);
break;
case EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT: {
email_account_t *account = (email_account_t *)event_data->event_param_data_1;
- event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(account, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(event_data->multi_user_name, account, handle_to_be_published, &err);
}
break;
case EMAIL_EVENT_VALIDATE_ACCOUNT_EX: {
email_account_t *account = (email_account_t *)event_data->event_param_data_1;
- err = event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(account, handle_to_be_published);
+ err = event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(event_data->multi_user_name, account, handle_to_be_published);
}
break;
case EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT: {
email_account_t *account = (email_account_t *)event_data->event_param_data_1;
- event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(event_data->account_id, account, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(event_data->multi_user_name,
+ event_data->account_id,
+ account,
+ handle_to_be_published,
+ &err);
}
break;
case EMAIL_EVENT_UPDATE_MAIL:
- event_handler_EMAIL_EVENT_UPDATE_MAIL((email_mail_data_t*)event_data->event_param_data_1, (email_attachment_data_t*)event_data->event_param_data_2, event_data->event_param_data_4, (email_meeting_request_t*)event_data->event_param_data_3, event_data->event_param_data_5, handle_to_be_published);
+ event_handler_EMAIL_EVENT_UPDATE_MAIL(event_data->multi_user_name, (email_mail_data_t*)event_data->event_param_data_1, (email_attachment_data_t*)event_data->event_param_data_2, event_data->event_param_data_4, (email_meeting_request_t*)event_data->event_param_data_3, event_data->event_param_data_5, handle_to_be_published);
break;
case EMAIL_EVENT_SET_MAIL_SLOT_SIZE:
- event_handler_EMAIL_EVENT_SET_MAIL_SLOT_SIZE(event_data->account_id, event_data->event_param_data_4, event_data->event_param_data_5, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_SET_MAIL_SLOT_SIZE(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_4, event_data->event_param_data_5, handle_to_be_published, &err);
break;
case EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED:
- err = event_handler_EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED(event_data->account_id, event_data->event_param_data_4);
+ err = event_handler_EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_4);
break;
#ifdef __FEATURE_LOCAL_ACTIVITY__
case EMAIL_EVENT_LOCAL_ACTIVITY:
- event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(event_data->account_id, handle_to_be_published, &err);
+ event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(event_data->multi_user_name, event_data->account_id, handle_to_be_published, &err);
break;
#endif /* __FEATURE_LOCAL_ACTIVITY__*/
+ case EMAIL_EVENT_SEARCH_ON_SERVER:
+ err = event_handler_EMAIL_EVENT_SEARCH_ON_SERVER(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_4, (email_search_filter_t *)event_data->event_param_data_1, event_data->event_param_data_5, handle_to_be_published);
+ break;
+
case EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER:
- err = event_handler_EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER(event_data->account_id, event_data->event_param_data_4, (char*)event_data->event_param_data_1, (char*)event_data->event_param_data_2, (char*)event_data->event_param_data_3, handle_to_be_published);
+ err = event_handler_EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_4, (char*)event_data->event_param_data_1, (char*)event_data->event_param_data_2, (char*)event_data->event_param_data_3, handle_to_be_published);
break;
case EMAIL_EVENT_QUERY_SMTP_MAIL_SIZE_LIMIT:
- if (!emcore_query_mail_size_limit(event_data->account_id, handle_to_be_published, &err))
+ if (!emcore_query_mail_size_limit(event_data->multi_user_name, event_data->account_id, handle_to_be_published, &err))
EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list failed [%d]", err);
break;
@@ -484,48 +493,53 @@ static void* worker_event_queue(void *arg)
}
}
- if ((event_data->type == EMAIL_EVENT_SYNC_HEADER || event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX) && (err != EMAIL_ERROR_NONE)) {
+ if ((event_data->type == EMAIL_EVENT_SYNC_HEADER || event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX) &&
+ (err != EMAIL_ERROR_NONE)) {
+ EM_DEBUG_LOG("retry syncing");
+ if (event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX && err == EMAIL_ERROR_INVALID_ACCOUNT) {
+ EM_DEBUG_LOG("Unsupported account");
+ goto FINISH_OFF;
+ }
+
/* for the retry syncing */
if (sync_failed_event_data) {
emcore_free_event(sync_failed_event_data);
EM_SAFE_FREE(sync_failed_event_data);
- sync_failed_event_data = NULL;
}
sync_failed_event_data = em_malloc(sizeof(email_event_t));
if (sync_failed_event_data == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed");
err = EMAIL_ERROR_OUT_OF_MEMORY;
- continue;
+ goto FINISH_OFF;
}
- if (event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX) {
+ if (event_data->type == EMAIL_EVENT_SYNC_IMAP_MAILBOX && sync_failed_event_data) {
sync_failed_event_data->type = EMAIL_EVENT_SYNC_IMAP_MAILBOX;
sync_failed_event_data->account_id = event_data->account_id;
sync_failed_event_data->status = EMAIL_EVENT_STATUS_WAIT;
sync_failed_event_data->event_param_data_3 = EM_SAFE_STRDUP(event_data->event_param_data_3);
+ sync_failed_event_data->multi_user_name = EM_SAFE_STRDUP(event_data->multi_user_name);
}
- if (event_data->type == EMAIL_EVENT_SYNC_HEADER) {
+ if (event_data->type == EMAIL_EVENT_SYNC_HEADER && sync_failed_event_data) {
sync_failed_event_data->type = EMAIL_EVENT_SYNC_HEADER;
sync_failed_event_data->account_id = event_data->account_id;
sync_failed_event_data->status = EMAIL_EVENT_STATUS_WAIT;
sync_failed_event_data->event_param_data_5 = event_data->event_param_data_5;
sync_failed_event_data->event_param_data_4 = event_data->event_param_data_4;
+ sync_failed_event_data->multi_user_name = EM_SAFE_STRDUP(event_data->multi_user_name);
}
}
-
- /* free internals in event */
- emcore_free_event(event_data); /*detected by valgrind*/
+FINISH_OFF:
+ if (!emcore_notify_response_to_api(event_data->type, handle_to_be_published, err))
+ EM_DEBUG_EXCEPTION("emcore_notify_response_to_api failed");
if (account_tbl) {
emstorage_free_account(&account_tbl, 1, NULL);
account_tbl = NULL;
}
- if (!emcore_notify_response_to_api(event_data->type, handle_to_be_published, err))
- EM_DEBUG_EXCEPTION("emcore_notify_response_to_api failed");
-
/* free event itself */
ENTER_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
started_event = g_queue_pop_head(g_event_que);
@@ -534,10 +548,11 @@ static void* worker_event_queue(void *arg)
EM_DEBUG_EXCEPTION("Failed to g_queue_pop_head");
}
else {
+ /* freed event_data : event_data is started event */
emcore_return_handle(started_event->handle);
+ emcore_free_event(started_event); /*detected by valgrind*/
EM_SAFE_FREE(started_event);
}
- em_flush_memory();
}
}
@@ -549,7 +564,7 @@ static void* worker_event_queue(void *arg)
return SUCCESS;
}
-static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int input_mailbox_id,
+static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int input_account_id, int input_mailbox_id,
int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_id [%d], handle_to_be_published [%d], error[%p]",
@@ -577,8 +592,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
email_account_t *ref_account = NULL;
int sync_disabled = 0;
- ref_account = emcore_get_account_reference(input_account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, input_account_id, false);
if (ref_account) {
sync_disabled = ref_account->sync_disabled;
emcore_free_account(ref_account);
@@ -593,7 +607,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl_target) || !mailbox_tbl_target) {
+ if (!emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl_target) || !mailbox_tbl_target) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -615,11 +629,15 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
if (sync_type != EMAIL_SYNC_ALL_MAILBOX) { /* Sync only particular mailbox */
EM_DEBUG_LOG_SEC ("sync start: account_id [%d] alias [%s]", input_account_id, mailbox_tbl_target->alias);
- if ((err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name,
+ input_account_id,
+ SET_TYPE_UNION,
+ SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
- if (!emcore_sync_header (mailbox_tbl_target, (void**) &stream,
- &uid_list, &mail_count, &unread, &vip_mail_count, &vip_unread, 1, handle_to_be_published, &err)) {
+ if (!emcore_sync_header (multi_user_name, mailbox_tbl_target, (void**) &stream,
+ &uid_list, &mail_count, &unread, &vip_mail_count,
+ &vip_unread, 1, handle_to_be_published, &err)) {
EM_DEBUG_EXCEPTION("emcore_sync_header failed [%d]", err);
if (!emcore_notify_network_event(NOTI_DOWNLOAD_FAIL, mailbox_tbl_target->account_id, mailbox_id_param_string, handle_to_be_published, err))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed >>>> ");
@@ -637,19 +655,19 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
total_mail += mail_count;
vip_total_mail += vip_mail_count;
- if (total_unread > 0 && (emcore_update_sync_status_of_account(input_account_id, SET_TYPE_UNION, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE) {
+ if (total_unread > 0 && (emcore_update_sync_status_of_account(multi_user_name, input_account_id, SET_TYPE_UNION, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed");
} else {
- if ((err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name, input_account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
}
- if (!emstorage_get_account_by_id(input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl_array, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl_array, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [ %d ] ", err);
}
if (account_tbl_array && account_tbl_array->auto_download_size == 0) {
- if (!emdaemon_finalize_sync(input_account_id, 0, 0, 0, 0, true, NULL))
+ if (!emdaemon_finalize_sync(multi_user_name, input_account_id, 0, 0, 0, 0, true, NULL))
EM_DEBUG_EXCEPTION("emdaemon_finalize_sync failed");
}
@@ -657,17 +675,16 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
emstorage_free_account(&account_tbl_array, 1, NULL);
if (mailbox_tbl_target->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
}
else /* All Folder */ {
EM_DEBUG_LOG ("sync start for all mailbox: account_id [%d]", input_account_id);
/* Sync of all mailbox */
if (input_account_id == ALL_ACCOUNT) {
- if ((err = emcore_update_sync_status_of_account(ALL_ACCOUNT, SET_TYPE_SET, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name, ALL_ACCOUNT, SET_TYPE_UNION, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
-
- if (!emstorage_get_account_list(&account_count, &account_tbl_array , true, false, &err)) {
+ if (!emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_array , true, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [ %d ] ", err);
if (!emcore_notify_network_event(NOTI_DOWNLOAD_FAIL, input_account_id, NULL, handle_to_be_published, err))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_FAIL] Failed >>>> ");
@@ -675,10 +692,10 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
}
}
else {
- if ((err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name, input_account_id, SET_TYPE_UNION, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
- if (!emstorage_get_account_by_id(input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl_array, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl_array, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [ %d ] ", err);
if (!emcore_notify_network_event(NOTI_DOWNLOAD_FAIL, input_account_id, input_mailbox_id_str, handle_to_be_published, err))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_FAIL] Failed >>>> ");
@@ -698,7 +715,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
continue;
}
/* folder sync is also necessary */
- if (!emstorage_get_mailbox_list (account_tbl_array[account_index].account_id, 0,
+ if (!emstorage_get_mailbox_list (multi_user_name, account_tbl_array[account_index].account_id, 0,
EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &mailbox_count, &mailbox_tbl_list, true, &err) ||
mailbox_count <= 0) {
EM_DEBUG_EXCEPTION ("emstorage_get_mailbox error [%d]", err);
@@ -715,7 +732,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
if (account_tbl_array[account_index].incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
memset(mailbox_id_param_string, 0, 10);
SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl_list[0].mailbox_id);
- if (!emcore_connect_to_remote_mailbox (account_tbl_array[account_index].account_id,
+ if (!emcore_connect_to_remote_mailbox (multi_user_name, account_tbl_array[account_index].account_id,
mailbox_tbl_list[0].mailbox_id, (void **)&stream, &err)) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox error [%d]", err);
if (err == EMAIL_ERROR_LOGIN_FAILURE)
@@ -744,17 +761,19 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
else if (!mailbox_tbl_list[counter].local_yn) {
EM_DEBUG_LOG_SEC("[%s] Syncing...", mailbox_tbl_list[counter].mailbox_name);
#ifdef __FEATURE_KEEP_CONNECTION__
- if (!emcore_sync_header ((mailbox_tbl_list + counter),
- (void **)&stream,
- &uid_list,
- &mail_count,
- &unread, &vip_mail_count, &vip_unread, 1, handle_to_be_published, &err))
+ if (!emcore_sync_header (multi_user_name,
+ (mailbox_tbl_list + counter),
+ (void **)&stream,
+ &uid_list,
+ &mail_count,
+ &unread, &vip_mail_count, &vip_unread, 1, handle_to_be_published, &err))
#else /* __FEATURE_KEEP_CONNECTION__ */
- if (!emcore_sync_header ((mailbox_tbl_list + counter),
- (void **)&stream,
- &uid_list,
- &mail_count,
- &unread, &vip_mail_count, &vip_unread, 1, handle_to_be_published, &err))
+ if (!emcore_sync_header (multi_user_name,
+ (mailbox_tbl_list + counter),
+ (void **)&stream,
+ &uid_list,
+ &mail_count,
+ &unread, &vip_mail_count, &vip_unread, 1, handle_to_be_published, &err))
#endif /* __FEATURE_KEEP_CONNECTION__ */
{
EM_DEBUG_EXCEPTION_SEC ("emcore_sync_header for %s(mailbox_id = %d) failed [%d]",
@@ -784,7 +803,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
vip_total_mail += vip_mail_count;
if (mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
}
@@ -794,15 +813,15 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (int input_account_id, int inpu
if ((err == EMAIL_ERROR_NONE) && !emcore_notify_network_event(NOTI_DOWNLOAD_FINISH, account_tbl_array[account_index].account_id, NULL, handle_to_be_published, 0))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_FINISH] Failed >>>> ");
- if ((total_unread > 0) && (emcore_update_sync_status_of_account(account_tbl_array[account_index].account_id, SET_TYPE_UNION, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE) {
+ if ((total_unread > 0) && (emcore_update_sync_status_of_account(multi_user_name, account_tbl_array[account_index].account_id, SET_TYPE_UNION, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed");
} else {
- if ((err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_update_sync_status_of_account(multi_user_name, input_account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
}
if (account_tbl_array[account_index].auto_download_size == 0) {
- if (!emdaemon_finalize_sync(account_tbl_array[account_index].account_id, 0, 0, 0, 0, true, NULL))
+ if (!emdaemon_finalize_sync(multi_user_name, account_tbl_array[account_index].account_id, 0, 0, 0, 0, true, NULL))
EM_DEBUG_EXCEPTION("emdaemon_finalize_sync failed");
}
@@ -842,7 +861,7 @@ FINISH_OFF:
return ret;
}
-static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(email_account_t *account, int handle_to_be_published, int *error)
+static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(char *multi_user_name, email_account_t *account, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN("account [%p]", account);
int err, ret = false;
@@ -866,7 +885,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(email_account_t
else {
EM_DEBUG_LOG_SEC("incoming_server_address : %s", account->incoming_server_address);
- if (!emcore_validate_account_with_account_info(account, EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT, &imap_cap_string, handle_to_be_published, &err)) {
+ if (!emcore_validate_account_with_account_info(multi_user_name, account, EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT, &imap_cap_string, handle_to_be_published, &err)) {
emcore_delete_account_from_unvalidated_account_list(account->account_id);
EM_DEBUG_EXCEPTION("emcore_validate_account_with_account_info failed err : %d", err);
if (err == EMAIL_ERROR_CANCELLED) {
@@ -881,19 +900,18 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(email_account_t
else {
emcore_delete_account_from_unvalidated_account_list(account->account_id);
- if (emcore_create_account(account, false, &err) == false) {
+ if (emcore_create_account(multi_user_name, account, false, &err) == false) {
EM_DEBUG_EXCEPTION(" emdaemon_create_account failed - %d", err);
goto FINISH_OFF;
}
- emcore_init_account_reference();
EM_DEBUG_LOG("incoming_server_type [%d]", account->incoming_server_type);
if ((EMAIL_SERVER_TYPE_IMAP4 == account->incoming_server_type)) {
- if (!emcore_sync_mailbox_list(account->account_id, "", handle_to_be_published, &err)) {
+ if (!emcore_sync_mailbox_list(multi_user_name, account->account_id, "", handle_to_be_published, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mailbox_list_to_be_sync failed [%d]", err);
/* delete account whose mailbox couldn't be obtained from server */
- emcore_delete_account(account->account_id, false, NULL);
+ emcore_delete_account(multi_user_name, account->account_id, false, NULL);
goto FINISH_OFF;
}
}
@@ -921,7 +939,7 @@ FINISH_OFF:
return ret;
}
-static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(email_account_t *input_account, int input_handle_to_be_published)
+static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(char *multi_user_name, email_account_t *input_account, int input_handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN("input_account [%p]", input_account);
int err = EMAIL_ERROR_NONE;
@@ -945,7 +963,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(email_account_t *input_
else {
EM_DEBUG_LOG_SEC("incoming_server_address : %s", input_account->incoming_server_address);
- if (!emcore_validate_account_with_account_info(input_account, EMAIL_EVENT_VALIDATE_ACCOUNT_EX, &server_capability_string, input_handle_to_be_published, &err)) {
+ if (!emcore_validate_account_with_account_info(multi_user_name, input_account, EMAIL_EVENT_VALIDATE_ACCOUNT_EX, &server_capability_string, input_handle_to_be_published, &err)) {
emcore_delete_account_from_unvalidated_account_list(input_account->account_id);
EM_DEBUG_EXCEPTION("emcore_validate_account_with_account_info failed err : %d", err);
@@ -980,7 +998,7 @@ FINISH_OFF:
return err;
}
-static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id, email_account_t *new_account_info, int handle_to_be_published, int *error)
+static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(char *multi_user_name, int account_id, email_account_t *new_account_info, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], new_account_info [%p]", account_id, new_account_info);
int err, ret = false;
@@ -1005,7 +1023,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id,
EM_DEBUG_LOG_SEC("incoming_server_address: (%s)", new_account_info->incoming_server_address);
/* If the password fields are empty, fill the fields with password of old information*/
- if((old_account_info = emcore_get_account_reference(account_id)) == NULL) {
+ if((old_account_info = emcore_get_account_reference(multi_user_name, account_id, true)) == NULL) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed ");
goto FINISH_OFF;
}
@@ -1048,7 +1066,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id,
goto FINISH_OFF;
}
- if (!emcore_validate_account_with_account_info(duplicated_account_info, EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT, &imap_cap_string, handle_to_be_published, &err)) {
+ if (!emcore_validate_account_with_account_info(multi_user_name, duplicated_account_info, EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT, &imap_cap_string, handle_to_be_published, &err)) {
EM_DEBUG_EXCEPTION("emcore_validate_account_with_account_info() failed err : %d", err);
if (err == EMAIL_ERROR_CANCELLED) {
EM_DEBUG_EXCEPTION(" notify : NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL ");
@@ -1061,7 +1079,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id,
}
}
else {
- if (!emstorage_get_account_by_id(account_id, WITHOUT_OPTION, &old_account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, WITHOUT_OPTION, &old_account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
/* goto FINISH_OFF; */
}
@@ -1076,8 +1094,8 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(int account_id,
em_convert_account_to_account_tbl(duplicated_account_info, new_account_tbl);
- if (emstorage_update_account(account_id, new_account_tbl, true, &err)) {
- emcore_init_account_reference();
+ if (!emstorage_update_account(multi_user_name, account_id, new_account_tbl, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_update_account failed : [%d]", err);
}
EM_DEBUG_LOG("validating and updating an account are succeeded for account id [%d], err [%d]", duplicated_account_info->account_id, err);
@@ -1123,27 +1141,27 @@ FINISH_OFF:
return ret;
}
-static int event_handler_EMAIL_EVENT_SET_MAIL_SLOT_SIZE(int account_id, int mailbox_id, int new_slot_size, int handle_to_be_published, int *error)
+static int event_handler_EMAIL_EVENT_SET_MAIL_SLOT_SIZE(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN();
- emcore_set_mail_slot_size(account_id, mailbox_id, new_slot_size, error);
+ emcore_set_mail_slot_size(multi_user_name, account_id, mailbox_id, new_slot_size, error);
EM_DEBUG_FUNC_END();
return true;
}
-static int event_handler_EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED(int input_account_id, int input_mailbox_id)
+static int event_handler_EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED(char *multi_user_name, int input_account_id, int input_mailbox_id)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_id [%d]", input_account_id, input_mailbox_id);
int err = EMAIL_ERROR_NONE;
- if ( (err = emcore_expunge_mails_deleted_flagged_from_remote_server(input_account_id, input_mailbox_id)) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_expunge_mails_deleted_flagged_from_remote_server(multi_user_name, input_account_id, input_mailbox_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_expunge_mails_deleted_flagged_from_remote_server failed [%d]", err);
goto FINISH_OFF;
}
- if ( (err = emcore_expunge_mails_deleted_flagged_from_local_storage(input_mailbox_id)) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_expunge_mails_deleted_flagged_from_local_storage(multi_user_name, input_mailbox_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_expunge_mails_deleted_flagged_from_local_storage failed [%d]", err);
goto FINISH_OFF;
}
@@ -1155,7 +1173,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_LOCAL_ACTIVITY__
-static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(int account_id, int event,handle, int *error)
+static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int account_id, int event,handle, int *error)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1170,7 +1188,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(int account_id, int event,ha
if (!emnetwork_check_network_status(&err))
EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
else {
- if (false == emstorage_get_activity_id_list(account_id, &activity_id_list, &activity_id_count, ACTIVITY_DELETEMAIL, ACTIVITY_COPYMAIL, true, &err)) {
+ if (false == emstorage_get_activity_id_list(multi_user_name, account_id, &activity_id_list, &activity_id_count, ACTIVITY_DELETEMAIL, ACTIVITY_COPYMAIL, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_activity_id_list failed [%d]", err);
}
else {
@@ -1181,7 +1199,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(int account_id, int event,ha
EM_DEBUG_LOG("Found local activity type - %d", local_activity[0].activity_type);
switch (local_activity[0].activity_type) {
case ACTIVITY_MODIFYFLAG: {
- if (emcore_sync_flag_with_server(local_activity[0].mail_id , &err)) {
+ if (emcore_sync_flag_with_server(multi_user_name, local_activity[0].mail_id , &err)) {
if (!emcore_delete_activity(&local_activity[0], &err))
EM_DEBUG_EXCEPTION(">>>>>>Local Activity [ACTIVITY_MODIFYFLAG] [%d] ", err);
}
@@ -1217,19 +1235,20 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(int account_id, int event,ha
switch (local_activity[k-1].activity_type) {
case ACTIVITY_DELETEMAIL: {
- if (!emcore_delete_mail(local_activity[k-1].account_id,
- mail_id_list,
- j,
- EMAIL_DELETE_LOCAL_AND_SERVER,
- EMAIL_DELETED_BY_COMMAND,
- false,
- &err))
+ if (!emcore_delete_mail(multi_user_name,
+ local_activity[k-1].account_id,
+ mail_id_list,
+ j,
+ EMAIL_DELETE_LOCAL_AND_SERVER,
+ EMAIL_DELETED_BY_COMMAND,
+ false,
+ &err))
EM_DEBUG_LOG("\t emcore_delete_mail failed - %d", err);
}
break;
case ACTIVITY_MOVEMAIL: {
- if (!emcore_move_mail_on_server_ex(local_activity[k-1].account_id ,
+ if (!emcore_move_mail_on_server_ex(multi_user_name, local_activity[k-1].account_id ,
local_activity[k-1].src_mbox,
mail_id_list,
j,
@@ -1240,7 +1259,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(int account_id, int event,ha
break;
case ACTIVITY_MODIFYSEENFLAG: {
int seen_flag = atoi(local_activity[0].src_mbox);
- if (!emcore_sync_seen_flag_with_server_ex(mail_id_list, j , seen_flag , &err)) /* local_activity[0].src_mbox points to the seen flag */
+ if (!emcore_sync_seen_flag_with_server_ex(multi_user_name, mail_id_list, j , seen_flag , &err)) /* local_activity[0].src_mbox points to the seen flag */
EM_DEBUG_EXCEPTION("\t emcore_sync_seen_flag_with_server_ex failed - %d", err);
}
break;
@@ -1282,7 +1301,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(int account_id, int event,ha
}
#endif /* __FEATURE_LOCAL_ACTIVITY__ */
-static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(int account_id, int mail_id, int option, int handle_to_be_published, int *error)
+static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(char *multi_user_name, int account_id, int mail_id, int option, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1297,18 +1316,17 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(int account_id, int mail_id,
emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, handle_to_be_published, err);
} else {
-#ifdef __FEATURE_USE_GMIME__
emstorage_mail_tbl_t *mail = NULL;
MAILSTREAM *tmp_stream = NULL;
- if (!emstorage_get_mail_by_id (mail_id, &mail, true, &err) || !mail) {
+ if (!emstorage_get_mail_by_id (multi_user_name, mail_id, &mail, true, &err) || !mail) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, handle_to_be_published, err);
goto FINISH_OFF;
}
- if (!emcore_connect_to_remote_mailbox(account_id, mail->mailbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
+ if (!emcore_connect_to_remote_mailbox(multi_user_name, account_id, mail->mailbox_id, (void **)&tmp_stream, &err) || !tmp_stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
if(err == EMAIL_ERROR_NO_SUCH_HOST)
err = EMAIL_ERROR_CONNECTION_FAILURE;
@@ -1321,7 +1339,7 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(int account_id, int mail_id,
goto FINISH_OFF;
}
- if (!emcore_gmime_download_body_sections(tmp_stream, mailbox.account_id, mail_id,
+ if (!emcore_gmime_download_body_sections(multi_user_name, tmp_stream, mailbox.account_id, mail_id,
option & 0x01, NO_LIMITATION, handle_to_be_published, 1, 0, &err))
EM_DEBUG_EXCEPTION("emcore_gmime_download_body_sections failed - %d", err);
@@ -1331,19 +1349,6 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(int account_id, int mail_id,
if (mail)
emstorage_free_mail(&mail, 1, NULL);
-
-#else
- if (!emcore_download_body_multi_sections_bulk(NULL,
- mailbox.account_id,
- mail_id,
- option >> 1, /*0: silent, 1: verbose */
- option & 0x01, /*0: without attachments, 1: with attachments */
- NO_LIMITATION,
- handle_to_be_published,
- 1, /* cancel enabled */
- &err))
- EM_DEBUG_EXCEPTION("emcore_download_body_multi_sections_bulk failed - %d", err);
-#endif
}
FINISH_OFF:
@@ -1355,7 +1360,7 @@ FINISH_OFF:
return true;
}
-static int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(int account_id, int mail_id, int attachment_no, int handle_to_be_published, int *error)
+static int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(char *multi_user_name, int account_id, int mail_id, int attachment_no, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1371,17 +1376,11 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(int account_id, int mai
#ifdef __ATTACHMENT_OPTI__
if (!emcore_download_attachment_bulk(account_id, mail_id, attachment_no, handle_to_be_published, &err))
- EM_DEBUG_EXCEPTION("\t emcore_download_attachment failed [%d]", err);
+ EM_DEBUG_EXCEPTION("\t emcore_download_attachment_bulk failed [%d]", err);
#else
-#ifdef __FEATURE_USE_GMIME__
- if (!emcore_gmime_download_attachment(mail_id, attachment_no, 1, handle_to_be_published, 0, &err))
+ if (!emcore_gmime_download_attachment(multi_user_name, mail_id, attachment_no, 1, handle_to_be_published, 0, &err))
EM_DEBUG_EXCEPTION("emcore_gmime_download_attachment failed [%d]", err);
-#else
- if (!emcore_download_attachment (account_id, mail_id, attachment_no, 1, handle_to_be_published, &err))
- EM_DEBUG_EXCEPTION("\t emcore_download_attachment failed [%d]", err);
-#endif
-
#endif
}
@@ -1392,7 +1391,7 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(int account_id, int mai
return true;
}
-static int event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(int mail_ids[], int num, email_flags_field_type field_type, int value, int *error)
+static int event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(char *multi_user_name, int mail_ids[], int num, email_flags_field_type field_type, int value, int *error)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1400,7 +1399,7 @@ static int event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(int mail_ids[],
if (!emnetwork_check_network_status(&err))
EM_DEBUG_EXCEPTION("dnet_init failed [%d]", err);
- else if (!emcore_sync_flags_field_with_server(mail_ids, num, field_type, value, &err))
+ else if (!emcore_sync_flags_field_with_server(multi_user_name, mail_ids, num, field_type, value, &err))
EM_DEBUG_EXCEPTION("emcore_sync_flags_field_with_server failed [%d]", err);
if (error)
@@ -1410,7 +1409,7 @@ static int event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(int mail_ids[],
return true;
}
-static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(int account_id, int handle_to_be_published, int *error)
+static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(char *multi_user_name, int account_id, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN();
@@ -1424,7 +1423,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(int account_id, int handle
}
else {
- if (!emcore_validate_account(account_id, handle_to_be_published, &err)) {
+ if (!emcore_validate_account(multi_user_name, account_id, handle_to_be_published, &err)) {
EM_DEBUG_EXCEPTION("emcore_validate_account failed account id : %d err : %d", account_id, err);
if (err == EMAIL_ERROR_CANCELLED) {
@@ -1439,7 +1438,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(int account_id, int handle
}
else {
email_account_t *account_ref = NULL;
- account_ref = emcore_get_account_reference(account_id);
+ account_ref = emcore_get_account_reference(multi_user_name, account_id, false);
if (account_ref) {
EM_DEBUG_LOG("account_ref->incoming_server_type[%d]", account_ref->incoming_server_type);
@@ -1449,7 +1448,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(int account_id, int handle
EM_DEBUG_LOG("canceled type [%d]", dummy);
err = EMAIL_ERROR_CANCELLED;
}
- else if (!emcore_sync_mailbox_list(account_id, "", handle_to_be_published, &err))
+ else if (!emcore_sync_mailbox_list(multi_user_name, account_id, "", handle_to_be_published, &err))
EM_DEBUG_EXCEPTION("\t emcore_get_mailbox_list_to_be_sync falied - %d", err);
}
@@ -1472,35 +1471,36 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(int account_id, int handle
return true;
}
-static int event_handler_EMAIL_EVENT_UPDATE_MAIL(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas, int handle_to_be_published)
+static int event_handler_EMAIL_EVENT_UPDATE_MAIL(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas, int handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count[%d], input_meeting_request[%p], input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
int err = EMAIL_ERROR_NONE;
/*
- if ( (err = emcore_update_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE)
+ if ( (err = emcore_update_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
*/
EM_DEBUG_FUNC_END("err [%d", err);
return err;
}
-static int event_handler_EMAIL_EVENT_SAVE_MAIL(int input_account_id, int input_mail_id, int input_handle_to_be_published)
+
+static int event_handler_EMAIL_EVENT_SAVE_MAIL(char *multi_user_name, int input_account_id, int input_mail_id, int input_handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d] input_mail_id [%d] input_handle_to_be_published [%d]", input_account_id, input_mail_id, input_handle_to_be_published);
int err = EMAIL_ERROR_NONE;
- err = emcore_sync_mail_from_client_to_server(input_mail_id);
+ err = emcore_sync_mail_from_client_to_server(multi_user_name, input_mail_id);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-static int event_handler_EMAIL_EVENT_MOVE_MAIL(int account_id, int *mail_ids, int mail_id_count, int dest_mailbox_id, int src_mailbox_id, int handle_to_be_published, int *error)
+static int event_handler_EMAIL_EVENT_MOVE_MAIL(char *multi_user_name, int account_id, int *mail_ids, int mail_id_count, int dest_mailbox_id, int src_mailbox_id, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE, ret = false;
email_account_t *account_ref = NULL;
- if (!(account_ref = emcore_get_account_reference(account_id))) {
+ if (!(account_ref = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
@@ -1520,10 +1520,10 @@ static int event_handler_EMAIL_EVENT_MOVE_MAIL(int account_id, int *mail_ids, in
EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
else {
#ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
- if (!emcore_move_mail_on_server_ex(account_id , src_mailbox_id, mail_ids, mail_id_count, dest_mailbox_id, &err))
+ if (!emcore_move_mail_on_server_ex(multi_user_name, account_id , src_mailbox_id, mail_ids, mail_id_count, dest_mailbox_id, &err))
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_ex failed - %d", err);
#else
- if (!emcore_move_mail_on_server(account_id , src_mailbox_id, mail_ids, mail_id_count, dest_mailbox_id, &err))
+ if (!emcore_move_mail_on_server(multi_user_name, account_id , src_mailbox_id, mail_ids, mail_id_count, dest_mailbox_id, &err))
EM_DEBUG_EXCEPTION("\t emcore_move_mail_on_server failed - %d", err);
#endif
}
@@ -1544,31 +1544,31 @@ FINISH_OFF:
return ret;
}
-static int event_handler_EMAIL_EVENT_DELETE_MAILBOX(int mailbox_id, int on_server, int recursive, int handle_to_be_published)
+static int event_handler_EMAIL_EVENT_DELETE_MAILBOX(char *multi_user_name, int mailbox_id, int on_server, int recursive, int handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN("mailbox_id[%d] on_server[%d] recursive[%d] handle_to_be_published[%d]", mailbox_id, on_server, recursive, handle_to_be_published);
int err = EMAIL_ERROR_NONE;
- if ((err = emcore_delete_mailbox(mailbox_id, on_server, recursive)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_delete_mailbox(multi_user_name, mailbox_id, on_server, recursive)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_delete failed [%d]", err);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-static int event_handler_EMAIL_EVENT_CREATE_MAILBOX(email_mailbox_t *input_new_mailbox, int on_server, int handle_to_be_published)
+static int event_handler_EMAIL_EVENT_CREATE_MAILBOX(char *multi_user_name, email_mailbox_t *input_new_mailbox, int on_server, int handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- if (!emcore_create_mailbox(input_new_mailbox, on_server, -1, -1, &err))
+ if (!emcore_create_mailbox(multi_user_name, input_new_mailbox, on_server, -1, -1, &err))
EM_DEBUG_EXCEPTION("emcore_create failed - %d", err);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-static int event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(int mail_id, int event_handle, int *error)
+static int event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(char *multi_user_name, int mail_id, int event_handle, int *error)
{
EM_DEBUG_FUNC_BEGIN("mail_id [%d], error [%p]", mail_id, error);
@@ -1577,7 +1577,7 @@ static int event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(int mail_id, int e
if (!emnetwork_check_network_status(&err))
EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
else {
- if (!emcore_sync_flag_with_server(mail_id, event_handle, &err))
+ if (!emcore_sync_flag_with_server(multi_user_name, mail_id, event_handle, &err))
EM_DEBUG_EXCEPTION("emcore_sync_flag_with_server failed [%d]", err);
#ifdef __FEATURE_LOCAL_ACTIVITY__
else {
@@ -1603,12 +1603,17 @@ static int event_handler_EMAIL_EVENT_SYNC_MAIL_FLAG_TO_SERVER(int mail_id, int e
return true;
}
-static int event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(int input_account_id, int input_mailbox_id, int input_from_server, int *error)
+static int event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(char *multi_user_name, int input_account_id, int input_mailbox_id, int input_from_server, int *error)
{
EM_DEBUG_FUNC_BEGIN("input_account_id [%d] input_mailbox_id [%d], input_from_server [%d], error [%p]", input_account_id, input_mailbox_id, input_from_server, error);
int err = EMAIL_ERROR_NONE;
- if (!emcore_delete_all_mails_of_mailbox(input_account_id, input_mailbox_id, input_from_server, &err))
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ input_account_id,
+ input_mailbox_id,
+ 0,
+ input_from_server,
+ &err))
EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
if (error)
@@ -1618,20 +1623,20 @@ static int event_handler_EMAIL_EVENT_DELETE_MAIL_ALL(int input_account_id, int i
return true;
}
-static int event_handler_EMAIL_EVENT_DELETE_MAIL(int account_id, int *mail_id_list, int mail_id_count, int from_server, int *error)
+static int event_handler_EMAIL_EVENT_DELETE_MAIL(char *multi_user_name, int account_id, int *mail_id_list, int mail_id_count, int from_server, int *error)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
int ret = false;
email_account_t *account_ref = NULL;
- if (!(account_ref = emcore_get_account_reference(account_id))) {
+ if (!(account_ref = emcore_get_account_reference(multi_user_name, account_id, false))) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, from_server, EMAIL_DELETED_BY_COMMAND, false, &err)) {
+ if (!emcore_delete_mail(multi_user_name, account_id, mail_id_list, mail_id_count, from_server, EMAIL_DELETED_BY_COMMAND, false, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -1651,7 +1656,7 @@ FINISH_OFF:
return ret;
}
-static int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(int account_id, char *maibox_name, int handle_to_be_published, int *error)
+static int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(char *multi_user_name, int account_id, char *maibox_name, int handle_to_be_published, int *error)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
@@ -1663,7 +1668,7 @@ static int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(int account_id, char *maibo
}
else {
EM_DEBUG_LOG("Sync of all mailbox");
- if (!emcore_sync_mailbox_list(account_id, "", handle_to_be_published, &err))
+ if (!emcore_sync_mailbox_list(multi_user_name, account_id, "", handle_to_be_published, &err))
EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list failed [%d]", err);
}
@@ -1674,14 +1679,92 @@ static int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(int account_id, char *maibo
return true;
}
-static int event_handler_EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER(int input_account_id, int input_mailbox_id, char *input_old_mailbox_path, char *input_new_mailbox_path, char *input_new_mailbox_alias, int handle_to_be_published)
+static int event_handler_EMAIL_EVENT_SEARCH_ON_SERVER(char *multi_user_name, int account_id, int mailbox_id,
+ email_search_filter_t *input_search_filter,
+ int input_search_filter_count, int handle_to_be_published)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id : [%d], mailbox_id : [%d], input_search_filter : [%p], "
+ "input_search_filter_count : [%d], handle_to_be_published [%d]",
+ account_id, mailbox_id, input_search_filter,
+ input_search_filter_count, handle_to_be_published);
+
+ int err = EMAIL_ERROR_NONE;
+ char mailbox_id_param_string[10] = {0,};
+ emstorage_mailbox_tbl_t *local_mailbox = NULL;
+
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name,
+ mailbox_id,
+ &local_mailbox)) != EMAIL_ERROR_NONE || !local_mailbox) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ SNPRINTF(mailbox_id_param_string, 10, "%d", local_mailbox->mailbox_id);
+
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL, account_id, mailbox_id_param_string, 0, err))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed");
+ goto FINISH_OFF;
+ }
+
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_START,
+ account_id,
+ mailbox_id_param_string,
+ handle_to_be_published,
+ 0))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_START] failed >>>>");
+
+ if ((err = emcore_search_on_server(multi_user_name,
+ account_id,
+ mailbox_id,
+ input_search_filter,
+ input_search_filter_count,
+ true,
+ handle_to_be_published)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_search_on_server failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ if (err != EMAIL_ERROR_NONE) {
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FAIL,
+ account_id,
+ mailbox_id_param_string,
+ handle_to_be_published,
+ 0))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEARCH_ON_SERVER_FAILED] failed >>>>");
+ } else {
+ if (!emcore_notify_network_event(NOTI_SEARCH_ON_SERVER_FINISH,
+ account_id,
+ NULL,
+ handle_to_be_published,
+ 0))
+ EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEARCH_ON_SERVER_FINISH] Failed >>>>>");
+ }
+
+ if (local_mailbox)
+ emstorage_free_mailbox(&local_mailbox, 1, NULL);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+static int event_handler_EMAIL_EVENT_RENAME_MAILBOX_ON_IMAP_SERVER(char *multi_user_name,
+ int input_account_id,
+ int input_mailbox_id,
+ char *input_old_mailbox_path,
+ char *input_new_mailbox_path,
+ char *input_new_mailbox_alias,
+ int handle_to_be_published)
{
EM_DEBUG_FUNC_BEGIN_SEC("input_account_id [%d], input_mailbox_id [%d], input_old_mailbox_path %s], input_new_mailbox_path [%s], input_new_mailbox_alias [%s], handle_to_be_published [%d]", input_account_id, input_mailbox_id, input_old_mailbox_path, input_new_mailbox_path, input_new_mailbox_alias, handle_to_be_published);
int err = EMAIL_ERROR_NONE;
if (err == EMAIL_ERROR_NONE) {
- if ((err = emcore_rename_mailbox(input_mailbox_id, input_new_mailbox_path, input_new_mailbox_alias, NULL, 0, true, true, handle_to_be_published)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_rename_mailbox(multi_user_name, input_mailbox_id, input_new_mailbox_path, input_new_mailbox_alias, NULL, 0, true, true, handle_to_be_published)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_rename_mailbox failed [%d]", err);
}
}
@@ -1699,7 +1782,7 @@ static void* worker_send_event_queue(void *arg)
int pbd_thd_state = 0;
int event_que_state = 0;
- if (!emstorage_open(&err)) {
+ if (!emstorage_open(NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_open falied [%d]", err);
return NULL;
}
@@ -1747,13 +1830,13 @@ static void* worker_send_event_queue(void *arg)
switch (event_data->type) {
case EMAIL_EVENT_SEND_MAIL:
- if (!emcore_send_mail(event_data->event_param_data_4, &err))
+ if (!emcore_send_mail(event_data->multi_user_name, event_data->event_param_data_4, &err))
EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err);
break;
case EMAIL_EVENT_SEND_MAIL_SAVED:
/* send mails to been saved in off-line mode */
- if (!emcore_send_saved_mail(event_data->account_id, event_data->event_param_data_3, &err))
+ if (!emcore_send_saved_mail(event_data->multi_user_name, event_data->account_id, event_data->event_param_data_3, &err))
EM_DEBUG_EXCEPTION("emcore_send_saved_mail failed - %d", err);
break;
@@ -1778,14 +1861,15 @@ static void* worker_send_event_queue(void *arg)
EM_DEBUG_LOG("Found local activity type - %d", local_activity[0].activity_type);
switch (local_activity[0].activity_type) {
case ACTIVITY_SAVEMAIL: {
- if (!emcore_sync_mail_from_client_to_server(event_data->account_id, local_activity[0].mail_id, &err)) {
+ if (!emcore_sync_mail_from_client_to_server(event_data->multi_user_name, event_data->account_id, local_activity[0].mail_id, &err)) {
EM_DEBUG_EXCEPTION("emcore_sync_mail_from_client_to_server failed - %d ", err);
}
}
break;
case ACTIVITY_DELETEMAIL_SEND: /* New Activity Type Added for Race Condition and Crash Fix */ {
- if (!emcore_delete_mail(local_activity[0].account_id,
+ if (!emcore_delete_mail(local_activity[0].multi_user_name,
+ local_activity[0].account_id,
&local_activity[0].mail_id,
EMAIL_DELETE_FOR_SEND_THREAD,
true,
@@ -1915,7 +1999,7 @@ static gpointer partial_body_download_thread(gpointer data)
/* Open connection with DB */
- if (false == emstorage_open(&err)) {
+ if (false == emstorage_open(NULL, &err)) {
EM_DEBUG_EXCEPTION("emstorage_open failed [%d]", err);
return false;
}
@@ -1945,6 +2029,8 @@ static gpointer partial_body_download_thread(gpointer data)
partial_body_thd_event.account_id = g_partial_body_bulk_dwd_que[0].account_id;
partial_body_thd_event.mailbox_id = g_partial_body_bulk_dwd_que[0].mailbox_id;
partial_body_thd_event.mailbox_name = EM_SAFE_STRDUP(g_partial_body_bulk_dwd_que[0].mailbox_name); /* need to be freed */
+ partial_body_thd_event.multi_user_name = EM_SAFE_STRDUP(g_partial_body_bulk_dwd_que[0].multi_user_name); /* need to be freed */
+
if (false == emcore_mail_partial_body_download(&partial_body_thd_event, &err))
EM_DEBUG_EXCEPTION("emcore_mail_partial_body_download from event_data queue failed [%d]", err);
@@ -1956,7 +2042,7 @@ static gpointer partial_body_download_thread(gpointer data)
/*Check for local Activities */
int is_local_activity_event_inserted = false;
- if (false == emcore_partial_body_thd_local_activity_sync(&is_local_activity_event_inserted, &err)) {
+ if (false == emcore_partial_body_thd_local_activity_sync(partial_body_thd_event.multi_user_name, &is_local_activity_event_inserted, &err)) {
EM_DEBUG_EXCEPTION("emcore_partial_body_thd_local_activity_sync failed [%d]", err);
}
else {
@@ -1978,13 +2064,12 @@ static gpointer partial_body_download_thread(gpointer data)
/* finalize sync */
account_count = 0;
account_list = NULL;
-
- if (!emstorage_get_account_list(&account_count, &account_list, false, false, &err)) {
+ if (!emstorage_get_account_list(NULL, &account_count, &account_list, false, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed : [%d]", err);
}
for (i = 0; i < account_count; i++) {
- if (!emdaemon_finalize_sync(account_list[i].account_id, 0, 0, 0, 0, true, NULL))
+ if (!emdaemon_finalize_sync(partial_body_thd_event.multi_user_name, account_list[i].account_id, 0, 0, 0, 0, true, NULL))
EM_DEBUG_EXCEPTION("emdaemon_finalize_sync failed");
}
diff --git a/email-daemon/email-daemon-init.c b/email-daemon/email-daemon-init.c
index aa7770b..d56a9c8 100755
--- a/email-daemon/email-daemon-init.c
+++ b/email-daemon/email-daemon-init.c
@@ -67,6 +67,7 @@
#include "email-device.h"
#include "c-client.h"
#include "email-core-smime.h"
+#include "email-core-container.h"
connection_h conn = NULL;
@@ -146,6 +147,9 @@ static int _emdaemon_unload_email_core()
emcore_stop_event_loop(&err);
emcore_stop_task_manager_loop();
+ /* Destroy container for daemon */
+ emcore_destroy_container();
+
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
emcore_stop_auto_download_loop(&err);
#endif
@@ -158,6 +162,7 @@ static int _emdaemon_unload_email_core()
return err;
}
+#ifdef __FEATURE_SYNC_STATUS__
static void callback_for_SYNC_ALL_STATUS_from_account_svc(keynode_t *input_node, void *input_user_data)
{
EM_DEBUG_FUNC_BEGIN("input_node [%p], input_user_data [%p]", input_node, input_user_data);
@@ -169,7 +174,7 @@ static void callback_for_SYNC_ALL_STATUS_from_account_svc(keynode_t *input_node,
email_account_t *account_list = NULL;
emstorage_mailbox_tbl_t *mailbox_tbl_data = NULL;
- if (!emdaemon_get_account_list(&account_list, &account_count, &err)) {
+ if (!emdaemon_get_account_list(NULL, &account_list, &account_count, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -179,12 +184,12 @@ static void callback_for_SYNC_ALL_STATUS_from_account_svc(keynode_t *input_node,
for(i = 0; i < account_count; i++) {
if(sync_start_toggle == 1) {
- if(!emstorage_get_mailbox_by_mailbox_type(account_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl_data, true, &err)) {
+ if(!emstorage_get_mailbox_by_mailbox_type(NULL, account_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl_data, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type for [%d] failed [%d]", account_list[i].account_id, err);
continue;
}
- if(!emdaemon_sync_header(account_list[i].account_id, mailbox_tbl_data->mailbox_id, &handle, &err)) {
+ if(!emdaemon_sync_header(NULL, account_list[i].account_id, mailbox_tbl_data->mailbox_id, &handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_sync_header for [%d] failed [%d]", account_list[i].account_id, err);
}
@@ -192,7 +197,7 @@ static void callback_for_SYNC_ALL_STATUS_from_account_svc(keynode_t *input_node,
mailbox_tbl_data = NULL;
}
else {
- emcore_cancel_all_threads_of_an_account(account_list[i].account_id);
+ emcore_cancel_all_threads_of_an_account(NULL, account_list[i].account_id);
}
}
@@ -215,7 +220,7 @@ static void callback_for_AUTO_SYNC_STATUS_from_account_svc(keynode_t *input_node
email_account_t *account_list = NULL;
email_account_t *account_info = NULL;
- if (!emdaemon_get_account_list(&account_list, &account_count, &err)) {
+ if (!emdaemon_get_account_list(NULL, &account_list, &account_count, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -237,7 +242,7 @@ static void callback_for_AUTO_SYNC_STATUS_from_account_svc(keynode_t *input_node
account_info->check_interval = ~account_info->check_interval + 1;
}
- if(!emdaemon_update_account(account_info->account_id, account_info, &err)) {
+ if(!emdaemon_update_account(NULL, account_info->account_id, account_info, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_update_account failed [%d]", err);
goto FINISH_OFF;
}
@@ -249,6 +254,7 @@ FINISH_OFF:
EM_DEBUG_FUNC_END();
}
+#endif /* __FEATURE_SYNC_STATUS__ */
static void callback_for_NETWORK_STATUS(connection_type_e new_conn_type, void *input_user_data)
{
@@ -261,6 +267,7 @@ static void callback_for_NETWORK_STATUS(connection_type_e new_conn_type, void *i
int conn_type = 0;
int handle = 0;
int send_saved_handle = 0;
+ char *multi_user_name = NULL;
email_event_t *event_data = NULL;
email_account_t *account_list = NULL;
email_account_t *account_info = NULL;
@@ -299,18 +306,24 @@ static void callback_for_NETWORK_STATUS(connection_type_e new_conn_type, void *i
if (false == emcore_is_partial_body_thd_que_empty())
emcore_pb_thd_set_local_activity_continue(true);
- if (!emdaemon_get_account_list(&account_list, &account_count, &err)) {
+ if (!emdaemon_get_account_list(NULL, &account_list, &account_count, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
+ // initialize imap idle connection if network connection type is changed
+ if (conn_type != new_conn_type) {
+ EM_DEBUG_LOG("connection type is changed. initializing imap idle connection");
+ emcore_refresh_imap_idle_thread();
+ }
+
for (i = 0; i < account_count ; i++) {
account_info = account_list + i;
/* check if inbox folder sync is finished */
- if (!emstorage_get_mailbox_by_mailbox_type (account_info->account_id, EMAIL_MAILBOX_TYPE_INBOX, &local_mailbox, false, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type (multi_user_name, account_info->account_id, EMAIL_MAILBOX_TYPE_INBOX, &local_mailbox, false, &err)) {
if (err == EMAIL_ERROR_MAILBOX_NOT_FOUND) {
- int handle = 0;
- emdaemon_get_imap_mailbox_list(account_info->account_id, "", &handle, &err);
+ int handle = 0;
+ emdaemon_get_imap_mailbox_list(multi_user_name, account_info->account_id, "", &handle, &err);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_get_imap_mailbox_list error [%d]", err);
}
@@ -322,14 +335,14 @@ static void callback_for_NETWORK_STATUS(connection_type_e new_conn_type, void *i
}
/* send mails in outbox */
- if (!emcore_get_mail_count_by_query(account_info->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, 0, &total, &unseen, &err)) {
+ if (!emcore_get_mail_count_by_query(NULL, account_info->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, 0, &total, &unseen, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_count_by_query failed [%d]", err);
}
if (total <= 0)
continue;
- if (!emdaemon_send_mail_saved(account_info->account_id, &send_saved_handle, &err)) {
+ if (!emdaemon_send_mail_saved(multi_user_name, account_info->account_id, &send_saved_handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_send_mail_saved failed : [%d]", err);
}
}
@@ -402,7 +415,7 @@ static void callback_for_VCONFKEY_GLOBAL_BADGE_STATUS(keynode_t *input_node, voi
noti_status = vconf_keynode_get_bool(input_node);
if (noti_status) {
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge((char *)input_user_data);
} else {
if (vconf_get_bool(VCONF_VIP_NOTI_BADGE_TICKER, &badge_ticker) != 0) {
EM_DEBUG_EXCEPTION("vconf_get_bool failed");
@@ -411,12 +424,12 @@ static void callback_for_VCONFKEY_GLOBAL_BADGE_STATUS(keynode_t *input_node, voi
}
/* if priority sender is on, show the priority sender unread */
if (badge_ticker) {
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge((char *)input_user_data);
goto FINISH_OFF;
}
/* reset badge */
- if ((err = emcore_display_badge_count(0)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_display_badge_count((char *)input_user_data, 0)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_display_badge_count failed : [%d]", err);
}
@@ -440,7 +453,7 @@ static void callback_for_VCONFKEY_PRIORITY_BADGE_STATUS(keynode_t *input_node, v
noti_status = vconf_keynode_get_bool(input_node);
if (noti_status) {
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge((char *)input_user_data);
} else {
if (vconf_get_bool(VCONFKEY_TICKER_NOTI_BADGE_EMAIL, &badge_ticker) != 0) {
@@ -451,11 +464,11 @@ static void callback_for_VCONFKEY_PRIORITY_BADGE_STATUS(keynode_t *input_node, v
/*if global badge is on, show the global unread*/
if (badge_ticker) {
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge((char *)input_user_data);
goto FINISH_OFF;
}
/* if all badges are off, reset badge count */
- if ((err = emcore_display_badge_count(0)) != EMAIL_ERROR_NONE)
+ if ((err = emcore_display_badge_count((char *)input_user_data, 0)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_display_badge_count failed : [%d]", err);
}
@@ -463,33 +476,6 @@ FINISH_OFF:
EM_DEBUG_FUNC_END();
}
-static void callback_for_VCONFKEY_TELEPHONY_ZONE_TYPE(keynode_t *input_node, void *input_user_data)
-{
- EM_DEBUG_FUNC_BEGIN();
- int telephony_zone = 0;
-
- if (!input_node) {
- EM_DEBUG_EXCEPTION("Invalid param");
- return;
- }
-
- telephony_zone = vconf_keynode_get_int(input_node);
-
- EM_DEBUG_LOG("telephony_zone [%d]", telephony_zone);
-
- /*
- switch(telephony_zone) {
- case VCONFKEY_TELEPHONY_ZONE_NONE :
- case VCONFKEY_TELEPHONY_ZONE_HOME :
- case VCONFKEY_TELEPHONY_ZONE_CITY :
- default :
- break;
- }
- */
-
- EM_DEBUG_FUNC_END();
-}
-
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
static void callback_for_VCONFKEY_WIFI_STATE(keynode_t *input_node, void *input_user_data)
{
@@ -517,7 +503,7 @@ static void callback_for_VCONFKEY_WIFI_STATE(keynode_t *input_node, void *input_
}
#endif
-INTERNAL_FUNC int emdaemon_initialize(int* err_code)
+INTERNAL_FUNC int emdaemon_initialize(char *multi_user_name, int* err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -526,60 +512,42 @@ INTERNAL_FUNC int emdaemon_initialize(int* err_code)
int err = EMAIL_ERROR_NONE;
connection_type_e net_state = CONNECTION_TYPE_DISCONNECTED;
- if (g_client_count > 0) {
+ if (!g_client_count) {
EM_DEBUG_LOG("Initialization was already done. increased counter=[%d]", g_client_count);
- g_client_count++;
- return true;
- }
- else
+
EM_DEBUG_LOG("************* start email service build time [%s %s] ************* ", __DATE__, __TIME__);
- dbus_threads_init_default();
+ dbus_threads_init_default();
#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+ g_type_init();
#endif
+ if ((err = _emdaemon_load_email_core()) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("_emdaemon_load_email_core failed [%d]", err);
+ goto FINISH_OFF;
+ }
- emstorage_shm_file_init(SHM_FILE_FOR_DB_LOCK);
-
-#ifdef __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__
- emstorage_shm_file_init(SHM_FILE_FOR_MAIL_ID_LOCK);
-#endif /* __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ */
+#ifdef __FEATURE_OMA_EMN__
+ if(emdaemon_initialize_emn() != EMAIL_ERROR_NONE) {
+ vconf_notify_key_changed(VCONFKEY_MSG_SERVER_READY, callback_for_VCONFKEY_MSG_SERVER_READY, NULL);
+ }
+#endif
+ }
- /* open database */
- if (!emstorage_open(&err)) {
+ /* open database */
+ if (!emstorage_open(multi_user_name, &err)) {
EM_DEBUG_EXCEPTION("emstorage_open failed [%d]", err);
goto FINISH_OFF;
}
- if ((err = emstorage_update_db_table_schema()) != EMAIL_ERROR_NONE)
+ if ((err = emstorage_update_db_table_schema(multi_user_name)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emstorage_update_db_table_schema failed [%d]", err);
- if (!emstorage_clean_save_status(EMAIL_MAIL_STATUS_SAVED, &err))
+ if (!emstorage_clean_save_status(multi_user_name, EMAIL_MAIL_STATUS_SAVED, &err))
EM_DEBUG_EXCEPTION("emstorage_check_mail_status Failed [%d]", err );
- g_client_count = 0;
-
- if (!emdaemon_initialize_account_reference()) {
- EM_DEBUG_EXCEPTION("emdaemon_initialize_account_reference fail...");
- err = EMAIL_ERROR_DB_FAILURE;
- goto FINISH_OFF;
- }
- EM_DEBUG_LOG("emdaemon_initialize_account_reference over - g_client_count [%d]", g_client_count);
-
- if ((err = _emdaemon_load_email_core()) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("_emdaemon_load_email_core failed [%d]", err);
- goto FINISH_OFF;
- }
-
-#ifdef __FEATURE_OMA_EMN__
- if(emdaemon_initialize_emn() != EMAIL_ERROR_NONE) {
- vconf_notify_key_changed(VCONFKEY_MSG_SERVER_READY, callback_for_VCONFKEY_MSG_SERVER_READY, NULL);
- }
-#endif
-
#ifdef __FEATURE_AUTO_RETRY_SEND__
- if ((err = emcore_create_alarm_for_auto_resend (AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_create_alarm_for_auto_resend (multi_user_name, AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
if (err == EMAIL_ERROR_MAIL_NOT_FOUND)
EM_DEBUG_LOG ("no mail found");
else
@@ -587,13 +555,15 @@ INTERNAL_FUNC int emdaemon_initialize(int* err_code)
}
#endif /* __FEATURE_AUTO_RETRY_SEND__ */
+
/* Start auto polling */
#ifdef __FEATURE_AUTO_POLLING__
- emdaemon_start_auto_polling(&err);
+ emdaemon_start_auto_polling(multi_user_name, &err);
#endif
#ifdef __FEATURE_IMAP_IDLE__
- emcore_create_imap_idle_thread();
+ if (!g_client_count)
+ emcore_create_imap_idle_thread();
#endif /* __FEATURE_IMAP_IDLE__ */
/* Subscribe Events */
@@ -621,28 +591,20 @@ INTERNAL_FUNC int emdaemon_initialize(int* err_code)
#ifdef __FEATURE_BLOCKING_MODE__
vconf_notify_key_changed(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, callback_for_BLOCKING_MODE_STATUS, NULL);
#endif
- vconf_notify_key_changed(VCONFKEY_TICKER_NOTI_BADGE_EMAIL, callback_for_VCONFKEY_GLOBAL_BADGE_STATUS, NULL);
-
- vconf_notify_key_changed(VCONF_VIP_NOTI_BADGE_TICKER, callback_for_VCONFKEY_PRIORITY_BADGE_STATUS, NULL);
-
- vconf_notify_key_changed(VCONFKEY_SETAPPL_STATE_TICKER_NOTI_EMAIL_BOOL, callback_for_VCONFKEY_GLOBAL_BADGE_STATUS, NULL);
-
- vconf_notify_key_changed(VCONF_VIP_NOTI_NOTIFICATION_TICKER, callback_for_VCONFKEY_PRIORITY_BADGE_STATUS, NULL);
-
- /* VCONFKEY_TELEPHONY_SVC_ROAM */
- vconf_notify_key_changed(VCONFKEY_TELEPHONY_ZONE_TYPE, callback_for_VCONFKEY_TELEPHONY_ZONE_TYPE, NULL);
-
+ vconf_notify_key_changed(VCONFKEY_TICKER_NOTI_BADGE_EMAIL, callback_for_VCONFKEY_GLOBAL_BADGE_STATUS, multi_user_name);
+ vconf_notify_key_changed(VCONF_VIP_NOTI_BADGE_TICKER, callback_for_VCONFKEY_PRIORITY_BADGE_STATUS, multi_user_name);
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_STATE_TICKER_NOTI_EMAIL_BOOL, callback_for_VCONFKEY_GLOBAL_BADGE_STATUS, multi_user_name);
+ vconf_notify_key_changed(VCONF_VIP_NOTI_NOTIFICATION_TICKER, callback_for_VCONFKEY_PRIORITY_BADGE_STATUS, multi_user_name);
#ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
vconf_notify_key_changed(VCONFKEY_WIFI_STATE, callback_for_VCONFKEY_WIFI_STATE, NULL);
#endif
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
ret = true;
+ g_client_count++;
FINISH_OFF:
- if (ret == true)
- g_client_count = 1;
if (err_code)
*err_code = err;
@@ -666,9 +628,6 @@ INTERNAL_FUNC int emdaemon_finalize(int* err_code)
connection_destroy(conn);
- /* free account reference list */
- emcore_free_account_reference();
-
/* close database */
if (!emstorage_close(&err)) {
EM_DEBUG_EXCEPTION("emstorage_close failed [%d]", err);
@@ -688,7 +647,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_AUTO_POLLING__
-INTERNAL_FUNC int emdaemon_start_auto_polling(int* err_code)
+INTERNAL_FUNC int emdaemon_start_auto_polling(char *multi_user_name, int* err_code)
{
EM_DEBUG_FUNC_BEGIN();
@@ -698,15 +657,15 @@ INTERNAL_FUNC int emdaemon_start_auto_polling(int* err_code)
emstorage_account_tbl_t* account_list = NULL;
/* get account list */
- if (!emstorage_get_account_list(&count, &account_list, false, false, &err)) {
- EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
+ if (!emstorage_get_account_list(multi_user_name, &count, &account_list, false, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
goto FINISH_OFF;
}
for (i = 0; i < count; i++) {
/* start auto polling, if check_interval not zero */
if(account_list[i].check_interval > 0 || ((account_list[i].peak_days > 0) && account_list[i].peak_interval > 0)) {
- if(!emdaemon_add_polling_alarm( account_list[i].account_id))
+ if(!emdaemon_add_polling_alarm(multi_user_name, account_list[i].account_id))
EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm failed");
}
}
@@ -765,8 +724,8 @@ INTERNAL_FUNC int emdaemon_core_init(int *err_code)
emdaemon_init_alarm_data_list();
- /* Openssl library init */
- emcore_init_openssl_library();
+ /* Openssl library init */
+ emcore_init_openssl_library();
if (err_code)
*err_code = EMAIL_ERROR_NONE;
@@ -818,7 +777,7 @@ static int default_alarm_callback(int input_timer_id, void *user_parameter)
int err = EMAIL_ERROR_NONE;
email_alarm_data_t *alarm_data = NULL;
- EM_DEBUG_ALARM_LOG("default_alarm_callback input_timer_id[%d]", input_timer_id);
+// EM_DEBUG_ALARM_LOG("default_alarm_callback input_timer_id[%d]", input_timer_id);
emdevice_set_sleep_on_off(STAY_AWAKE_FLAG_FOR_ALARM_CALLBACK, false, NULL);
diff --git a/email-daemon/email-daemon-mail.c b/email-daemon/email-daemon-mail.c
index 8b453aa..8a1fbcb 100755
--- a/email-daemon/email-daemon-mail.c
+++ b/email-daemon/email-daemon-mail.c
@@ -42,6 +42,7 @@
#include "email-internal-types.h"
#include "email-daemon.h"
+#include "email-network.h"
#include "email-core-event.h"
#include "email-daemon-account.h"
#include "email-debug-log.h"
@@ -59,9 +60,9 @@
extern int g_local_activity_run;
extern int g_save_local_activity_run;
#endif
-static int _emdaemon_check_mail_id(int mail_id, int* err_code);
+static int _emdaemon_check_mail_id(char *multi_user_name, int mail_id, int* err_code);
-INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_send_mail(char *multi_user_name, int mail_id, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], handle[%p], err_code[%p]", mail_id, handle, err_code);
@@ -79,7 +80,7 @@ INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code)
goto FINISH_OFF;
}
- if(!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err)) {
+ if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err)) {
EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
goto FINISH_OFF;
}
@@ -96,45 +97,55 @@ INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code)
account_id = mail_table_data->account_id;
- ref_account = emcore_get_account_reference(account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
+ if (!emnetwork_check_network_status(&err)) {
+ EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
#ifdef __FEATURE_MOVE_TO_OUTBOX_FIRST__
- if (!emstorage_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, true, &err)) {
+ if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
+
dst_mailbox_id = local_mailbox->mailbox_id;
- if ( mail_table_data->mailbox_id != dst_mailbox_id ) {
+ if (mail_table_data->mailbox_id != dst_mailbox_id) {
/* mail is moved to 'OUTBOX' first of all. */
- if (!emcore_move_mail(&mail_id, 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, &err)) {
+ if (!emcore_move_mail(multi_user_name, &mail_id, 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, &err)) {
EM_DEBUG_EXCEPTION("emcore_mail_move falied [%d]", err);
goto FINISH_OFF;
}
}
#endif /* __FEATURE_MOVE_TO_OUTBOX_FIRST__ */
- if(!emcore_notify_network_event(NOTI_SEND_START, account_id, NULL, mail_id, 0))
+ if (!emcore_notify_network_event(NOTI_SEND_START, account_id, NULL, mail_id, 0))
EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_SEND_START] Failed >>>> ");
/* set EMAIL_MAIL_STATUS_SEND_WAIT status */
-
- if(!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_WAIT, true, &err)) {
+ if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_WAIT, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value [%d]",err);
-
goto FINISH_OFF;
}
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_SEND_MAIL;
event_data->account_id = account_id;
event_data->event_param_data_4 = mail_id;
event_data->event_param_data_5 = mail_table_data->mailbox_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event_for_sending_mails(event_data, &result_handle, &err)) {
EM_DEBUG_EXCEPTION(" emcore_insert_event failed [%d]", err);
@@ -155,7 +166,7 @@ FINISH_OFF:
if (ret == false) {
EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
- if(!emstorage_set_field_of_mails_with_integer_value(account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SAVED, true, &err))
+ if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SAVED, true, &err))
EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value [%d]",err);
if (event_data) {
@@ -185,7 +196,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_send_mail_saved(char *multi_user_name, int account_id, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d],handle[%p], err_code[%p]", account_id, handle, err_code);
@@ -201,23 +212,29 @@ INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, int *handle, int* err
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_name_by_mailbox_type(account_id,EMAIL_MAILBOX_TYPE_OUTBOX,&mailbox_name, false, &err)) {
+ if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, account_id,EMAIL_MAILBOX_TYPE_OUTBOX,&mailbox_name, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_SEND_MAIL_SAVED;
event_data->account_id = account_id;
event_data->event_param_data_3 = EM_SAFE_STRDUP(mailbox_name);
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event_for_sending_mails(event_data, (int *)handle, &err)) {
EM_DEBUG_EXCEPTION(" emcore_insert_event failed [%d]", err);
@@ -247,7 +264,12 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas)
+INTERNAL_FUNC int emdaemon_add_mail(char *multi_user_name,
+ email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data_list,
+ int input_attachment_count,
+ email_meeting_request_t *input_meeting_request,
+ int input_from_eas)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count [%d], input_meeting_req [%p], input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
@@ -264,14 +286,14 @@ INTERNAL_FUNC int emdaemon_add_mail(email_mail_data_t *input_mail_data, email_at
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(input_mail_data->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, input_mail_data->account_id, false);
if (!ref_account) {
EM_DEBUG_LOG(" emcore_get_account_reference failed [%d]", input_mail_data->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if ((err = emcore_add_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas, false)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas, false)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -279,9 +301,16 @@ INTERNAL_FUNC int emdaemon_add_mail(email_mail_data_t *input_mail_data, email_at
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
if ( input_from_eas == 0 && ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_SAVE_MAIL;
event_data->account_id = input_mail_data->account_id;
event_data->event_param_data_4 = input_mail_data->mail_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, &handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
@@ -310,7 +339,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code)
+INTERNAL_FUNC int emdaemon_add_meeting_request(char *multi_user_name, int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], input_mailbox_id[%d], meeting_req[%p], err_code[%p]", account_id, input_mailbox_id, meeting_req, err_code);
@@ -326,7 +355,7 @@ INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox
goto FINISH_OFF;
}
- if (!emcore_add_meeting_request(account_id, input_mailbox_id, meeting_req, &err)) {
+ if (!emcore_add_meeting_request(multi_user_name, account_id, input_mailbox_id, meeting_req, &err)) {
EM_DEBUG_EXCEPTION(" emcore_save_mail_meeting_request failed [%d]", err);
goto FINISH_OFF;
}
@@ -340,7 +369,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_download_body(char *multi_user_name, int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], verbose[%d], with_attachment[%d], handle[%p], err_code[%p]", account_id, mail_id, verbose, with_attachment, handle, err_code);
@@ -348,16 +377,23 @@ INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbos
int err = EMAIL_ERROR_NONE;
email_event_t *event_data = NULL;
- if (!_emdaemon_check_mail_id(mail_id, &err)) {
+ if (!_emdaemon_check_mail_id(multi_user_name, mail_id, &err)) {
EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err);
goto FINISH_OFF;
}
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_DOWNLOAD_BODY;
event_data->account_id = account_id;
event_data->event_param_data_4 = mail_id;
event_data->event_param_data_5 = (verbose << 1 | with_attachment);
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
@@ -386,7 +422,7 @@ FINISH_OFF:
return ret;
}
-int emdaemon_get_attachment(int attachment_id, email_attachment_data_t** attachment, int* err_code)
+int emdaemon_get_attachment(char *multi_user_name, int attachment_id, email_attachment_data_t** attachment, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], err_code[%p]", attachment_id, attachment, err_code);
@@ -400,7 +436,7 @@ int emdaemon_get_attachment(int attachment_id, email_attachment_data_t** attachm
goto FINISH_OFF;
}
- if (!emcore_get_attachment_info(attachment_id, attachment, &err) || !attachment) {
+ if (!emcore_get_attachment_info(multi_user_name, attachment_id, attachment, &err) || !attachment) {
EM_DEBUG_EXCEPTION("emcore_get_attachment_info failed [%d]", err);
goto FINISH_OFF;
}
@@ -417,7 +453,7 @@ FINISH_OFF:
return ret;
}
-int emdaemon_add_attachment(int mail_id, email_attachment_data_t* attachment, int* err_code)
+int emdaemon_add_attachment(char *multi_user_name, int mail_id, email_attachment_data_t* attachment, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment[%p], err_code[%p]", mail_id, attachment, err_code);
@@ -431,12 +467,12 @@ int emdaemon_add_attachment(int mail_id, email_attachment_data_t* attachment, in
goto FINISH_OFF;
}
- if (!_emdaemon_check_mail_id(mail_id, &err)) {
+ if (!_emdaemon_check_mail_id(multi_user_name, mail_id, &err)) {
EM_DEBUG_EXCEPTION(" _emdaemon_check_mail_id failed [%d]", err);
goto FINISH_OFF;
}
- if (!emcore_add_attachment(mail_id, attachment, &err)) {
+ if (!emcore_add_attachment(multi_user_name, mail_id, attachment, &err)) {
EM_DEBUG_EXCEPTION(" emcore_add_attachment failed [%d]", err);
goto FINISH_OFF;
}
@@ -453,7 +489,7 @@ FINISH_OFF:
return ret;
}
-int emdaemon_delete_mail_attachment(int attachment_id, int* err_code)
+int emdaemon_delete_mail_attachment(char *multi_user_name, int attachment_id, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("attachment_id[%d], err_code[%p]", attachment_id, err_code);
@@ -467,7 +503,7 @@ int emdaemon_delete_mail_attachment(int attachment_id, int* err_code)
goto FINISH_OFF;
}
- if (!emcore_delete_mail_attachment(attachment_id, &err)) {
+ if (!emcore_delete_mail_attachment(multi_user_name, attachment_id, &err)) {
EM_DEBUG_EXCEPTION(" emcore_delete_mail_attachment failed [%d]", err);
goto FINISH_OFF;
}
@@ -484,7 +520,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_download_attachment(char *multi_user_name, int account_id, int mail_id, int nth, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], nth[%d], handle[%p], err_code[%p]", account_id, mail_id, nth, handle, err_code);
@@ -498,16 +534,23 @@ INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int
goto FINISH_OFF;
}
- if (!_emdaemon_check_mail_id(mail_id, &err)) {
+ if (!_emdaemon_check_mail_id(multi_user_name, mail_id, &err)) {
EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err);
goto FINISH_OFF;
}
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_DOWNLOAD_ATTACHMENT;
event_data->account_id = account_id;
event_data->event_param_data_4 = mail_id;
event_data->event_param_data_5 = nth;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
@@ -551,23 +594,27 @@ void* thread_func_to_delete_mail(void *thread_argument)
int account_id = 0;
int from_server = 0;
int noti_param_2 = 0;
- int handle = 0;
+ int handle = 0;
+ char *multi_user_name = NULL;
email_event_t *event_data = (email_event_t*)thread_argument;
account_id = event_data->account_id;
mail_id_list = (int*)event_data->event_param_data_3;
mail_id_count = event_data->event_param_data_4;
from_server = event_data->event_param_data_5;
+ multi_user_name = event_data->multi_user_name;
- if (!emcore_delete_mail(account_id, mail_id_list, mail_id_count, EMAIL_DELETE_LOCALLY, EMAIL_DELETED_BY_COMMAND, noti_param_2, &err)) {
- EM_DEBUG_EXCEPTION(" emcore_delete_mail failed [%d]", err);
+ if (!emcore_delete_mail(multi_user_name, account_id, mail_id_list,
+ mail_id_count, EMAIL_DELETE_LOCALLY,
+ EMAIL_DELETED_BY_COMMAND, noti_param_2, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err);
emcore_free_event(event_data); /* prevent 17922 */
EM_SAFE_FREE(event_data);
goto FINISH_OFF;
}
if (from_server == EMAIL_DELETE_LOCAL_AND_SERVER || from_server == EMAIL_DELETE_FROM_SERVER) {
- if (!emcore_insert_event(event_data, (int*)handle, &err)) {
+ if (!emcore_insert_event(event_data, &handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
/* if (from_server != EMAIL_DELETE_LOCAL_AND_SERVER && from_server != EMAIL_DELETE_FROM_SERVER) {
EM_SAFE_FREE(event_data->event_param_data_3);
@@ -589,9 +636,16 @@ FINISH_OFF:
return SUCCESS;
}
-INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_ids_count, int from_server, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_mail(char *multi_user_name,
+ int account_id,
+ int mail_ids[],
+ int mail_ids_count,
+ int from_server,
+ int *handle,
+ int* err_code)
{
- EM_DEBUG_FUNC_BEGIN("mailbox_id[%d], mail_ids[%p], mail_ids_count[%d], from_server[%d], handle[%p], err_code[%p]", mailbox_id, mail_ids, mail_ids_count, from_server, handle, err_code);
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_ids[%p], mail_ids_count[%d], from_server[%d], handle[%p], err_code[%p]",
+ account_id, mail_ids, mail_ids_count, from_server, handle, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
@@ -599,7 +653,6 @@ INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_
int thread_error = 0;
email_account_t *ref_account = NULL;
email_event_t *event_data = NULL;
- emstorage_mailbox_tbl_t *mailbox_tbl_data = NULL;
thread_t delete_thread;
/* mailbox can be NULL for deleting thread mail. */
@@ -609,11 +662,6 @@ INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_
goto FINISH_OFF;
}
- if ( (err = emstorage_get_mailbox_by_id(mailbox_id, &mailbox_tbl_data)) != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%err]", err);
- goto FINISH_OFF;
- }
-
if ((p = em_malloc(sizeof(int) * mail_ids_count)) == NULL) {
EM_DEBUG_EXCEPTION("em_malloc for p failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -628,8 +676,7 @@ INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox_tbl_data->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed.");
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -641,10 +688,11 @@ INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_
}
event_data->type = EMAIL_EVENT_DELETE_MAIL;
- event_data->account_id = mailbox_tbl_data->account_id;
+ event_data->account_id = account_id;
event_data->event_param_data_3 = (char*)p;
event_data->event_param_data_4 = mail_ids_count;
event_data->event_param_data_5 = from_server;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
THREAD_CREATE(delete_thread, thread_func_to_delete_mail, (void*)event_data, thread_error);
THREAD_DETACH(delete_thread); /* free resources used for new thread */
@@ -652,9 +700,6 @@ INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_ids[], int mail_
FINISH_OFF:
- if (mailbox_tbl_data)
- emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL);
-
if (ref_account) {
emcore_free_account(ref_account);
EM_SAFE_FREE(ref_account);
@@ -672,7 +717,7 @@ FINISH_OFF:
return ret;
}
-int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code)
+int emdaemon_delete_mail_all(char *multi_user_name, int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], input_from_server[%d], handle[%p], err_code[%p]", input_mailbox_id, input_from_server, output_handle, output_err_code);
@@ -687,12 +732,17 @@ int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *o
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl) != EMAIL_ERROR_NONE)) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl) != EMAIL_ERROR_NONE)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
- if(!emcore_delete_all_mails_of_mailbox(mailbox_tbl->account_id, input_mailbox_id, EMAIL_DELETE_LOCALLY, &err)) {
+ if (!emcore_delete_all_mails_of_mailbox(multi_user_name,
+ mailbox_tbl->account_id,
+ input_mailbox_id,
+ 0,
+ EMAIL_DELETE_LOCALLY,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -710,6 +760,7 @@ int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *o
event_data->account_id = mailbox_tbl->account_id;
event_data->event_param_data_4 = input_mailbox_id;
event_data->event_param_data_5 = input_from_server;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)output_handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err);
@@ -717,7 +768,8 @@ int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *o
}
#ifdef __FEATURE_LOCAL_ACTIVITY__
- int i, total = 0 , search_handle = 0;
+ int i, total = 0;
+ DB_STMT search_handle = 0;
int *mail_ids = NULL;
emstorage_activity_tbl_t new_activity;
int activityid = 0;
@@ -726,17 +778,14 @@ int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *o
EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d ", err);
}
- if (!emstorage_mail_search_start(NULL, mailbox->account_id, mailbox->mailbox_name, 0, &search_handle, &total, true, &err)) {
+ if (!emstorage_mail_search_start(multi_user_name, NULL, mailbox->account_id, mailbox->mailbox_name, 0, &search_handle, &total, true, &err)) {
EM_DEBUG_EXCEPTION(" emstorage_mail_search_start failed [%d]", err);
-
-
goto FINISH_OFF;
}
mail_ids = em_malloc(sizeof(int) * total);
if (mail_ids == NULL) {
EM_DEBUG_EXCEPTION(" mailloc failed...");
-
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
@@ -798,6 +847,7 @@ void* thread_func_to_move_mail(void *thread_argument)
int handle = 0;
email_event_t *event_data = (email_event_t*)thread_argument;
int dst_mailbox_id = 0;
+ char *multi_user_name = NULL;
if(!event_data) { /*prevent 53096*/
EM_DEBUG_EXCEPTION("INVALID_PARMAETER");
@@ -811,9 +861,9 @@ void* thread_func_to_move_mail(void *thread_argument)
dst_mailbox_id = event_data->event_param_data_5;
noti_param_1 = event_data->event_param_data_6;
noti_param_2 = event_data->event_param_data_7;
+ multi_user_name = event_data->multi_user_name;
-
- if (!emcore_move_mail(mail_ids, mail_ids_count, dst_mailbox_id, noti_param_1, noti_param_2, &err)) {
+ if (!emcore_move_mail(multi_user_name, mail_ids, mail_ids_count, dst_mailbox_id, noti_param_1, noti_param_2, &err)) {
EM_DEBUG_EXCEPTION("emcore_mail_move failed [%d]", err);
goto FINISH_OFF;
}
@@ -836,7 +886,7 @@ FINISH_OFF:
return SUCCESS;
}
-INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailbox_id, int* err_code)
+INTERNAL_FUNC int emdaemon_move_mail_all_mails(char *multi_user_name, int src_mailbox_id, int dst_mailbox_id, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("src_mailbox_id[%d], dst_mailbox_id[%d], err_code[%p]", src_mailbox_id, dst_mailbox_id, err_code);
@@ -861,25 +911,24 @@ INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailb
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(dst_mailbox_id, &dst_mailbox_tbl)) != EMAIL_ERROR_NONE || !dst_mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, dst_mailbox_id, &dst_mailbox_tbl)) != EMAIL_ERROR_NONE || !dst_mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(src_mailbox_id, &src_mailbox_tbl)) != EMAIL_ERROR_NONE || !src_mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, src_mailbox_id, &src_mailbox_tbl)) != EMAIL_ERROR_NONE || !src_mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(dst_mailbox_tbl->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, dst_mailbox_tbl->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", dst_mailbox_tbl->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if(!emstorage_get_mail_list(src_mailbox_tbl->account_id, src_mailbox_id, NULL, EMAIL_LIST_TYPE_NORMAL, -1, -1, 0, NULL, EMAIL_SORT_DATETIME_HIGH, false, &mail_list, &select_num, &err)) {
+ if(!emstorage_get_mail_list(multi_user_name, src_mailbox_tbl->account_id, src_mailbox_id, NULL, EMAIL_LIST_TYPE_NORMAL, -1, -1, 0, NULL, EMAIL_SORT_DATETIME_HIGH, false, &mail_list, &select_num, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed");
goto FINISH_OFF;
}
@@ -927,6 +976,7 @@ INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailb
event_data->event_param_data_4 = num;
event_data->event_param_data_5 = dst_mailbox_id;
event_data->event_param_data_8 = src_mailbox_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
#ifdef __FEATURE_LOCAL_ACTIVITY__
int i = 0, activityid = 0;
@@ -990,7 +1040,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int* err_code)
+INTERNAL_FUNC int emdaemon_move_mail(char *multi_user_name, int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d], dst_mailbox_id[%d], err_code[%p]", mail_ids, num, dst_mailbox_id, err_code);
@@ -1010,12 +1060,12 @@ INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, int dst_mailbox_id
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(dst_mailbox_id, &dest_mailbox_tbl)) != EMAIL_ERROR_NONE || !dest_mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, dst_mailbox_id, &dest_mailbox_tbl)) != EMAIL_ERROR_NONE || !dest_mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(dest_mailbox_tbl->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, dest_mailbox_tbl->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", dest_mailbox_tbl->account_id);
@@ -1026,9 +1076,8 @@ INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, int dst_mailbox_id
/* Getting source mailbox name */
mail_id = mail_ids[0];
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
+ if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -1059,6 +1108,7 @@ INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, int dst_mailbox_id
event_data->event_param_data_8 = src_mailbox_id;
event_data->event_param_data_6 = noti_param_1;
event_data->event_param_data_7 = noti_param_2;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
#ifdef __FEATURE_LOCAL_ACTIVITY__
int i = 0, activityid = 0;
@@ -1113,9 +1163,12 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int onserver, int* err_code)
+INTERNAL_FUNC int emdaemon_set_flags_field(char *multi_user_name, int account_id, int mail_ids[],
+ int num, email_flags_field_type field_type, int value,
+ int onserver, int* err_code)
{
- EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d], field_type [%d], value[%d], err_code[%p]", mail_ids, num, field_type, value, err_code); /*prevent 27460*/
+ EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d], field_type [%d], value[%d], err_code[%p]",
+ mail_ids, num, field_type, value, err_code); /*prevent 27460*/
int ret = false, err = EMAIL_ERROR_NONE;
emstorage_account_tbl_t *account_tbl = NULL;
@@ -1129,19 +1182,23 @@ INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int n
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_tbl, false, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name,
+ account_id,
+ EMAIL_ACC_GET_OPT_DEFAULT,
+ &account_tbl,
+ false,
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id falled [%d]", err);
goto FINISH_OFF;
}
- if (!emcore_set_flags_field(account_id, mail_ids, num, field_type, value, &err)) {
+ if (!emcore_set_flags_field(multi_user_name, account_id, mail_ids, num, field_type, value, &err)) {
EM_DEBUG_EXCEPTION("emcore_set_flags_field falled [%d]", err);
goto FINISH_OFF;
}
- if( onserver && account_tbl->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 ) {
+ if (onserver && account_tbl->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
mail_id_array = em_malloc(sizeof(int) * num);
-
if (mail_id_array == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -1151,6 +1208,12 @@ INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int n
memcpy(mail_id_array, mail_ids, sizeof(int) * num);
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER;
event_data->account_id = account_id;
event_data->event_param_data_1 = NULL;
@@ -1158,6 +1221,7 @@ INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int n
event_data->event_param_data_4 = num;
event_data->event_param_data_5 = field_type;
event_data->event_param_data_6 = value;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)&handle, &err)) {
EM_DEBUG_LOG("emcore_insert_event failed [%d]", err);
@@ -1179,14 +1243,20 @@ FINISH_OFF:
if (err_code)
*err_code = err;
+
EM_DEBUG_FUNC_END();
return ret;
}
-
-INTERNAL_FUNC int emdaemon_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas)
+INTERNAL_FUNC int emdaemon_update_mail(char *multi_user_name, email_mail_data_t *input_mail_data,
+ email_attachment_data_t *input_attachment_data_list, int input_attachment_count,
+ email_meeting_request_t *input_meeting_request, int input_from_eas)
{
- EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count [%d], input_meeting_req [%p], input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
+ EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], "
+ "input_attachment_count [%d], input_meeting_req [%p], "
+ "input_from_eas[%d]", input_mail_data, input_attachment_data_list,
+ input_attachment_count, input_meeting_request, input_from_eas);
+
int err = EMAIL_ERROR_NONE;
/*email_event_t *event_data = NULL;*/
email_account_t *ref_account = NULL;
@@ -1198,14 +1268,14 @@ INTERNAL_FUNC int emdaemon_update_mail(email_mail_data_t *input_mail_data, email
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(input_mail_data->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, input_mail_data->account_id, false);
if (!ref_account) {
EM_DEBUG_LOG(" emcore_get_account_reference failed [%d]", input_mail_data->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if ( (err = emcore_update_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_update_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -1213,6 +1283,12 @@ INTERNAL_FUNC int emdaemon_update_mail(email_mail_data_t *input_mail_data, email
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
/* if ( input_from_eas == 0) {
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_UPDATE_MAIL;
event_data->account_id = input_mail_data->account_id;
event_data->event_param_data_1 = (char*)input_mail_data; // need to be duplicated, it is double freed
@@ -1220,6 +1296,7 @@ INTERNAL_FUNC int emdaemon_update_mail(email_mail_data_t *input_mail_data, email
event_data->event_param_data_3 = (char*)input_meeting_request; // need to be duplicated, it is double freed
event_data->event_param_data_4 = input_attachment_count;
event_data->event_param_data_5 = input_from_eas;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, &handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event_for_sending_mails failed [%d]", err);
@@ -1242,7 +1319,7 @@ FINISH_OFF:
}
-int _emdaemon_check_mail_id(int mail_id, int* err_code)
+int _emdaemon_check_mail_id(char *multi_user_name, int mail_id, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("mail_id[%d], err_code[%p]", mail_id, err_code);
@@ -1251,7 +1328,7 @@ int _emdaemon_check_mail_id(int mail_id, int* err_code)
emstorage_mail_tbl_t* mail = NULL;
- if (!emstorage_get_mail_field_by_id(mail_id, RETRIEVE_SUMMARY, &mail, true, &err)) {
+ if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_SUMMARY, &mail, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1268,33 +1345,47 @@ FINISH_OFF:
return ret;
}
+typedef struct {
+ int mail_id;
+ char *multi_user_name;
+} email_retry_info;
-INTERNAL_FUNC int emdaemon_send_mail_retry(int mail_id, int timeout_in_sec, int* err_code)
+INTERNAL_FUNC int emdaemon_send_mail_retry(char *multi_user_name, int mail_id, int timeout_in_sec, int* err_code)
{
int ret = false;
int err = EMAIL_ERROR_NONE;
long nTimerValue = 0;
- char mail_id_string[10] = { 0, };
+ email_retry_info *retry_info = NULL;
- if (!_emdaemon_check_mail_id(mail_id, &err)) {
+ if (!_emdaemon_check_mail_id(multi_user_name, mail_id, &err)) {
EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err);
goto FINISH_OFF;
}
- if ( timeout_in_sec == 0 ) {
- if(!emdaemon_send_mail(mail_id, NULL, &err)) {
+ if (timeout_in_sec == 0) {
+ if(!emdaemon_send_mail(multi_user_name, mail_id, NULL, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
goto FINISH_OFF;
}
}
- else if ( timeout_in_sec > 0 ) {
- sprintf(mail_id_string,"%d",mail_id);
+ else if (timeout_in_sec > 0) {
+ retry_info = em_malloc(sizeof(email_retry_info));
+ if (retry_info == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ retry_info->mail_id = mail_id;
+ retry_info->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
nTimerValue = timeout_in_sec * 1000;
- if ( emcore_set_timer_ex(nTimerValue, (EMAIL_TIMER_CALLBACK) _OnMailSendRetryTimerCB, (void*)mail_id_string) <= 0) {
+
+ if (emcore_set_timer_ex(nTimerValue, (EMAIL_TIMER_CALLBACK) _OnMailSendRetryTimerCB, (void*)retry_info) <= 0) {
EM_DEBUG_EXCEPTION("Failed to start timer");
goto FINISH_OFF;
}
}
+
ret = true;
FINISH_OFF:
@@ -1304,37 +1395,39 @@ FINISH_OFF:
return ret;
}
-
-INTERNAL_FUNC void _OnMailSendRetryTimerCB( void* data )
+INTERNAL_FUNC void _OnMailSendRetryTimerCB(void* data)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- int mail_id = 0 ;
+ email_retry_info *retry_info = NULL;
- if( !data ) {
+ if (!data) {
EM_DEBUG_LOG("Invalid param");
- goto FINISH_OFF;
+ return;
}
- mail_id = atoi((char*)data);
+ retry_info = (email_retry_info *)data;
- if (!_emdaemon_check_mail_id(mail_id, &err)) {
+ if (!_emdaemon_check_mail_id(retry_info->multi_user_name, retry_info->mail_id, &err)) {
EM_DEBUG_EXCEPTION("_emdaemon_check_mail_id failed [%d]", err);
goto FINISH_OFF;
}
- if(!emdaemon_send_mail(mail_id, NULL, &err)) {
+ if(!emdaemon_send_mail(retry_info->multi_user_name, retry_info->mail_id, NULL, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
+ free(retry_info->multi_user_name);
+ free(retry_info);
+
EM_DEBUG_FUNC_END();
return;
}
-INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag, int *err_code)
+INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(char *multi_user_name, int thread_id, int target_mailbox_id, int move_always_flag, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("thread_id [%d], target_mailbox_id [%d], move_always_flag [%d], err_code [%p]", thread_id, target_mailbox_id, move_always_flag, err_code);
int ret = false;
@@ -1350,7 +1443,7 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target
goto FINISH_OFF;
}
- if (!emstorage_get_mail_list(0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_DATETIME_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) {
+ if (!emstorage_get_mail_list(multi_user_name, 0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_DATETIME_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
goto FINISH_OFF;
@@ -1370,7 +1463,7 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target
account_id = mail_list[0].account_id;
- if (!emcore_get_mailbox_list(account_id, &target_mailbox_list, &mailbox_count, &err)) {
+ if (!emcore_get_mailbox_list(multi_user_name, account_id, &target_mailbox_list, &mailbox_count, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mailbox_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -1389,7 +1482,7 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target
}
/*
- if (!emdaemon_move_mail(mail_id_list, result_count, target_mailbox->mailbox_id, EMAIL_MOVED_BY_MOVING_THREAD, move_always_flag, &err)) {
+ if (!emdaemon_move_mail(multi_user_name, mail_id_list, result_count, target_mailbox->mailbox_id, EMAIL_MOVED_BY_MOVING_THREAD, move_always_flag, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_move_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -1412,23 +1505,34 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, int *handle, int *err_code)
+INTERNAL_FUNC int emdaemon_delete_mail_thread(char *multi_user_name, int thread_id, int delete_always_flag, int *handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("thread_id [%d], delete_always_flag [%d], err_code [%p]", thread_id, delete_always_flag, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
int account_id = 0;
- int mailbox_id, *mail_id_list = NULL, result_count = 0, i;
+ int *mail_id_list = NULL, result_count = 0, i;
email_mail_list_item_t *mail_list = NULL;
- if (!emstorage_get_mail_list(0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_MAILBOX_ID_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) {
+ if (!emstorage_get_mail_list(multi_user_name,
+ 0,
+ 0,
+ NULL,
+ thread_id,
+ -1,
+ -1,
+ 0,
+ NULL,
+ EMAIL_SORT_MAILBOX_ID_HIGH,
+ true,
+ &mail_list,
+ &result_count,
+ &err) || !mail_list || !result_count) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
-
goto FINISH_OFF;
}
mail_id_list = em_malloc(sizeof(int) * result_count);
-
if (mail_id_list == NULL) {
EM_DEBUG_EXCEPTION("em_malloc failed...");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -1440,11 +1544,10 @@ INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_f
}
account_id = mail_list[0].account_id;
- mailbox_id = mail_list[0].mailbox_id;
// should remove requiring of mailbox information from this function.
// email-service should find mailboxes itself by its mail id.
- if (!emdaemon_delete_mail(mailbox_id, mail_id_list, result_count, false, handle, &err)) {
+ if (!emdaemon_delete_mail(multi_user_name, account_id, mail_id_list, result_count, false, handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_delete_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -1464,7 +1567,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, int *handle, int *err_code)
+INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(char *multi_user_name, int thread_id, int seen_flag, int on_server, int *handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("thread_id [%d], seen_flag [%d], on_server [%d], handle [%p], err_code [%p]", thread_id, seen_flag, on_server, handle, err_code);
int ret = false;
@@ -1472,9 +1575,8 @@ INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_fl
int account_id, *mail_id_list = NULL, result_count = 0, i;
email_mail_list_item_t *mail_list = NULL;
- if (!emstorage_get_mail_list(0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_MAILBOX_ID_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) {
+ if (!emstorage_get_mail_list(multi_user_name, 0, 0, NULL, thread_id, -1, -1, 0, NULL, EMAIL_SORT_MAILBOX_ID_HIGH, true, &mail_list, &result_count, &err) || !mail_list || !result_count) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
-
goto FINISH_OFF;
}
@@ -1492,7 +1594,7 @@ INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_fl
account_id = mail_list[0].account_id;
- if (!emdaemon_set_flags_field(account_id, mail_id_list, result_count, EMAIL_FLAGS_SEEN_FIELD, seen_flag, on_server, &err)) {
+ if (!emdaemon_set_flags_field(multi_user_name, account_id, mail_id_list, result_count, EMAIL_FLAGS_SEEN_FIELD, seen_flag, on_server, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_set_flags_field failed [%d]", err);
goto FINISH_OFF;
}
@@ -1503,16 +1605,18 @@ INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_fl
ret = true;
FINISH_OFF:
+
EM_SAFE_FREE(mail_list);
EM_SAFE_FREE(mail_id_list);
if (err_code)
*err_code = err;
+
EM_DEBUG_FUNC_END();
return ret;
}
-INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle)
+INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(char *multi_user_name, int input_mailbox_id, int input_on_server, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_on_server [%d], output_handle [%p]", input_mailbox_id, input_on_server, output_handle);
int err = EMAIL_ERROR_NONE;
@@ -1528,12 +1632,12 @@ INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, i
goto FINISH_OFF;
}
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox_tbl->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, mailbox_tbl->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", mailbox_tbl->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -1543,9 +1647,16 @@ INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, i
#ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
if(input_on_server) {
event_data = em_malloc(sizeof(email_event_t));
+ if (event_data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
event_data->type = EMAIL_EVENT_EXPUNGE_MAILS_DELETED_FLAGGED;
event_data->account_id = mailbox_tbl->account_id;
event_data->event_param_data_4 = input_mailbox_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, &handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
@@ -1555,7 +1666,7 @@ INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, i
}
else
#endif
- if ( (err = emcore_expunge_mails_deleted_flagged_from_local_storage(input_mailbox_id)) != EMAIL_ERROR_NONE) {
+ if ( (err = emcore_expunge_mails_deleted_flagged_from_local_storage(multi_user_name, input_mailbox_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_expunge_mails_deleted_flagged_from_local_storage failed [%d]", err);
goto FINISH_OFF;
}
@@ -1563,6 +1674,7 @@ INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, i
FINISH_OFF:
if (event_insert == false && event_data) {
+ EM_SAFE_FREE(event_data->multi_user_name);
emcore_free_event(event_data);
EM_SAFE_FREE(event_data);
}
diff --git a/email-daemon/email-daemon-mailbox.c b/email-daemon/email-daemon-mailbox.c
index fa819f2..350f0ad 100755
--- a/email-daemon/email-daemon-mailbox.c
+++ b/email-daemon/email-daemon-mailbox.c
@@ -49,7 +49,11 @@
extern int g_local_activity_run;
#endif
-INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(char *multi_user_name,
+ int account_id,
+ char* mailbox,
+ int *handle,
+ int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d] mailbox[%p] err_code[%p]", account_id, mailbox, err_code);
@@ -73,8 +77,9 @@ INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox,
event_data->type = EMAIL_EVENT_SYNC_IMAP_MAILBOX;
event_data->account_id = account_id;
event_data->event_param_data_3 = EM_SAFE_STRDUP(mailbox);
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
- if (!emcore_insert_event(event_data, (int*)handle, &err)) {
+ if (!emcore_insert_event(event_data, handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
goto FINISH_OFF;
}
@@ -94,7 +99,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count, int* err_code)
+INTERNAL_FUNC int emdaemon_get_mailbox_list(char *multi_user_name, int account_id, email_mailbox_t** mailbox_list, int* count, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], count[%p], err_code[%p]", account_id, mailbox_list, count, err_code);
@@ -108,15 +113,14 @@ INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, email_mailbox_t** ma
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (!emcore_get_mailbox_list(account_id, mailbox_list, count, &err)) {
+ if (!emcore_get_mailbox_list(multi_user_name, account_id, mailbox_list, count, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mailbox_list failed [%d]", err);
goto FINISH_OFF;
}
@@ -137,7 +141,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(email_mailbox_t* mailbox, int* total, int* unseen, int* err_code)
+INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(char *multi_user_name, email_mailbox_t* mailbox, int* total, int* unseen, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p], err_code[%p]", mailbox, total, unseen, err_code);
@@ -152,14 +156,14 @@ INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(email_mailbox_t* mailbox, i
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, mailbox->account_id, false);
if (ref_account == NULL) {
EM_DEBUG_EXCEPTION(" emcore_get_account_reference failed [%d]", mailbox->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (!emcore_get_mail_count(mailbox, total, unseen, &err)) {
+ if (!emcore_get_mail_count(multi_user_name, mailbox, total, unseen, &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_count failed [%d]", err);
goto FINISH_OFF;
}
@@ -180,7 +184,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_add_mailbox(char *multi_user_name, email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("new_mailbox[%p], err_code[%p]", new_mailbox, err_code);
@@ -197,8 +201,7 @@ INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_serv
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(new_mailbox->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, new_mailbox->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", new_mailbox->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -244,13 +247,14 @@ INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_serv
event_data->account_id = new_mailbox->account_id;
event_data->event_param_data_1 = (char*)mailbox;
event_data->event_param_data_4 = on_server;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if(!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
goto FINISH_OFF;
}
} else { /* sync */
- if (!emcore_create_mailbox(new_mailbox, on_server, -1, -1, &err)) {
+ if (!emcore_create_mailbox(multi_user_name, new_mailbox, on_server, -1, -1, &err)) {
EM_DEBUG_EXCEPTION("emcore_create failed [%d]", err);
goto FINISH_OFF;
}
@@ -282,7 +286,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type)
+INTERNAL_FUNC int emdaemon_set_mailbox_type(char *multi_user_name, int input_mailbox_id, email_mailbox_type_e input_mailbox_type)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_type [%d]", input_mailbox_id, input_mailbox_type);
@@ -296,18 +300,19 @@ INTERNAL_FUNC int emdaemon_set_mailbox_type(int input_mailbox_id, email_mailbox_
goto FINISH_OFF;
}
- if ( (err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
+ if ( (err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_update_mailbox_type(mailbox_tbl->account_id, -1, input_mailbox_id, input_mailbox_type, true, &err)) {
+ if (!emstorage_update_mailbox_type(multi_user_name, mailbox_tbl->account_id, -1, input_mailbox_id, input_mailbox_type, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_update_mailbox failed [%d]", err);
goto FINISH_OFF;
}
FINISH_OFF:
+
if (mailbox_tbl)
emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
@@ -315,7 +320,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emdaemon_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox)
+INTERNAL_FUNC int emdaemon_set_local_mailbox(char *multi_user_name, int input_mailbox_id, int input_is_local_mailbox)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id [%d], input_mailbox_type [%d]", input_mailbox_id, input_is_local_mailbox);
@@ -328,7 +333,7 @@ INTERNAL_FUNC int emdaemon_set_local_mailbox(int input_mailbox_id, int input_is_
goto FINISH_OFF;
}
- if ( (err = emstorage_set_local_mailbox(input_mailbox_id, input_is_local_mailbox, true)) != EMAIL_ERROR_NONE) {
+ if ( (err = emstorage_set_local_mailbox(multi_user_name, input_mailbox_id, input_is_local_mailbox, true)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_set_local_mailbox failed [%d]", err);
goto FINISH_OFF;
}
@@ -340,7 +345,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_mailbox(char *multi_user_name, int input_mailbox_id, int on_server, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], err_code[%p]", input_mailbox_id, err_code);
@@ -351,7 +356,7 @@ INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, i
email_account_t *ref_account = NULL;
email_event_t *event_data = NULL;
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed. [%d]", err);
goto FINISH_OFF;
}
@@ -363,8 +368,7 @@ INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, i
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox_tbl->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, mailbox_tbl->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", mailbox_tbl->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -390,12 +394,14 @@ INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, i
event_data->event_param_data_4 = input_mailbox_id;
event_data->event_param_data_5 = on_server;
event_data->event_param_data_6 = recursive;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
if(!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
goto FINISH_OFF;
}
} else {
- if (!emcore_delete_mailbox(input_mailbox_id, on_server, recursive)) {
+ if (!emcore_delete_mailbox(multi_user_name, input_mailbox_id, on_server, recursive)) {
EM_DEBUG_EXCEPTION("emcore_delete failed [%d]", err);
goto FINISH_OFF;
}
@@ -421,7 +427,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_delete_mailbox_all(email_mailbox_t* mailbox, int* err_code)
+INTERNAL_FUNC int emdaemon_delete_mailbox_all(char *multi_user_name, email_mailbox_t* mailbox, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("malibox[%p], err_code[%p]", mailbox, err_code);
@@ -441,15 +447,14 @@ INTERNAL_FUNC int emdaemon_delete_mailbox_all(email_mailbox_t* mailbox, int* err
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(mailbox->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, mailbox->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", mailbox->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (!emcore_delete_mailbox_all(mailbox, &err)) {
+ if (!emcore_delete_mailbox_all(multi_user_name, mailbox, &err)) {
EM_DEBUG_EXCEPTION("emcore_delete_all failed [%d]", err);
goto FINISH_OFF;
}
@@ -470,7 +475,7 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, int *handle, int* err_code)
+INTERNAL_FUNC int emdaemon_sync_header(char *multi_user_name, int input_account_id, int input_mailbox_id, int *handle, int* err_code)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d], input_mailbox_id[%d], handle[%p], err_code[%p]", input_account_id, input_mailbox_id, handle, err_code);
@@ -496,6 +501,8 @@ INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_i
event_data->type = EMAIL_EVENT_SYNC_HEADER;
event_data->account_id = input_account_id;
event_data->event_param_data_5 = input_mailbox_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
/* In case of Mailbox NULL, we need to set arg as EMAIL_SYNC_ALL_MAILBOX */
if (input_mailbox_id == 0)
event_data->event_param_data_4 = EMAIL_SYNC_ALL_MAILBOX;
@@ -509,6 +516,8 @@ INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_i
event_data->type = EMAIL_EVENT_SYNC_HEADER;
event_data->account_id = input_account_id;
event_data->event_param_data_5 = input_mailbox_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
/* In case of Mailbox NULL, we need to set arg as EMAIL_SYNC_ALL_MAILBOX */
if (input_mailbox_id == 0)
event_data->event_param_data_4 = EMAIL_SYNC_ALL_MAILBOX;
@@ -526,7 +535,7 @@ INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_i
if (!emcore_notify_network_event(NOTI_DOWNLOAD_START, input_account_id, ((input_mailbox_id==0)? NULL:input_mailbox_id_str), *handle, 0))
EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_START] Failed >>>> ");
-/* if ((err = emcore_update_sync_status_of_account(input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
+/* if ((err = emcore_update_sync_status_of_account(multi_user_name, input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
*/
@@ -547,12 +556,11 @@ FINISH_OFF:
if (err_code)
*err_code = err;
-
EM_DEBUG_FUNC_END();
return ret;
}
-INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, int *handle, int *err_code)
+INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int *handle, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d], mailbox_id[%d], handle[%p], err_code[%p]", account_id, mailbox_id, handle, err_code);
@@ -577,6 +585,7 @@ INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mai
event_data->account_id = account_id;
event_data->event_param_data_4 = mailbox_id;
event_data->event_param_data_5 = new_slot_size;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err);
@@ -598,7 +607,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int *output_handle)
+INTERNAL_FUNC int emdaemon_rename_mailbox(char *multi_user_name, int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int *output_handle)
{
EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d] input_mailbox_path[%p] input_mailbox_alias[%p] input_eas_data[%p] input_eas_data_length[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_mailbox_path, input_mailbox_alias, input_eas_data, input_eas_data_length, input_on_server, output_handle);
@@ -615,12 +624,12 @@ INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mail
}
if (input_on_server) {
- if ((err = emstorage_get_mailbox_by_id(input_mailbox_id, &old_mailbox_data)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &old_mailbox_data)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
goto FINISH_OFF;
}
- if (!emstorage_get_account_by_id(old_mailbox_data->account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_data, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, old_mailbox_data->account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account_data, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -639,6 +648,7 @@ INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mail
event_data->event_param_data_3 = EM_SAFE_STRDUP(input_mailbox_alias);
event_data->event_param_data_4 = input_mailbox_id;
event_data->account_id = old_mailbox_data->account_id;
+ event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
if (!emcore_insert_event(event_data, (int*)output_handle, &err)) {
EM_DEBUG_EXCEPTION("emcore_insert_event falied [%d]", err);
@@ -646,7 +656,7 @@ INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mail
}
}
} else {
- if ((err = emcore_rename_mailbox(input_mailbox_id, input_mailbox_path, input_mailbox_alias, input_eas_data, input_eas_data_length, false, true, 0)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_rename_mailbox(multi_user_name, input_mailbox_id, input_mailbox_path, input_mailbox_alias, input_eas_data, input_eas_data_length, false, true, 0)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_rename_mailbox failed [%d]", err);
goto FINISH_OFF;
}
diff --git a/email-daemon/include/email-daemon-auto-poll.h b/email-daemon/include/email-daemon-auto-poll.h
index 90e08e4..3910ecf 100755
--- a/email-daemon/include/email-daemon-auto-poll.h
+++ b/email-daemon/include/email-daemon-auto-poll.h
@@ -41,7 +41,7 @@ extern "C"
#endif /* __cplusplus */
-INTERNAL_FUNC int emdaemon_add_polling_alarm(int account_id);
+INTERNAL_FUNC int emdaemon_add_polling_alarm(char *multi_user_name, int account_id);
INTERNAL_FUNC int emdaemon_remove_polling_alarm(int account_id);
INTERNAL_FUNC int emdaemon_check_auto_polling_started(int account_id);
INTERNAL_FUNC int emdaemon_free_account_alarm_binder_list();
diff --git a/email-daemon/include/email-daemon.h b/email-daemon/include/email-daemon.h
index cda4b71..865efc7 100755
--- a/email-daemon/include/email-daemon.h
+++ b/email-daemon/include/email-daemon.h
@@ -51,7 +51,7 @@ extern "C"
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_initialize(int* err_code);
+INTERNAL_FUNC int emdaemon_initialize(char *multi_user_name, int* err_code);
/**
* Finalize Email-engine.
@@ -74,7 +74,7 @@ INTERNAL_FUNC int emdaemon_finalize(int* err_code);
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_create_account(email_account_t* account, int* err_code);
+INTERNAL_FUNC int emdaemon_create_account(char *multi_user_name, email_account_t* account, int* err_code);
/**
* Delete a email account.
@@ -84,7 +84,7 @@ INTERNAL_FUNC int emdaemon_create_account(email_account_t* account, int* err_cod
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_account(int account_id, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_account(char *multi_user_name, int account_id, int* err_code);
/**
* Validate a email account.
@@ -94,9 +94,9 @@ INTERNAL_FUNC int emdaemon_delete_account(int account_id, int* err_code);
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_validate_account(int account_id, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_validate_account(char *multi_user_name, int account_id, int *handle, int* err_code);
-INTERNAL_FUNC int emdaemon_validate_account_ex(email_account_t* account, int *handle);
+INTERNAL_FUNC int emdaemon_validate_account_ex(char *multi_user_name, email_account_t* account, int *handle);
/**
* Change the information of a email account.
@@ -107,7 +107,7 @@ INTERNAL_FUNC int emdaemon_validate_account_ex(email_account_t* account, int *ha
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_account, int* err_code);
+INTERNAL_FUNC int emdaemon_update_account(char *multi_user_name, int account_id, email_account_t* new_account, int* err_code);
/**
* Change the information of a email account after validation
@@ -119,7 +119,7 @@ INTERNAL_FUNC int emdaemon_update_account(int account_id, email_account_t* new_a
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email_account_t* new_account_info, int *handle,int *err_code);
+INTERNAL_FUNC int emdaemon_validate_account_and_update(char *multi_user_name, int old_account_id, email_account_t* new_account_info, int *handle,int *err_code);
/**
* Get a email account by ID.
@@ -131,7 +131,7 @@ INTERNAL_FUNC int emdaemon_validate_account_and_update(int old_account_id, email
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, email_account_t* acount, int* err_code);
+INTERNAL_FUNC int emdaemon_get_account(char *multi_user_name, int account_id, int pulloption, email_account_t* acount, int* err_code);
/**
* Get all emails.
@@ -142,7 +142,7 @@ INTERNAL_FUNC int emdaemon_get_account(int account_id, int pulloption, email_acc
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_get_account_list(email_account_t** acount_list, int* count, int* err_code);
+INTERNAL_FUNC int emdaemon_get_account_list(char *multi_user_name, email_account_t** acount_list, int* count, int* err_code);
/**
* Free allocated memory.
@@ -164,7 +164,7 @@ INTERNAL_FUNC int emdaemon_free_account(email_account_t** account_list, int coun
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filtering_set, int* err_code);
+INTERNAL_FUNC int emdaemon_get_filter(char *multi_user_name, int filter_id, email_rule_t** filtering_set, int* err_code);
/**
* Get all filterings.
@@ -175,7 +175,7 @@ INTERNAL_FUNC int emdaemon_get_filter(int filter_id, email_rule_t** filtering_se
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_get_filter_list(email_rule_t** filtering_set, int* count, int* err_code);
+INTERNAL_FUNC int emdaemon_get_filter_list(char *multi_user_name, email_rule_t** filtering_set, int* count, int* err_code);
/**
* find a filter already exists.
@@ -185,7 +185,7 @@ INTERNAL_FUNC int emdaemon_get_filter_list(email_rule_t** filtering_set, int* co
* @remarks N/A
* @return This function returns true if enable add filter, else returns false.
*/
-INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code);
+INTERNAL_FUNC int emdaemon_find_filter(char *multi_user_name, email_rule_t* filter_info, int* err_code);
/**
* Add a filter information.
@@ -194,7 +194,7 @@ INTERNAL_FUNC int emdaemon_find_filter(email_rule_t* filter_info, int* err_code)
* @remarks N/A
* @return This function returns true on success or false on failure.(only EMAIL_FILTER_BLOCK supported.)
*/
-INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filtering_set);
+INTERNAL_FUNC int emdaemon_add_filter(char *multi_user_name, email_rule_t* filtering_set);
/**
* Change a filter information.
@@ -205,7 +205,7 @@ INTERNAL_FUNC int emdaemon_add_filter(email_rule_t* filtering_set);
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_update_filter(int filter_id, email_rule_t* new_set, int* err_code);
+INTERNAL_FUNC int emdaemon_update_filter(char *multi_user_name, int filter_id, email_rule_t* new_set, int* err_code);
/**
* Delete a filter information.
@@ -215,7 +215,7 @@ INTERNAL_FUNC int emdaemon_update_filter(int filter_id, email_rule_t* new_set, i
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_filter(int filter_id, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_filter(char *multi_user_name, int filter_id, int* err_code);
/**
* Free allocated memory.
@@ -236,7 +236,7 @@ INTERNAL_FUNC int emdaemon_free_filter (email_rule_t** filtering_set, int count,
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_apply_filter(int filter_id, int* err_code);
+INTERNAL_FUNC int emdaemon_apply_filter(char *multi_user_name, int filter_id, int* err_code);
/*****************************************************************************/
/* Mail */
@@ -252,7 +252,7 @@ INTERNAL_FUNC int emdaemon_apply_filter(int filter_id, int* err_code);
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_send_mail(char *multi_user_name, int mail_id, int *handle, int* err_code);
/**
* Send all mails to been saved in Offline-mode.
@@ -264,16 +264,16 @@ INTERNAL_FUNC int emdaemon_send_mail(int mail_id, int *handle, int* err_code);
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_send_mail_saved(int account_id, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_send_mail_saved(char *multi_user_name, int account_id, int *handle, int* err_code);
-INTERNAL_FUNC int emdaemon_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas);
+INTERNAL_FUNC int emdaemon_add_mail(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas);
-INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code);
+INTERNAL_FUNC int emdaemon_add_meeting_request(char *multi_user_name, int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int* err_code);
/**
* Delete a mail or multiple mails.
*
- * @param[in] mailbox_id Specifies the mailbox.
+ * @param[in] account_id Specifies the account.
* @param[in] mail_id Specifies the arrary of mail id.
* @param[in] num Specifies the number of mail id.
* @param[in] from_server Specifies whether mails are deleted from server.
@@ -284,7 +284,7 @@ INTERNAL_FUNC int emdaemon_add_meeting_request(int account_id, int input_mailbox
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_id[], int num, int from_server, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_mail(char *multi_user_name, int account_id, int mail_id[], int num, int from_server, int *handle, int* err_code);
/**
* Delete all mail from a mailbox.
@@ -296,7 +296,7 @@ INTERNAL_FUNC int emdaemon_delete_mail(int mailbox_id, int mail_id[], int num, i
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code);
+INTERNAL_FUNC int emdaemon_delete_mail_all(char *multi_user_name, int input_mailbox_id, int input_from_server, int *output_handle, int *output_err_code);
/**
* Move a email to another mailbox.
@@ -310,7 +310,7 @@ INTERNAL_FUNC int emdaemon_delete_mail_all(int input_mailbox_id, int input_from_
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int* err_code);
+INTERNAL_FUNC int emdaemon_move_mail(char *multi_user_name, int mail_ids[], int num, int dst_mailbox_id, int noti_param_1, int noti_param_2, int* err_code);
/**
* Move all email to another mailbox.
@@ -322,7 +322,7 @@ INTERNAL_FUNC int emdaemon_move_mail(int mail_ids[], int num, int dst_mailbox_id
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailbox_id, int* err_code);
+INTERNAL_FUNC int emdaemon_move_mail_all_mails(char *multi_user_name, int src_mailbox_id, int dst_mailbox_id, int* err_code);
/**
@@ -336,7 +336,7 @@ INTERNAL_FUNC int emdaemon_move_mail_all_mails(int src_mailbox_id, int dst_mailb
* @remarks N/A
* @return This function returns EMAIL_ERROR_NONE on success or error code on failure.
*/
-INTERNAL_FUNC int emdaemon_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas);
+INTERNAL_FUNC int emdaemon_update_mail(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t *input_meeting_request, int input_from_eas);
/**
@@ -359,7 +359,7 @@ INTERNAL_FUNC void _OnMailSendRetryTimerCB( void* data );
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_download_body(char *multi_user_name, int account_id, int mail_id, int verbose, int with_attachment, int *handle, int* err_code);
/**
* Get a mail attachment.
@@ -371,7 +371,7 @@ INTERNAL_FUNC int emdaemon_download_body(int account_id, int mail_id, int verbos
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_get_attachment(int attachment_id, email_attachment_data_t** attachment, int* err_code);
+INTERNAL_FUNC int emdaemon_get_attachment(char *multi_user_name, int attachment_id, email_attachment_data_t** attachment, int* err_code);
/**
* Download a email nth-attachment from server.
@@ -385,7 +385,7 @@ INTERNAL_FUNC int emdaemon_get_attachment(int attachment_id, email_attachment_da
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int nth, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_download_attachment(char *multi_user_name, int account_id, int mail_id, int nth, int *handle, int* err_code);
/**
@@ -397,7 +397,7 @@ INTERNAL_FUNC int emdaemon_download_attachment(int account_id, int mail_id, int
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_add_attachment(int mail_id, email_attachment_data_t* attachment, int* err_code);
+INTERNAL_FUNC int emdaemon_add_attachment(char *multi_user_name, int mail_id, email_attachment_data_t* attachment, int* err_code);
/**
* Delete a attachment from email.
@@ -408,7 +408,7 @@ INTERNAL_FUNC int emdaemon_add_attachment(int mail_id, email_attachment_data_t*
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mail_attachment(int attachment_id, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_mail_attachment(char *multi_user_name, int attachment_id, int* err_code);
/**
* Free allocated memroy for email attachment.
@@ -432,12 +432,12 @@ INTERNAL_FUNC int emdaemon_free_attachment_data(email_attachment_data_t** atch_i
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_set_flags_field(int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int onserver, int* err_code);
+INTERNAL_FUNC int emdaemon_set_flags_field(char *multi_user_name, int account_id, int mail_ids[], int num, email_flags_field_type field_type, int value, int onserver, int* err_code);
/*****************************************************************************/
/* Mailbox */
/*****************************************************************************/
-INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(char *multi_user_name, int account_id, char* mailbox, int *handle, int* err_code);
/**
* Download header of new emails from mail server.
@@ -449,7 +449,7 @@ INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(int account_id, char* mailbox,
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_id, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_sync_header(char *multi_user_name, int input_account_id, int input_mailbox_id, int *handle, int* err_code);
/**
@@ -462,7 +462,7 @@ INTERNAL_FUNC int emdaemon_sync_header(int input_account_id, int input_mailbox_i
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(email_mailbox_t* mailbox, int* total, int* unseen, int* err_code);
+INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(char *multi_user_name, email_mailbox_t* mailbox, int* total, int* unseen, int* err_code);
/**
* Get all mailboxes from account.
@@ -474,7 +474,7 @@ INTERNAL_FUNC int emdaemon_get_mail_count_of_mailbox(email_mailbox_t* mailbox, i
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count, int* err_code);
+INTERNAL_FUNC int emdaemon_get_mailbox_list(char *multi_user_name, int account_id, email_mailbox_t** mailbox_list, int* count, int* err_code);
/**
* Create a new mailbox.
@@ -485,7 +485,7 @@ INTERNAL_FUNC int emdaemon_get_mailbox_list(int account_id, email_mailbox_t** ma
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_add_mailbox(char *multi_user_name, email_mailbox_t* new_mailbox, int on_server, int *handle, int* err_code);
/**
* Delete a mailbox.
@@ -496,7 +496,7 @@ INTERNAL_FUNC int emdaemon_add_mailbox(email_mailbox_t* new_mailbox, int on_serv
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_mailbox(char *multi_user_name, int input_mailbox_id, int on_server, int *handle, int* err_code);
/**
* Delete all sub-mailboxes from a specific mailbox.
@@ -506,7 +506,7 @@ INTERNAL_FUNC int emdaemon_delete_mailbox(int input_mailbox_id, int on_server, i
* @remarks N/A
* @return This function returns true on success or false on failure.
*/
-INTERNAL_FUNC int emdaemon_delete_mailbox_all(email_mailbox_t* mailbox, int* err_code);
+INTERNAL_FUNC int emdaemon_delete_mailbox_all(char *multi_user_name, email_mailbox_t* mailbox, int* err_code);
/**
* Free allocated memory for mailbox information.
@@ -602,36 +602,36 @@ INTERNAL_FUNC int emdaemon_sync_local_activity(int account_id, int *err_code);
#ifdef __FEATURE_AUTO_POLLING__
-INTERNAL_FUNC int emdaemon_start_auto_polling(int* err_code);
+INTERNAL_FUNC int emdaemon_start_auto_polling(char *multi_user_name, int* err_code);
#endif /* __FEATURE_AUTO_POLLING__ */
INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(email_account_t* account);
INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_account, email_account_t* new_account);
-INTERNAL_FUNC int emdaemon_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type);
+INTERNAL_FUNC int emdaemon_set_mailbox_type(char *multi_user_name, int input_mailbox_id, email_mailbox_type_e input_mailbox_type);
-INTERNAL_FUNC int emdaemon_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox);
+INTERNAL_FUNC int emdaemon_set_local_mailbox(char *multi_user_name, int input_mailbox_id, int input_is_local_mailbox);
-INTERNAL_FUNC int emdaemon_search_mail_on_server(int input_account_id, int input_mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, unsigned int *output_handle, int *err_code);
+INTERNAL_FUNC int emdaemon_search_mail_on_server(char *multi_user_name, int input_account_id, int input_mailbox_id, email_search_filter_t *input_search_filter, int input_search_filter_count, unsigned int *output_handle, int *err_code);
-INTERNAL_FUNC int emdaemon_clear_all_mail_data(int* err_code);
+INTERNAL_FUNC int emdaemon_clear_all_mail_data(char *multi_user_name, int* err_code);
-INTERNAL_FUNC int emdaemon_send_mail_retry( int mail_id, int timeout_in_sec, int* err_code);
+INTERNAL_FUNC int emdaemon_send_mail_retry(char *multi_user_name, int mail_id, int timeout_in_sec, int* err_code);
-INTERNAL_FUNC int emdaemon_validate_account_and_create(email_account_t* new_account, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_validate_account_and_create(char *multi_user_name, email_account_t* new_account, int *handle, int* err_code);
-INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(int account_id, int mailbox_id, int new_slot_size, int *handle, int *err_code);
+INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int *handle, int *err_code);
-INTERNAL_FUNC int emdaemon_rename_mailbox(int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int *output_handle);
+INTERNAL_FUNC int emdaemon_rename_mailbox(char *multi_user_name, int input_mailbox_id, char *input_mailbox_path, char *input_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int *output_handle);
-INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag, int *err_code);
+INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(char *multi_user_name, int thread_id, int target_mailbox_id, int move_always_flag, int *err_code);
-INTERNAL_FUNC int emdaemon_delete_mail_thread(int thread_id, int delete_always_flag, int *handle, int *err_code);
+INTERNAL_FUNC int emdaemon_delete_mail_thread(char *multi_user_name, int thread_id, int delete_always_flag, int *handle, int *err_code);
-INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server, int *handle, int *err_code);
+INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(char *multi_user_name, int thread_id, int seen_flag, int on_server, int *handle, int *err_code);
-INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle);
+INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(char *multi_user_name, int input_mailbox_id, int input_on_server, int *output_handle);
INTERNAL_FUNC int emdaemon_check_smack_rule(int app_sockfd, char *file_path);
@@ -639,9 +639,9 @@ INTERNAL_FUNC int emdaemon_set_smack_label(char *file_path, char *label);
INTERNAL_FUNC void emdaemon_start_alert(void);
-INTERNAL_FUNC int emdaemon_finalize_sync(int account_id, int total_mail_count, int unread_mail_count, int vip_total_mail_count, int vip_unread_mail_count, int from_app, int *error);
+INTERNAL_FUNC int emdaemon_finalize_sync(char *multi_user_name, int account_id, int total_mail_count, int unread_mail_count, int vip_total_mail_count, int vip_unread_mail_count, int from_app, int *error);
-INTERNAL_FUNC int emdaemon_query_smtp_mail_size_limit(int account_id, int *handle, int* err_code);
+INTERNAL_FUNC int emdaemon_query_smtp_mail_size_limit(char *multi_user_name, int account_id, int *handle, int* err_code);
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/email-daemon/main.c b/email-daemon/main.c
index d7b3d92..ed76d86 100755
--- a/email-daemon/main.c
+++ b/email-daemon/main.c
@@ -59,6 +59,7 @@
#include "email-core-gmime.h"
#include "email-storage.h"
#include "email-dbus-activation.h"
+#include "email-core-container.h"
void stb_create_account(HIPC_API a_hAPI)
{
@@ -69,6 +70,13 @@ void stb_create_account(HIPC_API a_hAPI)
email_account_t account;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_name failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* Initialize the email_account_t */
memset(&account, 0x00, sizeof(email_account_t));
@@ -81,11 +89,13 @@ void stb_create_account(HIPC_API a_hAPI)
local_account_stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0);
/* Convert account stream to structure */
em_convert_byte_stream_to_account(local_account_stream, buffer_size, &account);
+ account.user_name = EM_SAFE_STRDUP(multi_user_name);
EM_DEBUG_LOG_SEC("Account name - %s", account.account_name);
EM_DEBUG_LOG_SEC("Email Address - %s", account.user_email_address);
+ EM_DEBUG_LOG("Multi user name - %s", account.user_name);
- if(!emdaemon_create_account(&account, &err)) {
+ if(!emdaemon_create_account(multi_user_name, &account, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_create_account fail ");
goto FINISH_OFF;
}
@@ -94,7 +104,7 @@ void stb_create_account(HIPC_API a_hAPI)
#ifdef __FEATURE_AUTO_POLLING__
/* start auto polling, if check_interval not zero */
if(account.check_interval > 0 || (account.peak_days > 0 && account.peak_interval > 0)) {
- if(!emdaemon_add_polling_alarm(account.account_id))
+ if(!emdaemon_add_polling_alarm(multi_user_name, account.account_id))
EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[NOTI_ACCOUNT_ADD] : start auto poll failed >>> ");
}
#ifdef __FEATURE_IMAP_IDLE__
@@ -114,8 +124,6 @@ void stb_create_account(HIPC_API a_hAPI)
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(account.account_id), sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
- emcore_add_account_reference(&account);
-
FINISH_OFF:
if ( local_result == 0 ) {
@@ -139,6 +147,7 @@ FINISH_OFF:
EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_ADD] : Notification failed");
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -149,6 +158,13 @@ void stb_delete_account(HIPC_API a_hAPI)
int local_result = 0;
int *ret_nth_value = NULL;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
if ((ret_nth_value = (int *)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0)))
@@ -157,10 +173,11 @@ void stb_delete_account(HIPC_API a_hAPI)
err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
goto FINISH_OFF;
}
-
- if(!emdaemon_delete_account(account_id, &err)) {
+
+ if(!emdaemon_delete_account(multi_user_name, account_id, &err)) {
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
EM_DEBUG_LOG("emipc_add_parameter failed ");
+
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
@@ -190,6 +207,7 @@ void stb_delete_account(HIPC_API a_hAPI)
FINISH_OFF:
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -202,6 +220,13 @@ void stb_update_account(HIPC_API a_hAPI)
email_account_t new_account_info = {0};
int err = EMAIL_ERROR_NONE;
int handle = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
if ((ret_nth_value = (int *)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0)))
account_id = *ret_nth_value;
@@ -209,6 +234,7 @@ void stb_update_account(HIPC_API a_hAPI)
err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
goto FINISH_OFF;
}
+
/* get account structure from stream */
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 1);
EM_DEBUG_LOG("size [%d]", buffer_size);
@@ -224,13 +250,13 @@ void stb_update_account(HIPC_API a_hAPI)
}
if(with_validation) {
- if(!emdaemon_validate_account_and_update(account_id, &new_account_info, &handle, &err)){
+ if(!emdaemon_validate_account_and_update(multi_user_name, account_id, &new_account_info, &handle, &err)){
EM_DEBUG_EXCEPTION("emdaemon_validate_account_and_update failed [%d]", err);
goto FINISH_OFF;
}
}
else {
- if(!emdaemon_update_account(account_id, &new_account_info, &err)) {
+ if(!emdaemon_update_account(multi_user_name, account_id, &new_account_info, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_update_account failed [%d]", err);
goto FINISH_OFF;
}
@@ -247,8 +273,7 @@ FINISH_OFF:
emcore_free_account(&new_account_info);
- emcore_init_account_reference();
-
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -260,16 +285,23 @@ void stb_validate_account(HIPC_API a_hAPI)
int local_result = 0;
int err_code = 0;
int handle = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err_code = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err_code);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
- local_result = emdaemon_validate_account(account_id, &handle,&err_code);
+ local_result = emdaemon_validate_account(multi_user_name, account_id, &handle, &err_code);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
EM_DEBUG_LOG("emipc_add_parameter failed ");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
@@ -277,6 +309,7 @@ void stb_validate_account(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -292,8 +325,15 @@ void stb_get_account_list(HIPC_API a_hAPI)
int count;
int size = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
- if(emdaemon_get_account_list(&account_list, &count, &err)) {
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
+ if(emdaemon_get_account_list(multi_user_name, &account_list, &count, &err)) {
EM_DEBUG_LOG("emdaemon_get_account_list success");
local_result = 1;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
@@ -337,6 +377,7 @@ void stb_get_account_list(HIPC_API a_hAPI)
}
EM_SAFE_FREE(local_stream);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -347,6 +388,13 @@ void stb_sync_header(HIPC_API a_hAPI)
int err = EMAIL_ERROR_NONE;
int handle = -1;
int account_id = 0, maibox_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
@@ -354,7 +402,7 @@ void stb_sync_header(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &maibox_id);
EM_DEBUG_LOG("account_id [%d] maibox_id [%d]", account_id, maibox_id);
- if(!emdaemon_sync_header(account_id, maibox_id, &handle, &err)) {
+ if(!emdaemon_sync_header(multi_user_name, account_id, maibox_id, &handle, &err)) {
EM_DEBUG_EXCEPTION ("emdaemon_sync_header failed [%d]", err);
}
@@ -364,6 +412,8 @@ void stb_sync_header(HIPC_API a_hAPI)
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -375,6 +425,13 @@ void stb_download_body(HIPC_API a_hAPI)
int attachment_count = 0;
int handle = 0;
int account_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* Account Id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
@@ -386,7 +443,7 @@ void stb_download_body(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &attachment_count);
/*Download Body */
- if (!emdaemon_download_body(account_id, mail_id, 1, attachment_count, &handle, &err)) {
+ if (!emdaemon_download_body(multi_user_name, account_id, mail_id, 1, attachment_count, &handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_download_body - failed");
goto FINISH_OFF;
}
@@ -396,12 +453,16 @@ void stb_download_body(HIPC_API a_hAPI)
FINISH_OFF:
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
+ EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
+
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
+
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END();
}
@@ -416,6 +477,13 @@ void stb_create_mailbox(HIPC_API a_hAPI)
int on_server = 0;
email_mailbox_t mailbox = { 0 };
int handle = 0; /* Added for cancelling mailbox creating */
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
EM_DEBUG_LOG("size [%d]", buffer_size);
@@ -435,11 +503,12 @@ void stb_create_mailbox(HIPC_API a_hAPI)
else
err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
- emdaemon_add_mailbox(&mailbox, on_server, &handle, &err);
+ emdaemon_add_mailbox(multi_user_name, &mailbox, on_server, &handle, &err);
FINISH_OFF:
emcore_free_mailbox(&mailbox);
+ EM_SAFE_FREE(multi_user_name);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
@@ -464,6 +533,13 @@ void stb_delete_mailbox(HIPC_API a_hAPI)
int on_server = 0;
int handle = 0; /* Added for cancelling mailbox deleting */
int input_mailbox_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* src_mailbox_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &input_mailbox_id);
@@ -476,7 +552,7 @@ void stb_delete_mailbox(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &on_server);
- if(emdaemon_delete_mailbox(input_mailbox_id, on_server, &handle, &err))
+ if(emdaemon_delete_mailbox(multi_user_name, input_mailbox_id, on_server, &handle, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -487,6 +563,7 @@ void stb_delete_mailbox(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -496,6 +573,13 @@ void stb_set_mailbox_type(HIPC_API a_hAPI)
int err = EMAIL_ERROR_NONE;
int mailbox_id = 0;
int mailbox_type = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
@@ -503,7 +587,7 @@ void stb_set_mailbox_type(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_type);
EM_DEBUG_LOG("mailbox_type[%d]", mailbox_type);
- if( (err = emdaemon_set_mailbox_type(mailbox_id, mailbox_type)) != EMAIL_ERROR_NONE)
+ if( (err = emdaemon_set_mailbox_type(multi_user_name, mailbox_id, mailbox_type)) != EMAIL_ERROR_NONE)
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -512,6 +596,7 @@ void stb_set_mailbox_type(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -521,6 +606,13 @@ void stb_set_local_mailbox(HIPC_API a_hAPI)
int err = EMAIL_ERROR_NONE;
int mailbox_id = 0;
int is_local_mailbox = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
@@ -528,7 +620,7 @@ void stb_set_local_mailbox(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &is_local_mailbox);
EM_DEBUG_LOG("is_local_mailbox[%d]", is_local_mailbox);
- if( (err = emdaemon_set_local_mailbox(mailbox_id, is_local_mailbox)) != EMAIL_ERROR_NONE)
+ if( (err = emdaemon_set_local_mailbox(multi_user_name, mailbox_id, is_local_mailbox)) != EMAIL_ERROR_NONE)
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -537,6 +629,35 @@ void stb_set_local_mailbox(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_FUNC_END();
+}
+
+void stb_stamp_sync_time_of_mailbox(HIPC_API a_hAPI)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ int mailbox_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
+ EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
+
+ err = emstorage_stamp_last_sync_time_of_mailbox(multi_user_name, mailbox_id, 1);
+
+ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
+
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -548,17 +669,24 @@ void stb_set_mail_slot_size_of_mailbox(HIPC_API a_hAPI)
int account_id = 0;
int mailbox_id = 0;
int mail_slot_size = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
EM_DEBUG_LOG("account_id[%d]", account_id);
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_id);
- EM_DEBUG_LOG("mail_slot_size[%d]", mail_slot_size);
+ EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &mail_slot_size);
EM_DEBUG_LOG("mail_slot_size[%d]", mail_slot_size);
- if(emdaemon_set_mail_slot_size_of_mailbox(account_id, mailbox_id, mail_slot_size, &handle, &err))
+ if(emdaemon_set_mail_slot_size_of_mailbox(multi_user_name, account_id, mailbox_id, mail_slot_size, &handle, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
@@ -569,6 +697,7 @@ void stb_set_mail_slot_size_of_mailbox(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -582,6 +711,13 @@ void stb_rename_mailbox(HIPC_API a_hAPI)
int on_server = 0;
char *mailbox_path = NULL;
char *mailbox_alias = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
@@ -605,7 +741,7 @@ void stb_rename_mailbox(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, sizeof(int), &on_server);
EM_DEBUG_LOG("on_server[%d]", on_server);
- if ((err = emdaemon_rename_mailbox(mailbox_id, mailbox_path, mailbox_alias, NULL, 0, on_server, &handle)) != EMAIL_ERROR_NONE) {
+ if ((err = emdaemon_rename_mailbox(multi_user_name, mailbox_id, mailbox_path, mailbox_alias, NULL, 0, on_server, &handle)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_rename_mailbox failed [%d]", err);
}
@@ -621,6 +757,7 @@ void stb_rename_mailbox(HIPC_API a_hAPI)
EM_SAFE_FREE(mailbox_alias);
EM_SAFE_FREE(mailbox_path);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -636,6 +773,13 @@ void stb_rename_mailbox_ex(HIPC_API a_hAPI)
char *mailbox_path = NULL;
char *mailbox_alias = NULL;
void *eas_data = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
EM_DEBUG_LOG("mailbox_id[%d]", mailbox_id);
@@ -666,7 +810,7 @@ void stb_rename_mailbox_ex(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 4, sizeof(int), &on_server);
EM_DEBUG_LOG("on_server[%d]", on_server);
- if ((err = emdaemon_rename_mailbox(mailbox_id, mailbox_path, mailbox_alias, eas_data, eas_data_length, on_server, &handle)) != EMAIL_ERROR_NONE) {
+ if ((err = emdaemon_rename_mailbox(multi_user_name, mailbox_id, mailbox_path, mailbox_alias, eas_data, eas_data_length, on_server, &handle)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_rename_mailbox failed [%d]", err);
}
@@ -683,6 +827,7 @@ void stb_rename_mailbox_ex(HIPC_API a_hAPI)
EM_SAFE_FREE(mailbox_path);
EM_SAFE_FREE(eas_data);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -693,12 +838,19 @@ void stb_send_mail(HIPC_API a_hAPI)
int mail_id;
int handle;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* Mail_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
EM_DEBUG_LOG("mail_id [%d]", mail_id);
- if(emdaemon_send_mail(mail_id, &handle, &err)) {
+ if(emdaemon_send_mail(multi_user_name, mail_id, &handle, &err)) {
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
@@ -716,6 +868,7 @@ void stb_send_mail(HIPC_API a_hAPI)
EM_SAFE_FREE(local_stream);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -726,12 +879,19 @@ void stb_query_smtp_mail_size_limit(HIPC_API a_hAPI)
int account_id;
int handle;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* Mail_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
EM_DEBUG_LOG("account_id [%d]", account_id);
- if(emdaemon_query_smtp_mail_size_limit(account_id, &handle, &err)) {
+ if(emdaemon_query_smtp_mail_size_limit(multi_user_name, account_id, &handle, &err)) {
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
@@ -746,6 +906,7 @@ void stb_query_smtp_mail_size_limit(HIPC_API a_hAPI)
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -760,10 +921,17 @@ void stb_get_mailbox_list(HIPC_API a_hAPI)
email_mailbox_t* mailbox_list = NULL;
int count = 0;
int size = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
- if(emdaemon_get_mailbox_list(account_id, &mailbox_list, &count, &err))
+ if(emdaemon_get_mailbox_list(multi_user_name, account_id, &mailbox_list, &count, &err))
EM_DEBUG_LOG("emdaemon_get_mailbox_list - success");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -798,6 +966,7 @@ void stb_get_mailbox_list(HIPC_API a_hAPI)
emcore_free_mailbox_list(&mailbox_list, count);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -807,6 +976,13 @@ void stb_delete_all_mails(HIPC_API a_hAPI)
int mailbox_id = 0;
int from_server = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* mailbox_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
@@ -814,13 +990,14 @@ void stb_delete_all_mails(HIPC_API a_hAPI)
/* from_server */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &from_server);
- emdaemon_delete_mail_all(mailbox_id, from_server, NULL, &err);
+ emdaemon_delete_mail_all(multi_user_name, mailbox_id, from_server, NULL, &err);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -833,6 +1010,14 @@ void stb_delete_mail(HIPC_API a_hAPI)
int counter = 0;
int num;
int *mail_ids = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+ emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* Mailbox */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mailbox_id);
@@ -861,16 +1046,27 @@ void stb_delete_mail(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, sizeof(int), &from_server);
EM_DEBUG_LOG("from_server [%d]", from_server);
- emdaemon_delete_mail(mailbox_id, mail_ids, num, from_server, NULL, &err);
+ err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id, &mailbox_tbl);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ emdaemon_delete_mail(multi_user_name, mailbox_tbl->account_id, mail_ids, num, from_server, NULL, &err);
FINISH_OFF:
+
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+ if (mailbox_tbl)
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+
EM_SAFE_FREE(mail_ids);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -880,15 +1076,24 @@ void stb_clear_mail_data (HIPC_API a_hAPI)
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed : err");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- if(emdaemon_clear_all_mail_data(&err)) {
+ if(emdaemon_clear_all_mail_data(multi_user_name, &err)) {
EM_DEBUG_LOG(">>> stb_clear_mail_data Success [ %d] >> ", err);
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -899,6 +1104,13 @@ void stb_add_rule(HIPC_API a_hAPI)
int err = EMAIL_ERROR_NONE;
char* local_rule_stream = NULL;
email_rule_t rule = { 0 };
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
if(buffer_size <= 0) {
@@ -915,7 +1127,7 @@ void stb_add_rule(HIPC_API a_hAPI)
EM_DEBUG_LOG("account ID [%d]", rule.account_id);
/* call add_filter handler */
- err = emdaemon_add_filter(&rule);
+ err = emdaemon_add_filter(multi_user_name, &rule);
FINISH_OFF:
@@ -928,6 +1140,7 @@ FINISH_OFF:
emcore_free_rule(&rule);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -937,46 +1150,59 @@ void stb_get_rule(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- int *ret_nth_value = NULL;
int filter_id = 0;
email_rule_t* rule = NULL;
int size =0;
char* local_rule_stream = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
- if ((ret_nth_value = emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0))) {
- filter_id = *ret_nth_value;
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
- emdaemon_get_filter(filter_id, &rule, &err);
- } else {
- err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
- }
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id);
+ EM_DEBUG_LOG("Filter ID : [%d]", filter_id);
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ if (!emdaemon_get_filter(multi_user_name, filter_id, &rule, &err)) {
+ EM_DEBUG_EXCEPTION("emdaemon_get_filter failed : [%d]", err);
+ goto FINISH_OFF;
+ }
/* insert a rule if there exists a rule */
- if ( rule ) {
+ if (rule) {
local_rule_stream = em_convert_rule_to_byte_stream(rule, &size);
- if(!local_rule_stream) { /*prevent 26265*/
+ if (!local_rule_stream) { /*prevent 26265*/
EM_DEBUG_EXCEPTION("em_convert_rule_to_byte_stream failed");
- emcore_free_rule(rule);
- EM_SAFE_FREE(rule);
- return;
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
}
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, local_rule_stream, size))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ }
- EM_SAFE_FREE(local_rule_stream);
- emcore_free_rule(rule);
- EM_SAFE_FREE(rule);
+FINISH_OFF:
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+
+ if (err == EMAIL_ERROR_NONE) {
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, local_rule_stream, size))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
}
if (!emipc_execute_stub_api(a_hAPI)) {
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- return;
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
}
+ if (rule) {
+ emcore_free_rule(rule);
+ free(rule);
+ }
+
+ EM_SAFE_FREE(local_rule_stream);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END();
}
@@ -990,8 +1216,15 @@ void stb_get_rule_list(HIPC_API a_hAPI)
int count = 0;
int size = 0;
email_rule_t* filtering_list = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
- emdaemon_get_filter_list(&filtering_list, &count, &err);
+ emdaemon_get_filter_list(multi_user_name, &filtering_list, &count, &err);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
@@ -1020,6 +1253,7 @@ void stb_get_rule_list(HIPC_API a_hAPI)
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1031,29 +1265,44 @@ void stb_find_rule(HIPC_API a_hAPI)
int err = EMAIL_ERROR_NONE;
char* local_rule_stream = NULL;
email_rule_t rule = { 0 };
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
-
if(buffer_size > 0) {
local_rule_stream = (char*)em_malloc(buffer_size);
- EM_NULL_CHECK_FOR_VOID(local_rule_stream);
- if(local_rule_stream) {
+ if (local_rule_stream == NULL) {
+ EM_DEBUG_EXCEPTION("Out of memory");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if (local_rule_stream) {
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, buffer_size, local_rule_stream);
em_convert_byte_stream_to_rule(local_rule_stream, buffer_size, &rule);
EM_SAFE_FREE(local_rule_stream);
EM_DEBUG_LOG("account ID [%d]", rule.account_id);
- if(emdaemon_find_filter(&rule, &err))
- err = EMAIL_ERROR_NONE;
-
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
- if (!emipc_execute_stub_api(a_hAPI))
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
-
+ if (!emdaemon_find_filter(multi_user_name, &rule, &err)) {
+ EM_DEBUG_EXCEPTION("emdaemon_find_filter failed : [%d]", err);
+ }
}
}
+
+FINISH_OFF:
+
+ if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1067,7 +1316,13 @@ void stb_update_rule(HIPC_API a_hAPI)
int *ret_nth_value = NULL;
char* rule_stream = NULL;
email_rule_t rule = {0};
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* get filter_id */
if ((ret_nth_value = emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0))) {
@@ -1092,7 +1347,7 @@ void stb_update_rule(HIPC_API a_hAPI)
em_convert_byte_stream_to_rule(rule_stream, buffer_size, &rule);
/* call update handler */
- emdaemon_update_filter(filter_id, &rule, &err);
+ emdaemon_update_filter(multi_user_name, filter_id, &rule, &err);
FINISH_OFF:
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1103,6 +1358,7 @@ FINISH_OFF:
emcore_free_rule(&rule);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1111,6 +1367,13 @@ void stb_move_all_mails(HIPC_API a_hAPI)
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
int src_mailbox_id = 0, dst_mailbox_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* src_mailbox_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &src_mailbox_id);
@@ -1130,17 +1393,18 @@ void stb_move_all_mails(HIPC_API a_hAPI)
else
EM_DEBUG_LOG("dst_mailbox_id == 0");
- if(emdaemon_move_mail_all_mails(src_mailbox_id, dst_mailbox_id, &err))
+ if(emdaemon_move_mail_all_mails(multi_user_name, src_mailbox_id, dst_mailbox_id, &err))
EM_DEBUG_LOG("emdaemon_move_mail_all_mails:Success");
+
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
- return;
}
if (!emipc_execute_stub_api(a_hAPI)) {
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
- return;
}
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1155,6 +1419,13 @@ void stb_set_flags_field(HIPC_API a_hAPI)
int num = 0;
int counter = 0;
int *mail_ids = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
@@ -1190,7 +1461,7 @@ void stb_set_flags_field(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 5, sizeof(int), &onserver);
EM_DEBUG_LOG("onserver [%d]", onserver);
- if(emdaemon_set_flags_field(account_id, mail_ids, num, field_type, value, onserver, &err))
+ if(emdaemon_set_flags_field(multi_user_name, account_id, mail_ids, num, field_type, value, onserver, &err))
EM_DEBUG_LOG("emdaemon_set_flags_field - success");
FINISH_OFF:
@@ -1204,6 +1475,7 @@ FINISH_OFF:
if (mail_ids)
EM_SAFE_FREE(mail_ids);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1222,11 +1494,19 @@ void stb_add_mail(HIPC_API a_hAPI)
email_meeting_request_t result_meeting_request = {0};
emipc_email_api_info *api_info = (emipc_email_api_info *)a_hAPI;
email_account_server_t account_server_type = EMAIL_SERVER_TYPE_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* email_mail_data_t */;
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
- EM_DEBUG_LOG("email_attachment_data_t buffer_size[%d]", buffer_size);
+ EM_DEBUG_LOG("email_mail_data_t buffer_size[%d]", buffer_size);
/* mail_data */
if(buffer_size > 0) {
@@ -1234,14 +1514,28 @@ void stb_add_mail(HIPC_API a_hAPI)
em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data);
}
- if (em_get_account_server_type_by_account_id(result_mail_data.account_id, &account_server_type, true, &err) == false) {
+ if (em_get_account_server_type_by_account_id(multi_user_name, result_mail_data.account_id, &account_server_type, true, &err) == false) {
EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
goto FINISH_OFF;
}
+ /* Get the absolute path */
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
/* check smack rule for accessing file path */
if ((account_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) && result_mail_data.file_path_html) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_mail_data.file_path_html)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_mail_data.file_path_html);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1249,7 +1543,10 @@ void stb_add_mail(HIPC_API a_hAPI)
}
if ((account_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) && result_mail_data.file_path_plain) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_mail_data.file_path_plain)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_mail_data.file_path_plain);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1257,7 +1554,10 @@ void stb_add_mail(HIPC_API a_hAPI)
}
if ((account_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) && result_mail_data.file_path_mime_entity) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_mail_data.file_path_mime_entity)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_mail_data.file_path_mime_entity);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1289,7 +1589,10 @@ void stb_add_mail(HIPC_API a_hAPI)
/* check smack rule for accessing file path */
for (i = 0; i < result_attachment_data_count ; i++) {
if ((account_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) && result_attachment_data[i].attachment_path && result_attachment_data[i].save_status) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_attachment_data[i].attachment_path)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_attachment_data[i].attachment_path);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1313,7 +1616,7 @@ void stb_add_mail(HIPC_API a_hAPI)
EM_DEBUG_LOG("sync_server");
emipc_get_parameter(a_hAPI, ePARAMETER_IN, param_index++, sizeof(int), &sync_server);
- if( (err = emdaemon_add_mail(&result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
+ if( (err = emdaemon_add_mail(multi_user_name, &result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_add_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -1336,6 +1639,8 @@ FINISH_OFF:
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
}
+ EM_SAFE_FREE(prefix_path);
+
emcore_free_mail_data(&result_mail_data);
if(result_attachment_data)
@@ -1343,8 +1648,7 @@ FINISH_OFF:
emstorage_free_meeting_request(&result_meeting_request);
- em_flush_memory();
-
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1364,6 +1668,15 @@ void stb_update_mail(HIPC_API a_hAPI)
email_attachment_data_t *result_attachment_data = NULL;
email_meeting_request_t result_meeting_request = {0};
emipc_email_api_info *api_info = (emipc_email_api_info *)a_hAPI;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
EM_DEBUG_LOG("email_mail_data_t");
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
@@ -1373,9 +1686,23 @@ void stb_update_mail(HIPC_API a_hAPI)
em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data);
}
+ /* Get the absolute path */
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
/* check smack rule for accessing file path */
if (result_mail_data.file_path_html) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_mail_data.file_path_html)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_mail_data.file_path_html);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1383,7 +1710,10 @@ void stb_update_mail(HIPC_API a_hAPI)
}
if (result_mail_data.file_path_plain) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_mail_data.file_path_plain)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_mail_data.file_path_plain);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1391,7 +1721,10 @@ void stb_update_mail(HIPC_API a_hAPI)
}
if (result_mail_data.file_path_mime_entity) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_mail_data.file_path_mime_entity)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_mail_data.file_path_mime_entity);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1419,7 +1752,10 @@ void stb_update_mail(HIPC_API a_hAPI)
/* check smack rule for accessing file path */
for (i = 0; i < result_attachment_data_count ; i++) {
if (result_attachment_data[i].attachment_path) {
- if (!emdaemon_check_smack_rule(api_info->response_id, result_attachment_data[i].attachment_path)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, result_attachment_data[i].attachment_path);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1451,7 +1787,7 @@ void stb_update_mail(HIPC_API a_hAPI)
sync_server = *temp_buffer;
- if( (err = emdaemon_update_mail(&result_mail_data, result_attachment_data,
+ if( (err = emdaemon_update_mail(multi_user_name, &result_mail_data, result_attachment_data,
result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_update_mail failed [%d]", err);
goto FINISH_OFF;
@@ -1477,12 +1813,14 @@ FINISH_OFF:
emcore_free_mail_data(&result_mail_data);
+ EM_SAFE_FREE(prefix_path);
+
if(result_attachment_data)
emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL);
emstorage_free_meeting_request(&result_meeting_request);
- em_flush_memory();
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1493,6 +1831,13 @@ void stb_move_thread_to_mailbox(HIPC_API a_hAPI)
int mailbox_id = 0, thread_id = 0, move_always_flag = 0;
int err = EMAIL_ERROR_NONE;
char *target_mailbox_name = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id);
EM_DEBUG_LOG("thread_id [%d]", thread_id);
@@ -1503,22 +1848,25 @@ void stb_move_thread_to_mailbox(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &move_always_flag);
EM_DEBUG_LOG("move_always_flag [%d]", move_always_flag);
- if(emdaemon_move_mail_thread_to_mailbox(thread_id, mailbox_id, move_always_flag, &err))
+ if(emdaemon_move_mail_thread_to_mailbox(multi_user_name, thread_id, mailbox_id, move_always_flag, &err))
EM_DEBUG_LOG("emdaemon_move_mail_thread_to_mailbox success");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
EM_SAFE_FREE(target_mailbox_name);
+ EM_SAFE_FREE(multi_user_name);
return;
}
if (!emipc_execute_stub_api(a_hAPI)) {
EM_DEBUG_EXCEPTION("emipc_execute_stub_api fail");
EM_SAFE_FREE(target_mailbox_name);
+ EM_SAFE_FREE(multi_user_name);
return;
}
EM_SAFE_FREE(target_mailbox_name);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1529,6 +1877,13 @@ void stb_delete_thread(HIPC_API a_hAPI)
int thread_id = 0, delete_always_flag = 0;
int handle = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id);
EM_DEBUG_LOG("thread_id [%d]", thread_id);
@@ -1536,18 +1891,22 @@ void stb_delete_thread(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &delete_always_flag);
EM_DEBUG_LOG("delete_always_flag [%d]", delete_always_flag);
- if(emdaemon_delete_mail_thread(thread_id, delete_always_flag, &handle, &err))
+ if(emdaemon_delete_mail_thread(multi_user_name, thread_id, delete_always_flag, &handle, &err))
EM_DEBUG_LOG("emdaemon_delete_mail_thread success");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
+ EM_SAFE_FREE(multi_user_name);
return;
}
if (!emipc_execute_stub_api(a_hAPI)) {
EM_DEBUG_EXCEPTION("emipc_execute_stub_api fail");
+ EM_SAFE_FREE(multi_user_name);
return;
}
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1558,6 +1917,13 @@ void stb_modify_seen_flag_of_thread(HIPC_API a_hAPI)
int thread_id = 0, seen_flag = 0, on_server = 0;
int handle = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &thread_id);
EM_DEBUG_LOG("thread_id [%d]", thread_id);
@@ -1568,18 +1934,22 @@ void stb_modify_seen_flag_of_thread(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &on_server);
EM_DEBUG_LOG("on_server [%d]", on_server);
- if(emdaemon_modify_seen_flag_of_thread(thread_id, seen_flag, on_server, &handle, &err))
+ if(emdaemon_modify_seen_flag_of_thread(multi_user_name, thread_id, seen_flag, on_server, &handle, &err))
EM_DEBUG_LOG("emdaemon_modify_seen_flag_of_thread success");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
+ EM_SAFE_FREE(multi_user_name);
return;
}
if (!emipc_execute_stub_api(a_hAPI)) {
EM_DEBUG_EXCEPTION("emipc_execute_stub_api fail");
+ EM_SAFE_FREE(multi_user_name);
return;
}
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1590,6 +1960,13 @@ void stb_expunge_mails_deleted_flagged(HIPC_API a_hAPI)
int mailbox_id = 0, on_server = 0;
int handle = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), (void*)&mailbox_id);
EM_DEBUG_LOG("mailbox_id [%d]", mailbox_id);
@@ -1597,23 +1974,22 @@ void stb_expunge_mails_deleted_flagged(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), (void*)&on_server);
EM_DEBUG_LOG("on_server [%d]", on_server);
- if( (err = emdaemon_expunge_mails_deleted_flagged(mailbox_id, on_server, &handle)) != EMAIL_ERROR_NONE)
+ if( (err = emdaemon_expunge_mails_deleted_flagged(multi_user_name, mailbox_id, on_server, &handle)) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG("emdaemon_expunge_mails_deleted_flagged success");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
- return;
}
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int))) {
EM_DEBUG_LOG("ipcAPI_AddParameter local_result failed ");
- return;
}
if (!emipc_execute_stub_api(a_hAPI)) {
EM_DEBUG_EXCEPTION("emipc_execute_stub_api fail");
- return;
}
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1621,6 +1997,13 @@ void stb_move_mail(HIPC_API a_hAPI)
{
int err = EMAIL_ERROR_NONE;
int num = 0, counter = 0, mailbox_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* Number of mail_ids */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &num);
@@ -1642,7 +2025,7 @@ void stb_move_mail(HIPC_API a_hAPI)
else
EM_DEBUG_LOG("mailbox_id == 0");
- if(emdaemon_move_mail(mail_ids, num, mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, &err))
+ if(emdaemon_move_mail(multi_user_name, mail_ids, num, mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, &err))
EM_DEBUG_LOG("emdaemon_move_mail success");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1650,6 +2033,8 @@ void stb_move_mail(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api fail");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1659,11 +2044,18 @@ void stb_delete_rule(HIPC_API a_hAPI)
int filter_id = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* filter_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id);
- if(emdaemon_delete_filter(filter_id, &err))
+ if(emdaemon_delete_filter(multi_user_name, filter_id, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1671,6 +2063,8 @@ void stb_delete_rule(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1680,11 +2074,18 @@ void stb_apply_rule(HIPC_API a_hAPI)
int filter_id = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* filter_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id);
- if(emdaemon_apply_filter(filter_id, &err))
+ if(emdaemon_apply_filter(multi_user_name, filter_id, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1692,6 +2093,8 @@ void stb_apply_rule(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1706,6 +2109,15 @@ void stb_add_attachment(HIPC_API a_hAPI)
char* attachment_stream = NULL;
email_attachment_data_t* attachment = NULL;
emipc_email_api_info *api_info = (emipc_email_api_info *)a_hAPI;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* mail_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
@@ -1715,12 +2127,15 @@ void stb_add_attachment(HIPC_API a_hAPI)
if(buffer_size > 0) {
attachment_stream = (char*)em_malloc(buffer_size);
- EM_NULL_CHECK_FOR_VOID(attachment_stream);
- if(attachment_stream) {
- emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, attachment_stream);
- em_convert_byte_stream_to_attachment_data(attachment_stream, buffer_size, &attachment, &attachment_count);
- EM_SAFE_FREE(attachment_stream);
+ if (attachment_stream == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMAIL_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
}
+
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, attachment_stream);
+ em_convert_byte_stream_to_attachment_data(attachment_stream, buffer_size, &attachment, &attachment_count);
+ EM_SAFE_FREE(attachment_stream);
}
if (!attachment) {
@@ -1729,10 +2144,24 @@ void stb_add_attachment(HIPC_API a_hAPI)
goto FINISH_OFF;
}
+ /* Get the absolute path */
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
/* check smack rule for accessing file path */
for (i = 0; i < attachment_count ; i++) {
if (attachment[i].attachment_path) {
- if (!emdaemon_check_smack_rule(api_info->response_id, attachment[i].attachment_path)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, attachment[i].attachment_path);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -1740,7 +2169,7 @@ void stb_add_attachment(HIPC_API a_hAPI)
}
}
- emdaemon_add_attachment(mail_id, attachment, &err);
+ emdaemon_add_attachment(multi_user_name, mail_id, attachment, &err);
FINISH_OFF:
@@ -1756,6 +2185,9 @@ FINISH_OFF:
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
EM_SAFE_FREE(attachment);
+ EM_SAFE_FREE(multi_user_name);
+ EM_SAFE_FREE(prefix_path);
+
EM_DEBUG_FUNC_END();
}
@@ -1767,11 +2199,18 @@ void stb_get_attachment(HIPC_API a_hAPI)
char* attachment_stream = NULL;
email_attachment_data_t* attachment = NULL;
int size = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* attachment_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &attachment_id);
- emdaemon_get_attachment(attachment_id, &attachment, &err);
+ emdaemon_get_attachment(multi_user_name, attachment_id, &attachment, &err);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
@@ -1782,6 +2221,7 @@ void stb_get_attachment(HIPC_API a_hAPI)
attachment_stream = em_convert_attachment_data_to_byte_stream(attachment, 1, &size);
if(!attachment_stream) { /*prevent 26263*/
emcore_free_attachment_data(&attachment, 1, &err);
+ EM_SAFE_FREE(multi_user_name);
return;
}
EM_NULL_CHECK_FOR_VOID(attachment_stream);
@@ -1797,6 +2237,7 @@ void stb_get_attachment(HIPC_API a_hAPI)
EM_SAFE_FREE(attachment_stream);
emcore_free_attachment_data(&attachment, 1, &err);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1806,12 +2247,19 @@ void stb_get_imap_mailbox_list(HIPC_API a_hAPI)
int err = EMAIL_ERROR_NONE;
int account_id = 0;
int handle = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
- /*need to check: why err value is changed? */
- if(emdaemon_get_imap_mailbox_list(account_id, "", &handle, &err))
+ /* need to check: why err value is changed? */
+ if(emdaemon_get_imap_mailbox_list(multi_user_name, account_id, "", &handle, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1820,6 +2268,8 @@ void stb_get_imap_mailbox_list(HIPC_API a_hAPI)
EM_DEBUG_LOG("ipcAPI_AddParameter local_result failed ");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_LOG("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1828,17 +2278,25 @@ void stb_delete_attachment(HIPC_API a_hAPI)
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
int attachment_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* attachment_index */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &attachment_id);
- emdaemon_delete_mail_attachment(attachment_id, &err);
+ emdaemon_delete_mail_attachment(multi_user_name, attachment_id, &err);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1851,6 +2309,13 @@ void stb_download_attachment(HIPC_API a_hAPI)
int nth = 0;
int handle = 0;
int account_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
EM_DEBUG_LOG("account_id");
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
@@ -1861,7 +2326,7 @@ void stb_download_attachment(HIPC_API a_hAPI)
EM_DEBUG_LOG("nth");
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &nth);
- if(emdaemon_download_attachment(account_id, mail_id, nth, &handle, &err)) {
+ if(emdaemon_download_attachment(multi_user_name, account_id, mail_id, nth, &handle, &err)) {
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1883,6 +2348,7 @@ void stb_download_attachment(HIPC_API a_hAPI)
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1891,12 +2357,19 @@ void stb_mail_send_saved(HIPC_API a_hAPI)
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
int account_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
EM_DEBUG_LOG("calling emdaemon_send_mail_saved");
- if(emdaemon_send_mail_saved(account_id, NULL, &err))
+ if(emdaemon_send_mail_saved(multi_user_name, account_id, NULL, &err))
err = EMAIL_ERROR_NONE;
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1905,6 +2378,7 @@ void stb_mail_send_saved(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1913,12 +2387,19 @@ void stb_add_read_receipt(HIPC_API a_hAPI){
int read_mail_id = 0;
int receipt_mail_id = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* read_mail_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &read_mail_id);
EM_DEBUG_LOG("read_mail_id [%d]", read_mail_id);
- if( (err = emcore_add_read_receipt(read_mail_id, &receipt_mail_id)) != EMAIL_ERROR_NONE )
+ if( (err = emcore_add_read_receipt(multi_user_name, read_mail_id, &receipt_mail_id)) != EMAIL_ERROR_NONE )
EM_DEBUG_EXCEPTION("emcore_add_read_receipt failed [%d]", err);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -1932,6 +2413,7 @@ void stb_add_read_receipt(HIPC_API a_hAPI){
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END("err [%d]", err);
}
@@ -1942,6 +2424,13 @@ void stb_retry_sending_mail(HIPC_API a_hAPI)
int mail_id = 0;
int timeout_in_sec = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* Mail_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
@@ -1951,14 +2440,16 @@ void stb_retry_sending_mail(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &timeout_in_sec);
EM_DEBUG_LOG("timeout_in_sec [%d]", timeout_in_sec);
- if(emdaemon_send_mail_retry(mail_id, timeout_in_sec,&err))
+ if(emdaemon_send_mail_retry(multi_user_name, mail_id, timeout_in_sec,&err))
EM_DEBUG_LOG("emdaemon_get_mailbox_list - success");
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
- if (!emipc_execute_stub_api(a_hAPI))
- EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1968,6 +2459,13 @@ void stb_cancel_job(HIPC_API a_hAPI)
int account_id = 0;
int handle = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &handle);
@@ -1980,6 +2478,8 @@ void stb_cancel_job(HIPC_API a_hAPI)
EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -1989,6 +2489,13 @@ void stb_cancel_send_mail_job(HIPC_API a_hAPI)
int mail_id = 0;
int err = EMAIL_ERROR_NONE;
int account_id = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
@@ -2006,9 +2513,161 @@ void stb_cancel_send_mail_job(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_FUNC_END();
+}
+
+void stb_search_mail_on_server(HIPC_API a_hAPI)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ int account_id = 0;
+ int mailbox_id = 0;
+ int buffer_size = 0;
+ int search_filter_count = 0;
+ char *stream_for_search_filter_list = NULL;
+ unsigned int job_handle = 0;
+ email_search_filter_t *search_filter_list = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
+ /* account_id */
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
+ EM_DEBUG_LOG("account_id [%d]", account_id);
+
+ /* mailbox_id */
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_id);
+ EM_DEBUG_LOG("mailbox_id [%d]", mailbox_id);
+
+ /* search_filter_list */
+ buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2);
+
+ if(buffer_size > 0) {
+ stream_for_search_filter_list = (char*)em_malloc(buffer_size);
+ if (stream_for_search_filter_list == NULL) {
+ EM_DEBUG_EXCEPTION("out of memory");
+ EM_SAFE_FREE(multi_user_name);
+ return;
+ }
+
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, stream_for_search_filter_list);
+ em_convert_byte_stream_to_search_filter(stream_for_search_filter_list,
+ &search_filter_list,
+ &search_filter_count);
+ EM_SAFE_FREE(stream_for_search_filter_list);
+ }
+
+ if (!emdaemon_search_mail_on_server(multi_user_name, account_id ,mailbox_id,
+ search_filter_list,
+ search_filter_count,
+ &job_handle,
+ &err))
+ EM_DEBUG_LOG("success");
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &job_handle, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_FUNC_END();
+}
+
+void stb_clear_result_of_search_mail_on_server(HIPC_API a_hAPI)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMAIL_ERROR_NONE;
+ int account_id = 0;
+ int handle = 0;
+ int *mail_id_list = NULL;
+ int mail_id_count = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+
+ char conditional_clause[QUERY_SIZE] = {0, };
+ char *multi_user_name = NULL;
+ emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
+ /* account_id */
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
+
+ EM_DEBUG_LOG("account_id [%d]", account_id);
+
+ if (!emstorage_get_mailbox_by_name(multi_user_name,
+ account_id,
+ -1,
+ EMAIL_SEARCH_RESULT_MAILBOX_NAME,
+ &mailbox_tbl,
+ false,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ /* Create the conditional_clause */
+ SNPRINTF(conditional_clause, QUERY_SIZE, " where mailbox_type = %d ", mailbox_tbl->mailbox_type);
+
+ /* Get mail ids */
+ err = emstorage_query_mail_id_list(multi_user_name,
+ conditional_clause,
+ false,
+ &mail_id_list,
+ &mail_id_count);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emstorage_query_mail_id_list failed : [%d]", err);
+ if (err == EMAIL_ERROR_MAIL_NOT_FOUND) err = EMAIL_ERROR_NONE;
+ goto FINISH_OFF;
+ }
+
+ /* Remove the searched mails */
+ if (!emdaemon_delete_mail(multi_user_name,
+ account_id,
+ mail_id_list,
+ mail_id_count,
+ EMAIL_DELETE_LOCALLY,
+ &handle,
+ &err)) {
+ EM_DEBUG_EXCEPTION("emdaemon_delete_mail failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+/*
+ if (!emstorage_delete_mail_by_mailbox(multi_user_name, mailbox_tbl, true, &err))
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
+*/
+FINISH_OFF:
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ if (mailbox_tbl)
+ emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
+
+ EM_SAFE_FREE(mail_id_list);
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END();
}
+
+
void stb_add_account_with_validation(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
@@ -2021,6 +2680,13 @@ void stb_add_account_with_validation(HIPC_API a_hAPI)
int ref_check_interval = 0;
int ref_account_id = 0;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* get account info */
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
@@ -2037,22 +2703,21 @@ void stb_add_account_with_validation(HIPC_API a_hAPI)
}
account = em_malloc(sizeof(email_account_t));
-
- if(account == NULL) {
+ if (account == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
goto FINISH_OFF;
}
em_convert_byte_stream_to_account(stream, buffer_size, account);
+ account->user_name = EM_SAFE_STRDUP(multi_user_name);
- if((err = emcore_add_account_to_unvalidated_account_list(account)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_add_account_to_unvalidated_account_list(account)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_account_to_unvalidated_account_list failed [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(account->account_id);
-
+ ref_account = emcore_get_account_reference(multi_user_name, account->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", err);
goto FINISH_OFF;
@@ -2061,18 +2726,18 @@ void stb_add_account_with_validation(HIPC_API a_hAPI)
ref_check_interval = ref_account->check_interval;
ref_account_id = ref_account->account_id;
- if(!emdaemon_validate_account_and_create(ref_account, &handle, &err)) {
+ if (!emdaemon_validate_account_and_create(multi_user_name, ref_account, &handle, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_validate_account_and_create fail [%d]", err);
goto FINISH_OFF;
}
#ifdef __FEATURE_AUTO_POLLING__
/* start auto polling, if check_interval not zero */
- if(ref_check_interval > 0 || (ref_account->peak_days > 0 && ref_account->peak_interval > 0)) {
- if(!emdaemon_add_polling_alarm(ref_account_id))
+ if (ref_check_interval > 0 || (ref_account->peak_days > 0 && ref_account->peak_interval > 0)) {
+ if(!emdaemon_add_polling_alarm(multi_user_name, ref_account_id))
EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[NOTI_ACCOUNT_ADD] : start auto poll failed >>> ");
}
#ifdef __FEATURE_IMAP_IDLE__
- else if(ref_check_interval == 0 || (ref_account->peak_days > 0 && ref_account->peak_interval == 0))
+ else if (ref_check_interval == 0 || (ref_account->peak_days > 0 && ref_account->peak_interval == 0))
emcore_refresh_imap_idle_thread();
#endif /* __FEATURE_IMAP_IDLE__ */
#endif /* __FEATURE_AUTO_POLLING__ */
@@ -2080,9 +2745,9 @@ void stb_add_account_with_validation(HIPC_API a_hAPI)
/* emdaemon_insert_accountinfo_to_contact(account); */
local_result = 1;
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
@@ -2100,6 +2765,7 @@ FINISH_OFF:
/* note: account is freed in thread_func_branch_command, which is run by other thread */
/* emcore_free_account(account); */
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -2109,7 +2775,14 @@ void stb_backup_account(HIPC_API a_hAPI)
#ifdef __FEATURE_BACKUP_ACCOUNT__
char *file_path = NULL;
- int local_result = 0, err_code = 0, handle = 0, file_path_length = 0;
+ int local_result = 0, err_code = 0, file_path_length = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err_code = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err_code);
+ multi_user_name = NULL;
+ }
/* file_path_length */
file_path_length = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
@@ -2118,7 +2791,7 @@ void stb_backup_account(HIPC_API a_hAPI)
file_path = em_malloc(file_path_length);
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, file_path_length, file_path);
EM_DEBUG_LOG_SEC("file_path [%s]", file_path);
- local_result = emcore_backup_accounts((const char*)file_path, &err_code);
+ local_result = emcore_backup_accounts(multi_user_name, (const char*)file_path, &err_code);
}
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
@@ -2127,13 +2800,11 @@ void stb_backup_account(HIPC_API a_hAPI)
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
-
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
EM_SAFE_FREE(file_path);
+ EM_SAFE_FREE(multi_user_name);
#endif /* __FEATURE_BACKUP_ACCOUNT__ */
EM_DEBUG_FUNC_END();
}
@@ -2143,7 +2814,14 @@ void stb_restore_account(HIPC_API a_hAPI)
EM_DEBUG_FUNC_BEGIN();
#ifdef __FEATURE_BACKUP_ACCOUNT__
char *file_path = NULL;
- int result = 0, err_code = 0, handle = 0, file_path_length = 0;
+ int result = 0, err_code = 0, file_path_length = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err_code = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err_code);
+ multi_user_name = NULL;
+ }
/* file_path_length */
file_path_length = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
@@ -2155,7 +2833,7 @@ void stb_restore_account(HIPC_API a_hAPI)
}
/* file_path could be NULL */
- err_code = emcore_restore_accounts((const char*)file_path);
+ err_code = emcore_restore_accounts(multi_user_name, (const char*)file_path);
result = (err_code == EMAIL_ERROR_NONE)?1:0;
@@ -2165,13 +2843,11 @@ void stb_restore_account(HIPC_API a_hAPI)
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
- EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
-
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
EM_SAFE_FREE(file_path);
+ EM_SAFE_FREE(multi_user_name);
#endif /* __FEATURE_BACKUP_ACCOUNT__ */
EM_DEBUG_FUNC_END();
}
@@ -2185,12 +2861,19 @@ void stb_get_password_length(HIPC_API a_hAPI)
int local_result = 0;
int err_code = 0;
int password_length = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err_code = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err_code);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &password_type);
- local_result = emstorage_get_password_length_of_account(account_id, password_type, &password_length,&err_code);
+ local_result = emstorage_get_password_length_of_account(multi_user_name, account_id, password_type, &password_length,&err_code);
EM_DEBUG_LOG("password_length [%d]", password_length);
@@ -2205,6 +2888,8 @@ void stb_get_password_length(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -2216,14 +2901,21 @@ void stb_get_task_information(HIPC_API a_hAPI)
int stream_length;
email_task_information_t *task_information = NULL;
char *task_information_stream = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
err = emcore_get_task_information(&task_information, &task_information_count);
- if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
EM_DEBUG_LOG("emipc_add_parameter failed ");
/* email_task_information_t */
- if(task_information_count) {
+ if (task_information_count) {
task_information_stream = em_convert_task_information_to_byte_stream(task_information, task_information_count, &stream_length);
if((stream_length > 0) && !emipc_add_dynamic_parameter(a_hAPI, ePARAMETER_OUT, task_information_stream, stream_length)) {
@@ -2239,6 +2931,7 @@ void stb_get_task_information(HIPC_API a_hAPI)
EM_SAFE_FREE(task_information);
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -2250,6 +2943,26 @@ void stb_add_certificate(HIPC_API a_hAPI)
char *cert_file_path = NULL;
char *email_address = NULL;
emipc_email_api_info *api_info = (emipc_email_api_info *)a_hAPI;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
+ /* Get the absolute path */
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
cert_file_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
if (cert_file_len > 0) {
@@ -2259,7 +2972,10 @@ void stb_add_certificate(HIPC_API a_hAPI)
/* check smack rule for accessing file path */
if (cert_file_path) {
- if (!emdaemon_check_smack_rule(api_info->response_id, cert_file_path)) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, cert_file_path);
+
+ if (!emdaemon_check_smack_rule(api_info->response_id, real_file_path)) {
EM_DEBUG_EXCEPTION("emdaemon_check_smack_rule fail");
err = EMAIL_ERROR_NO_SMACK_RULE;
goto FINISH_OFF;
@@ -2272,7 +2988,7 @@ void stb_add_certificate(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, email_address_len, email_address);
}
- if (!emcore_add_public_certificate(cert_file_path, email_address, &err)) {
+ if (!emcore_add_public_certificate(multi_user_name, cert_file_path, email_address, &err)) {
EM_DEBUG_EXCEPTION("em_core_smime_add_certificate failed");
}
@@ -2288,8 +3004,10 @@ FINISH_OFF:
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(prefix_path);
EM_SAFE_FREE(cert_file_path);
EM_SAFE_FREE(email_address);
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -2299,6 +3017,13 @@ void stb_delete_certificate(HIPC_API a_hAPI)
int email_address_len = 0;
char *email_address = NULL;
char temp_email_address[130] = {0, };
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
email_address_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
if (email_address_len > 0) {
@@ -2309,7 +3034,7 @@ void stb_delete_certificate(HIPC_API a_hAPI)
}
SNPRINTF(temp_email_address, sizeof(temp_email_address), "<%s>", email_address);
- if (!emcore_delete_public_certificate(temp_email_address, &err)) {
+ if (!emcore_delete_public_certificate(multi_user_name, temp_email_address, &err)) {
EM_DEBUG_EXCEPTION("em_core_smime_add_certificate failed");
}
@@ -2323,9 +3048,10 @@ void stb_delete_certificate(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
-
+
EM_SAFE_FREE(email_address);
- EM_DEBUG_FUNC_END();
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_FUNC_END();
}
void stb_verify_signature(HIPC_API a_hAPI)
@@ -2337,6 +3063,13 @@ void stb_verify_signature(HIPC_API a_hAPI)
int attachment_tbl_count = 0;
email_mail_data_t *mail_data = NULL;
emstorage_attachment_tbl_t *attachment_tbl_list = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
err = emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
if (err != EMAIL_ERROR_NONE) {
@@ -2344,12 +3077,12 @@ void stb_verify_signature(HIPC_API a_hAPI)
goto FINISH_OFF;
}
- if (!emcore_get_mail_data(mail_id, &mail_data)) {
+ if (!emcore_get_mail_data(multi_user_name, mail_id, &mail_data)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_data failed");
goto FINISH_OFF;
}
- if ((err = emstorage_get_attachment_list(mail_id, true, &attachment_tbl_list, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &attachment_tbl_list, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed : [%d]", err);
goto FINISH_OFF;
}
@@ -2401,6 +3134,7 @@ FINISH_OFF:
EM_SAFE_FREE(mail_data);
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -2410,6 +3144,13 @@ void stb_verify_certificate(HIPC_API a_hAPI)
int verify = 0;
int cert_file_len = 0;
char *cert_file_path = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
cert_file_len = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
if (cert_file_len > 0) {
@@ -2431,8 +3172,9 @@ void stb_verify_certificate(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
- EM_SAFE_FREE(cert_file_path);
- EM_DEBUG_FUNC_END();
+ EM_SAFE_FREE(cert_file_path);
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_FUNC_END();
}
void stb_ping_service(HIPC_API a_hAPI)
@@ -2455,6 +3197,14 @@ void stb_update_notification_bar_for_unread_mail(HIPC_API a_hAPI)
int err = EMAIL_ERROR_NONE, account_id;
int total_mail_count = 0, unread_mail_count = 0;
int input_from_eas = 0;
+ /* Get Container name */
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
@@ -2469,9 +3219,9 @@ void stb_update_notification_bar_for_unread_mail(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, sizeof(int), &input_from_eas);
EM_DEBUG_LOG("unread_mail_count [%d]", input_from_eas);
- emcore_display_unread_in_badge(NULL);
+ emcore_display_unread_in_badge(multi_user_name);
- if(!emdaemon_finalize_sync(account_id, total_mail_count, unread_mail_count, 0, 0, input_from_eas, &err)) {
+ if(!emdaemon_finalize_sync(multi_user_name, account_id, total_mail_count, unread_mail_count, 0, 0, input_from_eas, &err)) {
EM_DEBUG_EXCEPTION("emdaemon_finalize_sync failed [%d]", err);
}
@@ -2480,6 +3230,8 @@ void stb_update_notification_bar_for_unread_mail(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -2487,12 +3239,19 @@ void stb_clear_notification_bar(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE, account_id;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* account_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
EM_DEBUG_LOG("account_id [%d]", account_id);
- if((err = emcore_clear_notifications(account_id)) != EMAIL_ERROR_NONE)
+ if((err = emcore_clear_notifications(multi_user_name, account_id)) != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emdaemon_finalize_sync failed [%d]", err);
if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
@@ -2500,6 +3259,8 @@ void stb_clear_notification_bar(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
@@ -2510,6 +3271,13 @@ void stb_show_user_message(HIPC_API a_hAPI)
int param_id = 0;
int param_error = 0;
email_action_t param_action = 0;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* param_id */
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &param_id);
@@ -2523,7 +3291,7 @@ void stb_show_user_message(HIPC_API a_hAPI)
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &param_error);
EM_DEBUG_LOG("param_error [%d]", param_error);
- if(!emcore_show_user_message(param_id, param_action, param_error)) {
+ if(!emcore_show_user_message(multi_user_name, param_id, param_action, param_error)) {
EM_DEBUG_EXCEPTION("emcore_show_user_message failed");
}
@@ -2533,6 +3301,7 @@ void stb_show_user_message(HIPC_API a_hAPI)
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END("err [%d]", err);
}
@@ -2561,6 +3330,13 @@ void stb_validate_account_ex(HIPC_API a_hAPI)
email_account_t *account = NULL;
email_account_t *ref_account = NULL;
int err = EMAIL_ERROR_NONE;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_name failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* get account info */
buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
@@ -2585,13 +3361,14 @@ void stb_validate_account_ex(HIPC_API a_hAPI)
}
em_convert_byte_stream_to_account(stream, buffer_size, account);
+ account->user_name = EM_SAFE_STRDUP(multi_user_name);
if((err = emcore_add_account_to_unvalidated_account_list(account)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_account_to_unvalidated_account_list failed [%d]", err);
goto FINISH_OFF;
}
- ref_account = emcore_get_account_reference(account->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, account->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", err);
@@ -2599,7 +3376,7 @@ void stb_validate_account_ex(HIPC_API a_hAPI)
}
/* ref_account will be removed by worker_event_queue() */
- if((err = emdaemon_validate_account_ex(ref_account, &handle)) != EMAIL_ERROR_NONE) {
+ if((err = emdaemon_validate_account_ex(multi_user_name, ref_account, &handle)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emdaemon_validate_account_ex fail [%d]", err);
goto FINISH_OFF;
}
@@ -2622,8 +3399,10 @@ FINISH_OFF:
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed ");
}
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
}
+
void stb_handle_task(int task_type, HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
@@ -2645,7 +3424,12 @@ void stb_handle_task(int task_type, HIPC_API a_hAPI)
if(is_async_task) {
/* add async task */
- if((err = emcore_add_task_to_task_table(task_type, EMAIL_TASK_PRIORITY_MID, task_parameter, task_parameter_length, &task_id)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_add_task_to_task_table(NULL,
+ task_type,
+ EMAIL_TASK_PRIORITY_MID,
+ task_parameter,
+ task_parameter_length,
+ &task_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_add_task_to_task_pool failed [%d]", err);
goto FINISH_OFF;
}
@@ -2660,7 +3444,7 @@ void stb_handle_task(int task_type, HIPC_API a_hAPI)
sync_task.task_parameter = task_parameter;
sync_task.task_parameter_length = task_parameter_length;
- if((err = (int)emcore_default_sync_task_handler(&sync_task)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_default_sync_task_handler(&sync_task)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_default_sync_task_handler failed [%d]", err);
goto FINISH_OFF;
}
@@ -2678,7 +3462,6 @@ FINISH_OFF:
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
- em_flush_memory();
EM_DEBUG_FUNC_END("err [%d]", err);
}
@@ -2696,7 +3479,7 @@ void* thread_func_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT(void
EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
for(i = 0; i < task_param->mail_id_count; i++) {
- if((err = emcore_move_mail_to_another_account(task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_move_mail_to_another_account(task_param->multi_user_name, task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_move_mail_to_another_account failed [%d]", err);
goto FINISH_OFF;
}
@@ -2718,6 +3501,7 @@ FINISH_OFF:
}
/* Free task parameter */
+ EM_SAFE_FREE(task_param->multi_user_name);
EM_SAFE_FREE(task_param->mail_id_array);
EM_SAFE_FREE(task_param);
@@ -2737,6 +3521,14 @@ void stb_move_mails_to_mailbox_of_another_account(HIPC_API a_hAPI)
char *task_parameter = NULL;
task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT *decoded_parameter = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
/* task_parameter_length */;
task_parameter_length = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
@@ -2754,6 +3546,8 @@ void stb_move_mails_to_mailbox_of_another_account(HIPC_API a_hAPI)
goto FINISH_OFF;
}
+ decoded_parameter->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
THREAD_CREATE(task_id, thread_func_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, (void*)decoded_parameter, thread_error);
if(thread_error != 0) {
@@ -2774,6 +3568,8 @@ FINISH_OFF:
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+ EM_SAFE_FREE(multi_user_name);
+
EM_DEBUG_FUNC_END("err [%d]", err);
}
@@ -2787,8 +3583,7 @@ void* thread_func_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX(void *input_param)
email_account_t* ref_account = NULL;
task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX *task_param = input_param;
- ref_account = emcore_get_account_reference(task_param->account_id);
-
+ ref_account = emcore_get_account_reference(task_param->multi_user_name, task_param->account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", task_param->account_id);
err = EMAIL_ERROR_INVALID_ACCOUNT;
@@ -2804,7 +3599,7 @@ void* thread_func_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX(void *input_param)
if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
- if((err = emcore_delete_mailbox_ex(task_param->account_id, task_param->mailbox_id_array, task_param->mailbox_id_count, task_param->on_server, recursive)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_delete_mailbox_ex(task_param->multi_user_name, task_param->account_id, task_param->mailbox_id_array, task_param->mailbox_id_count, task_param->on_server, recursive)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_delete_mailbox_ex failed[%d]", err);
goto FINISH_OFF;
}
@@ -2827,6 +3622,7 @@ FINISH_OFF:
/* Free task parameter */
EM_SAFE_FREE(task_param->mailbox_id_array);
+ EM_SAFE_FREE(task_param->multi_user_name);
EM_SAFE_FREE(task_param);
EM_DEBUG_FUNC_END("err [%d]", err);
@@ -2843,6 +3639,13 @@ void stb_delete_mailbox_ex(HIPC_API a_hAPI)
thread_t task_id;
char *task_parameter = NULL;
task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX *decoded_parameter = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* task_parameter_length */;
task_parameter_length = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
@@ -2861,6 +3664,8 @@ void stb_delete_mailbox_ex(HIPC_API a_hAPI)
goto FINISH_OFF;
}
+ decoded_parameter->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
THREAD_CREATE(task_id, thread_func_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, (void*)decoded_parameter, thread_error);
if(thread_error != 0) {
@@ -2881,6 +3686,7 @@ FINISH_OFF:
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END("err [%d]", err);
}
@@ -2896,7 +3702,7 @@ void* thread_func_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIG
if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
- if((err = emcore_send_mail_with_downloading_attachment_of_original_mail(task_param->mail_id)) != EMAIL_ERROR_NONE) {
+ if((err = emcore_send_mail_with_downloading_attachment_of_original_mail(task_param->multi_user_name, task_param->mail_id)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_send_mail_with_downloading_attachment_of_original_mail failed [%d]", err);
goto FINISH_OFF;
}
@@ -2913,6 +3719,7 @@ FINISH_OFF:
}
/* Free task parameter */
+ EM_SAFE_FREE(task_param->multi_user_name);
EM_SAFE_FREE(task_param);
emcore_close_smtp_stream_list();
EM_DEBUG_FUNC_END("err [%d]", err);
@@ -2929,6 +3736,13 @@ void stb_send_mail_with_downloading_attachment_of_original_mail(HIPC_API a_hAPI)
thread_t task_id;
char *task_parameter = NULL;
task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL *decoded_parameter = NULL;
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+ multi_user_name = NULL;
+ }
/* task_parameter_length */;
task_parameter_length = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
@@ -2947,6 +3761,8 @@ void stb_send_mail_with_downloading_attachment_of_original_mail(HIPC_API a_hAPI)
goto FINISH_OFF;
}
+ decoded_parameter->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
THREAD_CREATE(task_id, thread_func_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, (void*)decoded_parameter, thread_error);
if(thread_error != 0) {
@@ -2967,17 +3783,118 @@ FINISH_OFF:
if (!emipc_execute_stub_api(a_hAPI))
EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+ EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END("err [%d]", err);
}
+void stb_save_default_account_id(HIPC_API a_hAPI)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ int account_id = 0;
+
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_name failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
+ /* account_id */
+ emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
+ EM_DEBUG_LOG("account_id [%d]", account_id);
+
+ err = emcore_save_default_account_id(multi_user_name, account_id);
+ if (err != EMAIL_ERROR_NONE) EM_DEBUG_EXCEPTION("emcore_save_default_account_id failed [%d]", err);
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_FUNC_END();
+}
+
+void stb_load_default_account_id(HIPC_API a_hAPI)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ int account_id = 0;
+
+ int nAPPID = emipc_get_app_id(a_hAPI);
+ char *multi_user_name = NULL;
+
+ if ((err = emcore_get_user_name(nAPPID, &multi_user_name)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_user_name failed : [%d]", err);
+ multi_user_name = NULL;
+ }
+
+ err = emcore_load_default_account_id(multi_user_name, &account_id);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_save_default_account_id failed [%d]", err);
+ }
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+
+ if (err == EMAIL_ERROR_NONE) {
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &account_id, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ }
+
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ EM_SAFE_FREE(multi_user_name);
+ EM_DEBUG_FUNC_END();
+}
+
+void stb_get_user_name(HIPC_API a_hAPI)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMAIL_ERROR_NONE;
+ int pid = 0;
+
+ char *user_name = NULL;
+
+ pid = emipc_get_app_id(a_hAPI);
+ EM_DEBUG_LOG("Peer PID : [%d]", pid);
+
+ if (pid > 0) {
+ if ((err = emcore_get_user_name(pid, &user_name)) != EMAIL_ERROR_NONE)
+ EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
+
+ EM_DEBUG_LOG("Domain name : [%s]", user_name);
+
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+
+ if (user_name) {
+ if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, user_name, EM_SAFE_STRLEN(user_name) + 1))
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ }
+ }
+
+ if (!emipc_execute_stub_api(a_hAPI))
+ EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
+
+ EM_SAFE_FREE(user_name);
+
+ EM_DEBUG_FUNC_END();
+}
+
void stb_API_mapper(HIPC_API a_hAPI)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- int nAPIID = emipc_get_api_id(a_hAPI);
+ long nAPIID = emipc_get_api_id(a_hAPI);
#ifdef __FEATURE_ACCESS_CONTROL__
- int nAPPID = emipc_get_app_id(a_hAPI);
+ long nAPPID = emipc_get_app_id(a_hAPI);
err = em_check_socket_privilege_by_pid(nAPPID);
if (err == EMAIL_ERROR_PERMISSION_DENIED) {
EM_DEBUG_LOG("permission denied");
@@ -3012,6 +3929,10 @@ void stb_API_mapper(HIPC_API a_hAPI)
stb_set_local_mailbox(a_hAPI);
break;
+ case _EMAIL_API_STAMP_SYNC_TIME_OF_MAILBOX:
+ stb_stamp_sync_time_of_mailbox(a_hAPI);
+ break;
+
case _EMAIL_API_SET_MAIL_SLOT_SIZE:
stb_set_mail_slot_size_of_mailbox(a_hAPI);
break;
@@ -3176,6 +4097,14 @@ void stb_API_mapper(HIPC_API a_hAPI)
stb_cancel_send_mail_job(a_hAPI);
break;
+ case _EMAIL_API_SEARCH_MAIL_ON_SERVER :
+ stb_search_mail_on_server(a_hAPI);
+ break;
+
+ case _EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER :
+ stb_clear_result_of_search_mail_on_server(a_hAPI);
+ break;
+
case _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION :
stb_add_account_with_validation(a_hAPI);
break;
@@ -3248,6 +4177,18 @@ void stb_API_mapper(HIPC_API a_hAPI)
stb_send_mail_with_downloading_attachment_of_original_mail(a_hAPI);
break;
+ case _EMAIL_API_GET_USER_NAME :
+ stb_get_user_name(a_hAPI);
+ break;
+
+ case _EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID :
+ stb_save_default_account_id(a_hAPI);
+ break;
+
+ case _EMAIL_API_LOAD_DEFAULT_ACCOUNT_ID :
+ stb_load_default_account_id(a_hAPI);
+ break;
+
default :
if(EMAIL_SYNC_TASK_BOUNDARY_START < nAPIID && nAPIID < EMAIL_ASYNC_TASK_BOUNDARY_END)
stb_handle_task(nAPIID, a_hAPI);
@@ -3265,26 +4206,63 @@ INTERNAL_FUNC int kill_daemon_if_no_account()
int err = EMAIL_ERROR_NONE;
email_account_t *account_list = NULL;
int account_count = 0;
+ int total_account_count = 0;
+ GList *node = NULL;
+ GList *zone_name_list = NULL;
+
+ /* each container check the account */
+ if ((err = emcore_get_zone_name_list(&zone_name_list)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_zone_name_list failed : err[%d]", err);
+ if (zone_name_list) g_list_free(zone_name_list);
+ goto FINISH_OFF;
+ }
+
+ if (g_list_length(zone_name_list) <= 1) {
+ if ((err = emcore_get_account_reference_list(NULL, &account_list, &account_count)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
+ }
+
+ if (account_list)
+ emcore_free_account_list(&account_list, account_count, NULL);
+
+ total_account_count += account_count;
+ } else {
+ node = g_list_first(zone_name_list);
+ while (node != NULL) {
+ if (!node->data) {
+ node = g_list_next(node);
+ continue;
+ }
- if (!emcore_get_account_reference_list(&account_list, &account_count, &err)) {
- EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
- }
+ if ((err = emcore_get_account_reference_list(node->data, &account_list, &account_count)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_LOG("emcore_get_account_reference_list failed [%d]", err);
+ }
+
+ if (account_list)
+ emcore_free_account_list(&account_list, account_count, NULL);
+
+ total_account_count += account_count;
+ EM_SAFE_FREE(node->data);
+ node = g_list_next(node);
+ }
+ }
- EM_DEBUG_LOG("account_count [%d]", account_count);
+ if (zone_name_list)
+ g_list_free(zone_name_list);
- if (account_count == 0) {
+ EM_DEBUG_LOG("account_count [%d]", total_account_count);
+
+ if (total_account_count == 0) {
EM_DEBUG_LOG("email-service is going to shutdown");
g_main_loop_quit (g_mainloop);
}
- if(account_list)
- emcore_free_account_list(&account_list, account_count, NULL);
+FINISH_OFF:
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
-
static void callback_for_sigterm(int signum)
{
EM_DEBUG_FUNC_BEGIN("signum [%d]", signum);
@@ -3429,11 +4407,16 @@ INTERNAL_FUNC int main(int argc, char *argv[])
int err = 0, ret;
GMainLoop *mainloop = NULL;
int owner_id = 0;
+ GList *node = NULL;
+ GList *zone_name_list = NULL;
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif
+ /* Init container for daemon */
+ emcore_create_container();
+
EM_DEBUG_LOG("ipcEmailStub_Initialize Start");
ret = emipc_initialize_stub(stb_API_mapper);
@@ -3446,11 +4429,35 @@ INTERNAL_FUNC int main(int argc, char *argv[])
signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */
signal(SIGTERM, callback_for_sigterm); /* to handle signal 15(SIGTERM) - power off case*/
- emcore_connect_contacts_service();
-
emcore_gmime_init();
+ emcore_init_dbus_call_status();
+
+ /* each container initialize */
+ if ((err = emcore_get_zone_name_list(&zone_name_list)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_zone_name_list failed : err[%d]", err);
+ if (zone_name_list) g_list_free(zone_name_list);
+ goto FINISH_OFF;
+ }
+
+ if (g_list_length(zone_name_list) <= 1) {
+ emdaemon_initialize(NULL, &err);
+ emcore_connect_contacts_service(NULL);
+ } else {
+ node = g_list_first(zone_name_list);
+ while (node != NULL) {
+ if (!node->data)
+ node = g_list_next(node);
+
+ emdaemon_initialize(node->data, &err);
+ emcore_connect_contacts_service(node->data);
- emdaemon_initialize(&err);
+ EM_SAFE_FREE(node->data);
+ node = g_list_next(node);
+ }
+ }
+
+ if (zone_name_list)
+ g_list_free(zone_name_list);
g_timeout_add(5000, callback_for_shutdown, NULL);
@@ -3498,9 +4505,12 @@ INTERNAL_FUNC int main(int argc, char *argv[])
g_main_loop_unref(mainloop);
g_mainloop = NULL;
+FINISH_OFF:
+
emipc_finalize_stub();
emdaemon_finalize(NULL);
emcore_gmime_shutdown();
+ emcore_shutdown_dbus_call_status();
EM_DEBUG_LOG ("Goodbye, world");
EM_DEBUG_FUNC_END();
diff --git a/email-ipc/CMakeLists.txt b/email-ipc/CMakeLists.txt
index 1b50a60..8b21134 100755
--- a/email-ipc/CMakeLists.txt
+++ b/email-ipc/CMakeLists.txt
@@ -66,7 +66,7 @@ TARGET_LINK_LIBRARIES(${IPC-LIB} ${ipc_pkgs_LDFLAGS} email-common-use pthread)
SET_TARGET_PROPERTIES(${IPC-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${IPC-LIB} PROPERTIES VERSION ${VERSION})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/email-activation/email-service.service DESTINATION share/dbus-1/services)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/email-activation/email-service.service DESTINATION share/dbus-1/system-services)
INSTALL(TARGETS ${IPC-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
diff --git a/email-ipc/email-activation/email-dbus-activation.c b/email-ipc/email-activation/email-dbus-activation.c
index e13b5f9..83569a5 100755
--- a/email-ipc/email-activation/email-dbus-activation.c
+++ b/email-ipc/email-activation/email-dbus-activation.c
@@ -49,11 +49,13 @@ EXPORT_API const gchar introspection_xml[] =
" </method>"
" <method name='GetDisplayName'>"
" <arg type='s' name='email_address' direction='in' />"
+" <arg type='s' name='multi_user_name' direction='in' />"
" <arg type='s' name='contact_display_name' direction='out' />"
" <arg type='i' name='ret' direction='out' />"
" </method>"
" <method name='CheckBlockingMode'>"
" <arg type='s' name='sender_address' direction='in' />"
+" <arg type='s' name='multi_user_name' direction='in' />"
" <arg type='i' name='blocking_mode' direction='out' />"
" <arg type='i' name='ret' direction='out' />"
" </method>"
@@ -127,7 +129,7 @@ EXPORT_API int emipc_launch_email_service()
goto FINISH_OFF;
}
- g_variant_get (result, "(&d)", &ret);
+ g_variant_get (result, "(i)", &ret);
FINISH_OFF:
EM_DEBUG_LOG ("ret [%d]\n", ret);
@@ -150,18 +152,19 @@ void cancellable_connect_cb ()
EXPORT_API GCancellable *cancel = NULL;
-
GVariant* em_gdbus_get_display_name (GVariant *parameters)
{
- char *email_address = NULL;
- char *contact_display_name = NULL;
- g_variant_get (parameters, "(s)", &email_address);
+ char *email_address = NULL;
+ char *multi_user_name = NULL;
+ char *contact_display_name = NULL;
+
+ g_variant_get (parameters, "(ss)", &email_address, &multi_user_name);
/* replace "" to NULL */
if (!g_strcmp0(email_address,""))
EM_SAFE_FREE (email_address);
- int err = emcore_get_mail_display_name_internal (email_address, &contact_display_name);
+ int err = emcore_get_mail_display_name_internal (multi_user_name, email_address, &contact_display_name);
/* make return_val */
if (!contact_display_name) {
@@ -179,16 +182,19 @@ GVariant* em_gdbus_get_display_name (GVariant *parameters)
GVariant* em_gdbus_check_blocking_mode (GVariant *parameters)
{
char *sender_address = NULL;
+ char *multi_user_name = NULL;
int blocking_mode = 0;
- g_variant_get (parameters, "(s)", &sender_address);
- int err = emcore_check_blocking_mode_internal (sender_address, &blocking_mode);
+ g_variant_get (parameters, "(ss)", &sender_address, &multi_user_name);
+
+ int err = emcore_check_blocking_mode_internal (multi_user_name, sender_address, &blocking_mode);
/* make return_val */
GVariant* ret = g_variant_new ("(ii)", blocking_mode, err);
/* clean-up string */
EM_SAFE_FREE (sender_address);
+ EM_SAFE_FREE (multi_user_name);
return ret;
}
diff --git a/email-ipc/email-ipc-api.c b/email-ipc/email-ipc-api.c
index c2d527f..695c4db 100755
--- a/email-ipc/email-ipc-api.c
+++ b/email-ipc/email-ipc-api.c
@@ -70,7 +70,7 @@ EXPORT_API void emipc_destroy_email_api(HIPC_API api)
EXPORT_API long emipc_get_api_id(HIPC_API api)
{
EM_DEBUG_FUNC_BEGIN();
- emipc_email_api_info *api_info = (emipc_email_api_info*)api;
+ emipc_email_api_info *api_info = (emipc_email_api_info *)api;
EM_DEBUG_FUNC_END("api_id [%d]", api_info->api_id);
return api_info->api_id;
}
@@ -79,6 +79,7 @@ EXPORT_API long emipc_get_app_id(HIPC_API api)
{
EM_DEBUG_FUNC_BEGIN();
emipc_email_api_info *api_info = (emipc_email_api_info *)api;
+ EM_DEBUG_FUNC_END("app_id [%d]", api_info->app_id);
return api_info->app_id;
}
@@ -128,14 +129,12 @@ EXPORT_API int emipc_get_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTI
}
parameters = emipc_get_api_parameters(input_api_handle, input_parameter_direction);
-
if (parameters == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
}
local_buffer = emipc_get_param_of_param_list(parameters, input_parameter_index);
-
if (local_buffer == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
@@ -160,14 +159,12 @@ EXPORT_API void* emipc_get_nth_parameter_data(HIPC_API api_handle, EPARAMETER_DI
void *buf = NULL;
parameters = emipc_get_api_parameters(api_handle, direction);
-
if (parameters == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return NULL;
}
buf = emipc_get_param_of_param_list(parameters, param_index);
-
if (!buf) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE");
return NULL;
@@ -183,7 +180,7 @@ EXPORT_API int emipc_get_parameter_length(HIPC_API api, EPARAMETER_DIRECTION dir
EM_DEBUG_FUNC_BEGIN();
emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
if (parameters) {
- EM_DEBUG_FUNC_END("Suceeded");
+ EM_DEBUG_LOG("Suceeded");
return emipc_get_param_len_of_param_list(parameters, parameter_index);
}
EM_DEBUG_FUNC_END("Failed");
@@ -195,7 +192,7 @@ EXPORT_API int emipc_get_nth_parameter_length(HIPC_API api, EPARAMETER_DIRECTION
EM_DEBUG_FUNC_BEGIN();
emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
if (parameters) {
- EM_DEBUG_FUNC_END("Suceeded");
+ EM_DEBUG_LOG("Suceeded");
return emipc_get_param_len_of_param_list(parameters, parameter_index);
}
EM_DEBUG_FUNC_END("Failed");
@@ -244,11 +241,60 @@ EXPORT_API int emipc_execute_proxy_task(email_task_type_t input_task_type, void
emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
- FINISH_OFF:
- if(hAPI)
+FINISH_OFF:
+
+ EM_SAFE_FREE(task_parameter_stream);
+
+ if (hAPI)
emipc_destroy_email_api(hAPI);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
+EXPORT_API int emipc_get_user_name(char **output_user_name)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMAIL_ERROR_NONE;
+
+ if (!output_user_name) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ err = EMAIL_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ int buffer_size = 0;
+ char *user_name = NULL;
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_USER_NAME);
+ if(!emipc_execute_proxy_api(hAPI)) {
+ EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed");
+ err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ if (err != EMAIL_ERROR_NONE)
+ goto FINISH_OFF;
+
+ buffer_size = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1);
+ if (buffer_size > 0) {
+ user_name = (char *)malloc(buffer_size);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, buffer_size, user_name);
+ EM_DEBUG_LOG("Name : [%s]", user_name);
+ }
+
+FINISH_OFF:
+
+ *output_user_name = EM_SAFE_STRDUP(user_name);
+
+ EM_SAFE_FREE(user_name);
+
+ if (hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END();
+
+ return err;
+}
diff --git a/email-ipc/email-ipc-api/email-ipc-api-info.c b/email-ipc/email-ipc-api/email-ipc-api-info.c
index 76e1ee4..de8e88f 100755
--- a/email-ipc/email-ipc-api/email-ipc-api-info.c
+++ b/email-ipc/email-ipc-api/email-ipc-api-info.c
@@ -50,8 +50,8 @@ EXPORT_API bool emipc_deserialize_api_info(emipc_email_api_info *api_info, EPARA
}
api_info->api_id = *((long *)stream + eSTREAM_APIID);
- api_info->app_id = *((long*)stream + eSTREAM_APPID);
- api_info->response_id = *((long*)stream + eSTREAM_RESID);
+ api_info->app_id = *((long *)stream + eSTREAM_APPID);
+ api_info->response_id = *((long *)stream + eSTREAM_RESID);
return emipc_parse_stream_of_param_list(api_info->params[direction], stream);
}
diff --git a/email-ipc/email-ipc-api/email-ipc-param-list.c b/email-ipc/email-ipc-api/email-ipc-param-list.c
index aeb471e..bef1353 100755
--- a/email-ipc/email-ipc-api/email-ipc-param-list.c
+++ b/email-ipc/email-ipc-api/email-ipc-param-list.c
@@ -70,27 +70,28 @@ EXPORT_API bool emipc_parse_stream_of_param_list(emipc_param_list *param_list, v
{
EM_DEBUG_FUNC_BEGIN();
long parameter_count = *((long *)stream + eSTREAM_COUNT);
- if(parameter_count < 0) {
+
+ if (parameter_count < 0) {
EM_DEBUG_LOG("INVALID_PARAM : count %d", parameter_count);
return false;
}
- if(parameter_count == 0) {
+ if (parameter_count == 0) {
EM_DEBUG_LOG("count %d", parameter_count);
return true;
}
int stream_len = malloc_usable_size(stream);
int remain_len = stream_len - (sizeof(long) * eSTREAM_DATA);
- EM_DEBUG_LOG_DEV ("Allocated stream size : %dbyte", stream_len);
+ EM_DEBUG_LOG_DEV("Allocated stream size : %dbyte", stream_len);
- unsigned char* cur = ((unsigned char*)stream) + sizeof(int)*eSTREAM_DATA;
+ unsigned char* cur = ((unsigned char *)stream) + (sizeof(long) * eSTREAM_DATA);
int i = 0;
/* stream is composed of data type which is encoded into length and data field */
int len = 0;
- for(i = 0; i < parameter_count; i++) {
+ for (i = 0; i < parameter_count; i++) {
if (remain_len < sizeof(int)) {
EM_DEBUG_EXCEPTION("Not enough remain stream_len[%d]", remain_len);
return false;
@@ -104,13 +105,13 @@ EXPORT_API bool emipc_parse_stream_of_param_list(emipc_param_list *param_list, v
remain_len -= sizeof(int);
if (remain_len > 0 && len > 0 && remain_len >= len)
- emipc_add_param_to_param_list(param_list, (void*)cur, len);
+ emipc_add_param_to_param_list(param_list, (void *)cur, len);
else {
EM_DEBUG_EXCEPTION("data_len[%d] is not in the boundary of remain stream_len", len);
return false;
}
- EM_DEBUG_LOG("Parsing stream : element %d is %dbyte long ", i, len);
+ EM_DEBUG_LOG("Parsing stream : element %d is %dbyte integer", i, len);
/* move to next parameter */
cur += len;
@@ -151,6 +152,7 @@ EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_lis
memcpy((param_list->byte_stream + pos), &param_list->param_count, sizeof(param_list->param_count));
+ /* Add param count */
pos += sizeof(long);
int index = 0, length = 0;
@@ -165,14 +167,14 @@ EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_lis
goto FINISH_OFF;
}
- if (pos + (int)sizeof(long) > stream_len) {
- EM_DEBUG_EXCEPTION("%d > stream_len", pos + sizeof(long));
+ if (pos + (int)sizeof(int) > stream_len) {
+ EM_DEBUG_EXCEPTION("%d > stream_len", pos + sizeof(int));
EM_SAFE_FREE(param_list->byte_stream);
goto FINISH_OFF;
}
/* write param i length */
- memcpy((param_list->byte_stream+pos), &length, sizeof(long));
- pos += sizeof(long);
+ memcpy((param_list->byte_stream+pos), &length, sizeof(int));
+ pos += sizeof(int);
if (pos + length > stream_len) {
EM_DEBUG_EXCEPTION("%d > stream_len", pos + length);
@@ -180,7 +182,7 @@ EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_lis
goto FINISH_OFF;
}
/* write param i data if length is greater than 0 */
- if( length > 0 ) {
+ if (length > 0) {
memcpy((param_list->byte_stream+pos), emipc_get_data(param_list->params[index]), length);
pos += length;
}
@@ -198,7 +200,7 @@ EXPORT_API int emipc_sum_param_list_length(emipc_param_list *param_list)
int length = sizeof(long) * eSTREAM_DATA;
int index;
for (index = 0; index < param_list->param_count; index++) {
- length += sizeof(long);
+ length += sizeof(int);
length += emipc_get_length(param_list->params[index]);
}
return length;
@@ -227,7 +229,7 @@ EXPORT_API void *emipc_get_param_of_param_list(emipc_param_list *param_list, int
{
EM_DEBUG_FUNC_BEGIN("index [%d]", index);
if (index < 0 || index >= param_list->param_count) {
- EM_DEBUG_EXCEPTION("Index value is not valid");
+// EM_DEBUG_EXCEPTION("Index value is not valid");
return NULL;
}
return emipc_get_data(param_list->params[index]);
@@ -237,7 +239,7 @@ EXPORT_API int emipc_get_param_len_of_param_list(emipc_param_list *param_list, i
{
EM_DEBUG_FUNC_BEGIN();
if (index < 0 || index >= param_list->param_count) {
- EM_DEBUG_EXCEPTION("Index valud is not valid");
+// EM_DEBUG_EXCEPTION("Index value is not valid");
return 0;
}
return emipc_get_length(param_list->params[index]);
diff --git a/email-ipc/email-ipc-api/include/email-ipc-api-info.h b/email-ipc/email-ipc-api/include/email-ipc-api-info.h
index d11ad64..1ff6cc3 100755
--- a/email-ipc/email-ipc-api/include/email-ipc-api-info.h
+++ b/email-ipc/email-ipc-api/include/email-ipc-api-info.h
@@ -80,6 +80,9 @@ EXPORT_API void emipc_free_api_info(emipc_email_api_info *api_info);
case _EMAIL_API_SET_LOCAL_MAILBOX:\
s = "_EMAIL_API_SET_LOCAL_MAILBOX";\
break;\
+ case _EMAIL_API_STAMP_SYNC_TIME_OF_MAILBOX:\
+ s = "_EMAIL_API_STAMP_SYNC_TIME_OF_MAILBOX";\
+ break;\
case _EMAIL_API_SET_MAIL_SLOT_SIZE:\
s = "_EMAIL_API_SET_MAIL_SLOT_SIZE";\
break;\
@@ -194,6 +197,9 @@ EXPORT_API void emipc_free_api_info(emipc_email_api_info *api_info);
case _EMAIL_API_SEND_MAIL_CANCEL_JOB :\
s = "_EMAIL_API_SEND_MAIL_CANCEL_JOB";\
break;\
+ case _EMAIL_API_SEARCH_MAIL_ON_SERVER :\
+ s = "_EMAIL_API_SEARCH_MAIL_ON_SERVER";\
+ break;\
case _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION :\
s = "_EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION";\
break;\
@@ -224,6 +230,12 @@ EXPORT_API void emipc_free_api_info(emipc_email_api_info *api_info);
case _EMAIL_API_GET_TASK_INFORMATION:\
s = "_EMAIL_API_GET_TASK_INFORMATION";\
break;\
+ case _EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID:\
+ s = "_EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID";\
+ break;\
+ case _EMAIL_API_LOAD_DEFAULT_ACCOUNT_ID:\
+ s = "_EMAIL_API_LOAD_DEFAULT_ACCOUNT_ID";\
+ break;\
default : \
s = "UNKNOWN_APIID";\
}\
diff --git a/email-ipc/email-ipc-api/include/email-ipc-param-list.h b/email-ipc/email-ipc-api/include/email-ipc-param-list.h
index e12c17b..dab2e0b 100755
--- a/email-ipc/email-ipc-api/include/email-ipc-param-list.h
+++ b/email-ipc/email-ipc-api/include/email-ipc-param-list.h
@@ -36,7 +36,7 @@ typedef enum {
}IPC_STREAM_INFO;
typedef struct {
- int param_count;
+ long param_count;
emipc_param params[10];
unsigned char *byte_stream;
} emipc_param_list;
diff --git a/email-ipc/email-ipc-proxy.c b/email-ipc/email-ipc-proxy.c
index b0c4342..fff5db6 100755
--- a/email-ipc/email-ipc-proxy.c
+++ b/email-ipc/email-ipc-proxy.c
@@ -28,7 +28,6 @@
#include "email-proxy-socket.h"
#include "email-debug-log.h"
-#include "email-api.h"
#include "email-types.h"
#include "email-internal-types.h"
#include "email-dbus-activation.h"
diff --git a/email-ipc/email-proxy/email-proxy-main.c b/email-ipc/email-proxy/email-proxy-main.c
index de0e048..fcba8d1 100755
--- a/email-ipc/email-proxy/email-proxy-main.c
+++ b/email-ipc/email-proxy/email-proxy-main.c
@@ -43,7 +43,7 @@ EXPORT_API int emipc_initialize_proxy_main()
if (sock_fd) {
EM_DEBUG_LOG("Socket already initialized");
- return EMAIL_ERROR_IPC_ALREADY_INITIALIZED;
+ return err;
}
if ((err = emipc_start_proxy_socket()) != EMAIL_ERROR_NONE) {
diff --git a/email-ipc/email-proxy/email-proxy-socket.c b/email-ipc/email-proxy/email-proxy-socket.c
index f9c2452..584fdff 100755
--- a/email-ipc/email-proxy/email-proxy-socket.c
+++ b/email-ipc/email-proxy/email-proxy-socket.c
@@ -35,6 +35,7 @@
#include <glib.h>
#include <pthread.h>
#include <sys/types.h>
+#include <sys/epoll.h>
#include <unistd.h>
typedef struct {
@@ -90,16 +91,16 @@ EXPORT_API bool emipc_end_proxy_socket()
ENTER_CRITICAL_SECTION(proxy_mutex);
GList *cur = socket_head;
- while( cur ) {
+ while (cur) {
thread_socket_t* cur_socket = g_list_nth_data(cur,0);
/* close the socket of current thread */
- if( tid == cur_socket->tid ) {
+ if (tid == cur_socket->tid) {
emipc_close_email_socket(&cur_socket->socket_fd);
EM_SAFE_FREE(cur_socket);
GList *del = cur;
cur = g_list_next(cur);
- socket_head = g_list_remove_link(socket_head, del);
+ socket_head = g_list_delete_link(socket_head, del);
break;
}
@@ -128,12 +129,14 @@ EXPORT_API bool emipc_end_all_proxy_sockets()
EM_SAFE_FREE(cur_socket);
GList *del = cur;
cur = g_list_next(cur);
- socket_head = g_list_remove_link(socket_head, del);
+ socket_head = g_list_delete_link(socket_head, del);
continue;
}
cur = g_list_next(cur);
}
+ g_list_free(socket_head);
+ socket_head = NULL;
LEAVE_CRITICAL_SECTION(proxy_mutex);
return true;
@@ -149,7 +152,7 @@ EXPORT_API int emipc_send_proxy_socket(unsigned char *data, int len)
/* if thread socket is not created */
if (!socket_fd) {
int ret = emipc_start_proxy_socket();
- if(!ret ) {
+ if (!ret) {
EM_DEBUG_EXCEPTION("[IPCLib] emipc_send_proxy_socket not connected");
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
@@ -190,16 +193,19 @@ EXPORT_API int emipc_get_proxy_socket_id()
/* return true, when event occurred
* false, when select error
*/
+
+#define MAX_PROXY_EPOLL_EVENT 100
+
static bool wait_for_reply (int fd)
{
- int err = -1;
- fd_set fds;
- struct timeval tv;
-
if (fd < 0) {
EM_DEBUG_EXCEPTION("Invalid file description : [%d]", fd);
return false;
}
+#if 0
+ int err = -1;
+ fd_set fds;
+ struct timeval tv;
FD_ZERO(&fds);
FD_SET(fd, &fds);
@@ -219,8 +225,54 @@ static bool wait_for_reply (int fd)
}
if (FD_ISSET(fd, &fds)) return true;
+#endif
+
+ int i = 0;
+ int ret = false;
+ int proxy_epfd = -1;
+ int event_num = 0;
+ int timeout = 20000; /* 20 seconds */
+ char errno_buf[ERRNO_BUF_SIZE] = {0};
+ struct epoll_event proxy_ev = {0};
+ struct epoll_event proxy_ev_events[MAX_PROXY_EPOLL_EVENT] = {{0}, };
+
+ proxy_epfd = epoll_create(MAX_PROXY_EPOLL_EVENT);
+ if (proxy_epfd < 0) {
+ EM_DEBUG_EXCEPTION("epoll_create failed : [%d][%s]", errno, EM_STRERROR(errno_buf));
+ goto FINISH_OFF;
+ }
+
+ proxy_ev.data.fd = fd;
+ proxy_ev.events = EPOLLIN | EPOLLONESHOT;
+
+ if (epoll_ctl(proxy_epfd, EPOLL_CTL_ADD, fd, &proxy_ev) == -1) {
+ EM_DEBUG_EXCEPTION("epoll_ctl wait : [%d][%s]", errno, EM_STRERROR(errno_buf));
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("Wait for response poll_fd:[%d], proxy_fd:[%d]", proxy_epfd, fd);
+ event_num = epoll_wait(proxy_epfd, proxy_ev_events, MAX_PROXY_EPOLL_EVENT, timeout);
+ if (event_num == -1) {
+ EM_DEBUG_EXCEPTION("epoll_wait failed : [%d][%s]", errno, EM_STRERROR(errno_buf));
+ goto FINISH_OFF;
+ } else if (event_num == 0) {
+ EM_DEBUG_EXCEPTION("Occured timeout proxy_fd[%d]", fd);
+ goto FINISH_OFF;
+ } else {
+ for (i = 0; i < event_num; i++) {
+ if (proxy_ev_events[i].events & EPOLLIN) {
+ EM_DEBUG_LOG("Received event to stub");
+ ret = true;
+ }
+ }
+ }
+
+FINISH_OFF:
+
+ if (proxy_epfd >= 0)
+ close(proxy_epfd);
- return false;
+ return ret;
}
@@ -235,7 +287,7 @@ EXPORT_API int emipc_recv_proxy_socket(char **data)
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
- if( !wait_for_reply(socket_fd) ) {
+ if (!wait_for_reply(socket_fd)) {
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
diff --git a/email-ipc/email-socket/email-ipc-socket.c b/email-ipc/email-socket/email-ipc-socket.c
index 610286f..83a806d 100755
--- a/email-ipc/email-socket/email-ipc-socket.c
+++ b/email-ipc/email-socket/email-ipc-socket.c
@@ -26,6 +26,8 @@
#include "email-debug-log.h"
#include "email-types.h"
+#include "email-core-container.h"
+
#include <glib.h>
#include <sys/socket.h>
@@ -242,6 +244,8 @@ EXPORT_API int emipc_open_email_socket(int fd, const char *path)
return EMAIL_ERROR_IPC_SOCKET_FAILURE;
}
+ emcore_set_declare_link(path);
+
/**
* determine permission of socket file
*
diff --git a/email-ipc/email-stub/email-stub-main.c b/email-ipc/email-stub/email-stub-main.c
index 0cde0a5..64e62ff 100755
--- a/email-ipc/email-stub/email-stub-main.c
+++ b/email-ipc/email-stub/email-stub-main.c
@@ -29,7 +29,6 @@
#include "email-stub-socket.h"
#include "email-stub-task-manager.h"
-#include "email-api.h"
#include "email-debug-log.h"
static bool stub_socket = false;
diff --git a/email-ipc/email-stub/email-stub-task-manager.c b/email-ipc/email-stub/email-stub-task-manager.c
index 5b8185b..3052b42 100755
--- a/email-ipc/email-stub/email-stub-task-manager.c
+++ b/email-ipc/email-stub/email-stub-task-manager.c
@@ -20,6 +20,8 @@
*/
+#define _GNU_SOURCE
+#include <sys/socket.h>
#include <string.h>
#include <pthread.h>
@@ -31,7 +33,6 @@
#include "email-ipc-build.h"
#include "email-debug-log.h"
-#include "email-api.h"
#include "email-internal-types.h"
#include "email-utilities.h"
@@ -48,11 +49,10 @@ EXPORT_API bool emipc_start_task_thread()
if (task_thread)
return true;
- char errno_buf[ERRNO_BUF_SIZE] = {0};
task_queue = g_queue_new();
if (pthread_create(&task_thread, NULL, &emipc_do_task_thread, NULL) != 0) {
- EM_DEBUG_LOG("Worker thread creation failed: %s", EM_STRERROR(errno_buf));
+ EM_DEBUG_EXCEPTION("Worker thread creation failed: [%d]", errno);
return false;
}
@@ -127,8 +127,8 @@ EXPORT_API int emipc_create_task(unsigned char *task_stream, int response_channe
} else {
if (!emipc_parse_stream_email_task(task, task_stream, response_channel)) {
EM_DEBUG_EXCEPTION("emipc_parse_stream_email_task failed");
- emipc_free_email_task(task);
- EM_SAFE_FREE(task);
+ emipc_free_email_task(task);
+ EM_SAFE_FREE(task);
return err;
}
@@ -140,13 +140,28 @@ EXPORT_API int emipc_create_task(unsigned char *task_stream, int response_channe
task->api_info->app_id);
EM_DEBUG_LOG_DEV ("[IPCLib] ======================================================");
+ struct ucred uc;
+ socklen_t uc_len = sizeof(uc);
+
+ if (getsockopt(response_channel, SOL_SOCKET, SO_PEERCRED, &uc, &uc_len) < 0) {
+ EM_DEBUG_EXCEPTION("getsockopt error : [%d]", errno);
+ emipc_free_email_task(task);
+ EM_SAFE_FREE(task);
+ err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
+ return err;
+ }
+
+ EM_DEBUG_LOG("Peer PID : [%d]", uc.pid);
+
+ task->api_info->app_id = uc.pid;
+
/*check privilege*/
#ifdef __FEATURE_ACCESS_CONTROL__
err = em_check_db_privilege_by_pid(task->api_info->app_id);
if (err == EMAIL_ERROR_PERMISSION_DENIED) {
EM_DEBUG_LOG("permission denied");
- emipc_free_email_task(task);
- EM_SAFE_FREE(task);
+ emipc_free_email_task(task);
+ EM_SAFE_FREE(task);
return err;
}
#endif
diff --git a/email-ipc/email-stub/email-stub-task.c b/email-ipc/email-stub/email-stub-task.c
index f00f078..6c5d0a0 100755
--- a/email-ipc/email-stub/email-stub-task.c
+++ b/email-ipc/email-stub/email-stub-task.c
@@ -30,7 +30,6 @@
#include "email-stub-task.h"
#include "email-stub-main.h"
-#include "email-api.h"
#include "email-debug-log.h"
EXPORT_API void emipc_free_email_task(emipc_email_task *task)
diff --git a/email-ipc/include/email-ipc.h b/email-ipc/include/email-ipc.h
index 5af460c..3fb55aa 100755
--- a/email-ipc/include/email-ipc.h
+++ b/email-ipc/include/email-ipc.h
@@ -24,6 +24,7 @@
#define __IPC_LIBRARY_H
#include "email-types.h"
+#include "email-internal-types.h"
#ifdef __cplusplus
extern "C" {
@@ -81,6 +82,8 @@ EXPORT_API int emipc_get_parameter_length(HIPC_API input_api_handle, EPARAMETER_
EXPORT_API int emipc_get_nth_parameter_length(HIPC_API input_api_handle, EPARAMETER_DIRECTION input_parameter_direction, int input_parameter_index);
EXPORT_API int emipc_execute_proxy_task(email_task_type_t input_task_type, void *input_task_parameter);
+
+EXPORT_API int emipc_get_user_name(char **output_user_name);
#ifdef __cplusplus
}
#endif
diff --git a/email-service.manifest b/email-service.manifest
index 91b023b..91a23f4 100755
--- a/email-service.manifest
+++ b/email-service.manifest
@@ -1,55 +1,97 @@
<manifest>
<define>
- <domain name="email-service"/>
- <provide>
- <label name="email-service::read"/>
- <label name="email-service::write"/>
- </provide>
- <!--
- <provide>
- <label name="email-service::db"/>
- </provide>
- <request>
- <smack request="email-service::db" type="rw"/>
- <smack request="system::use_internet" type="w"/>
- <smack request="system::vconf" type="arwxt"/>
- </request>
- <permit>
- <smack permit="system::use_internet" type="rwx"/>
- </permit>
- -->
- <request>
- <smack request="contacts-service::svc" type="r"/>
- <smack request="contacts-service::phonelog" type="rw"/>
- <smack request="msg-service::wappush" type="rw"/>
- <smack request="system::vconf_inhouse" type="r"/>
- <smack request="secure-storage::pkcs12" type="r"/>
- <smack request="secure-storage::email-service" type="rw"/>
- </request>
- </define>
+ <domain name="email-service"/>
+ <provide>
+ <label name="email-service::read"/>
+ <label name="email-service::write"/>
+ </provide>
+ <!--
+ <provide>
+ <label name="email-service::db"/>
+ </provide>
+ -->
+ <permit>
+ <smack permit="connman" type="rw"/>
+ <smack permit="libaccounts-svc" type="rx"/>
+ <smack permit="org.tizen.app-selector" type="x"/>
+ <smack permit="org.tizen.indicator" type="rwx"/>
+ <smack permit="org.tizen.lockscreen" type="rx"/>
+ <smack permit="org.tizen.quickpanel" type="rx"/>
+ <smack permit="secure-storage" type="w"/>
+ <smack permit="system::share" type="rwx"/>
+ <smack permit="system::use_internet" type="rwx"/>
+ </permit>
+ <request>
+ <smack request="_" type="t"/>
+ <smack request="alarm-server::alarm" type="w"/>
+ <smack request="badge::db" type="rw"/>
+ <smack request="ca-certificates::ssl-certs" type="rx"/>
+ <smack request="cert-svc" type="rwx"/>
+ <smack request="connman" type="rw"/>
+ <smack request="connman::set" type="rw"/>
+ <smack request="connman::get" type="rw"/>
+ <smack request="contacts-service" type="wx"/>
+ <smack request="contacts-service::svc" type="r"/>
+ <smack request="contacts-service::phonelog" type="rw"/>
+ <smack request="data-provider-master" type="rw"/>
+ <smack request="data-provider-master::badge" type="w"/>
+ <smack request="data-provider-master::badge.client" type="w"/>
+ <smack request="data-provider-master::notification" type="w"/>
+ <smack request="data-provider-master::notification.client" type="w"/>
+ <smack request="device::app_logging" type="rw"/>
+ <smack request="device::sys_logging" type="rw"/>
+ <smack request="deviced::display" type="rw"/>
+ <smack request="email-service::db" type="rw"/>
+ <smack request="email-service::email_data" type="rwaxt"/>
+ <smack request="email-service::write" type="rw"/>
+ <smack request="libaccounts-svc::db" type="rw"/>
+ <smack request="notification::db" type="rl"/>
+ <smack request="msg-service::wappush" type="rw"/>
+ <smack request="pkgmgr::db" type="rl"/>
+ <smack request="secure-storage::email-service" type="rw"/>
+ <smack request="secure-storage::pkcs12" type="r"/>
+ <smack request="security-server::api-privilege-by-pid" type="w"/>
+ <smack request="system::use_internet" type="w"/>
+ <smack request="system::media" type="rwx"/>
+ <smack request="system::share" type="rwx"/>
+ <smack request="system::ext_storage" type="rwx"/>
+ <smack request="telephony_framework::api_ps_public" type="rw"/>
+ <smack request="tizen::vconf::account" type="rw"/>
+ <smack request="tizen::vconf::message" type="rl"/>
+ <smack request="tizen::vconf::platform::rw" type="rw"/>
+ <smack request="tizen::vconf::public::r" type="rl"/>
+ <smack request="tizen::vconf::setting" type="rl"/>
+ <smack request="tizen::vconf::setting::admin" type="rl"/>
+ <smack request="tizen::vconf::telephony::admin" type="rl"/>
+ </request>
+ </define>
<assign>
- <filesystem path="/usr/lib/libemail-api.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-api.so.1" label="_"/>
- <filesystem path="/usr/lib/libemail-ipc.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-ipc.so.1" label="_"/>
- <filesystem path="/usr/lib/libemail-common-use.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-common-use.so.1" label="_"/>
- <filesystem path="/usr/lib/libemail-core.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-core.so.1" label="_"/>
- <filesystem path="/usr/lib/libemail-core-sound.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-core-sound.so.1" label="_"/>
- <filesystem path="/usr/lib/libemail-device.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-device.so.1" label="_"/>
- <filesystem path="/usr/lib/libemail-network.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-network.so.1" label="_"/>
- <filesystem path="/usr/lib/libemail-storage.so.1.1.0" label="_"/>
- <filesystem path="/usr/lib/libemail-storage.so.1" label="_"/>
- <filesystem path="/etc/rc.d/init.d/email-service" label="_" exec_label="none"/>
- <filesystem path="/usr/lib/systemd/user/email.service" label="_"/>
- <filesystem path="/usr/lib/systemd/user/tizen-middleware.target.wants/email.service" label="_"/>
- <filesystem path="/usr/share/dbus-1/services/email-service.service" label="_"/>
+ <filesystem path="/usr/lib/libemail-api.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-api.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-common-use.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-common-use.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-container.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-container.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-core.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-core.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-device.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-device.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-ipc.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-ipc.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-network.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-network.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-smime-api.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-smime-api.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-smime.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-smime.so.1.1.0" label="_"/>
+ <filesystem path="/usr/lib/libemail-storage.so.1" label="_"/>
+ <filesystem path="/usr/lib/libemail-storage.so.1.1.0" label="_"/>
+ <filesystem path="/etc/rc.d/init.d/email-service" label="_" exec_label="none"/>
+ <filesystem path="/usr/lib/systemd/user/email.service" label="_"/>
+ <filesystem path="/usr/lib/systemd/user/tizen-middleware.target.wants/email.service" label="_"/>
+ <filesystem path="/usr/share/dbus-1/system-services/email-service.service" label="_"/>
</assign>
<request>
- <domain name="email-service"/>
+ <domain name="email-service"/>
</request>
</manifest>
diff --git a/email-service.rule b/email-service.rule
deleted file mode 100644
index 319e29b..0000000
--- a/email-service.rule
+++ /dev/null
@@ -1,20 +0,0 @@
-email-service email-service::db rw---- ------
-email-service system::use_internet -w---- ------
-email-service system::vconf rwxat- ------
-email-service system::vconf_inhouse rw---- ------
-email-service system::vconf_setting r----- ------
-email-service data-provider-master rw---- ------
-email-service secure-storage::pkcs12 r----- ------
-email-service security-server::api-privilege-by-pid -w---- ------
-system::use_internet email-service rwx--- ------
-system::share email-service rwx--- ------
-org.tizen.quickpanel email-service r-x--- ------
-org.tizen.indicator email-service rwx--- ------
-org.tizen.lockscreen email-service r-x--- ------
-org.tizen.app-selector email-service --x--- ------
-org.tizen.dropbox pkgmgr::db rw---- ------
-email-service deviced::display rw---- ------
-email-service connman rw---- ------
-email-service connman::set rw---- ------
-email-service connman::get rw---- ------
-email-service telephony_framework::api_ps_public rw---- ------
diff --git a/packaging/email-service.service b/packaging/email-service.service
index 4c74dd1..38a8834 100755
--- a/packaging/email-service.service
+++ b/packaging/email-service.service
@@ -3,6 +3,9 @@ Description=Email service
After=graphical.target
[Service]
+User=system
+Group=system
+SmackProcessLabel=email-service
Type=dbus
BusName=org.tizen.email_service
ExecStart=/usr/bin/email-service
diff --git a/packaging/email-service.spec b/packaging/email-service.spec
index 0cce5ea..90de1d6 100755
--- a/packaging/email-service.spec
+++ b/packaging/email-service.spec
@@ -1,12 +1,21 @@
Name: email-service
Summary: E-mail Framework Middleware package
-Version: 0.15.8
+Version: 0.15.14
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2.0
Source0: %{name}-%{version}.tar.gz
Source1: email.service
Source10: email-service.service
+
+%if "%{?tizen_profile_name}" == "wearable"
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+
+%if "%{?tizen_profile_name}" == "tv"
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+
Requires: connman
Requires: gmime
Requires(post): /sbin/ldconfig
@@ -27,7 +36,6 @@ BuildRequires: pkgconfig(vconf-internal-keys)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(dbus-1)
-BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(contacts-service2)
BuildRequires: pkgconfig(uw-imap-toolkit)
BuildRequires: pkgconfig(openssl)
@@ -40,8 +48,8 @@ BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(cert-svc)
+BuildRequires: pkgconfig(cert-svc-vcore)
BuildRequires: pkgconfig(badge)
-BuildRequires: pkgconfig(feedback)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(libwbxml2)
BuildRequires: pkgconfig(msg-service)
@@ -50,7 +58,7 @@ BuildRequires: pkgconfig(icu-i18n)
BuildRequires: pkgconfig(storage)
BuildRequires: pkgconfig(capi-network-connection)
BuildRequires: pkgconfig(capi-system-device)
-
+BuildRequires: pkgconfig(vasum)
%description
E-mail Framework Middleware Library/Binary package
@@ -113,43 +121,6 @@ echo "[EMAIL-SERVICE] Start adding preset account information..."
################################################################################################
-# for active sync
-vconftool set -t int db/email_handle/active_sync_handle "0" -g 5000 -s "email::vconf_active_sync_handle"
-
-# for default mail slot szie
-vconftool set -t int db/private/email-service/slot_size "100" -g 5000 -s "email::vconf_slot_size"
-
-# for latest mail id
-vconftool set -t int db/private/email-service/latest_mail_id "0" -g 5000 -s "email::vconf_latest_mail_id"
-
-# for default account id
-vconftool set -t int db/private/email-service/default_account_id "0" -g 5000 -s "email::vconf_default_account_id"
-
-# for default account id
-vconftool set -t int memory/sync/email "0" -i -g 5000 -s "email::vconf_sync_status"
-
-# for priority send
-vconftool set -t string db/private/email-service/noti_ringtone_path "/opt/usr/share/settings/Alerts/Over the horizon.mp3" -g 5000 -s "email::vconf_ringtone_path"
-vconftool set -t int db/private/email-service/noti_rep_type "0" -g 5000 -s "email::vconf_rep_type"
-vconftool set -t bool db/private/email-service/noti_notification_ticker "0" -g 5000 -s "email::vconf_notification"
-vconftool set -t bool db/private/email-service/noti_display_content_ticker "0" -g 5000 -s "email::vconf_display_content"
-vconftool set -t bool db/private/email-service/noti_badge_ticker "0" -i -g 5000 -s "email::vconf_badge"
-vconftool set -t int db/private/email-service/noti_private_id/1 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/2 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/3 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/4 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/5 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/6 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/7 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/8 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/9 "0" -i -g 5000 -s "email-service"
-vconftool set -t int db/private/email-service/noti_private_id/10 "0" -i -g 5000 -s "email-service"
-vconftool set -t bool db/private/email-service/noti_vibration_status "0" -g 5000 -s "email::vconf_vibration"
-vconftool set -t bool db/private/email-service/noti_vip_vibration_status "0" -g 5000 -s "email::vconf_vip_vibration"
-vconftool set -t bool db/private/email-service/noti_use_default_ringtone "1" -g 5000 -s "email::vconf_use_default_ringtone"
-vconftool set -t bool db/private/email-service/noti_vip_use_default_ringtone "1" -g 5000 -s "email::vconf_vip_use_default_ringtone"
-
-
#################################################################
# Set executin script
#################################################################
@@ -183,25 +154,40 @@ sqlite3 /opt/usr/dbspace/.email-service.db < /usr/share/email-service/email-serv
echo "[EMAIL-SERVICE] Finish Creating Email Tables."
chgrp 5000 /opt/usr/dbspace/.email-service.db*
+chown 200:200 /opt/usr/dbspace/.email-service.db*
chmod 664 /opt/usr/dbspace/.email-service.db
chmod 664 /opt/usr/dbspace/.email-service.db-journal
mkdir -m775 -p /opt/usr/data/email/.email_data
+chown 200 /opt/usr/data/email/.email_data
chgrp 5000 /opt/usr/data/email/.email_data
-chsmack -a 'email-service' /opt/usr/data/email/.email_data
+chsmack -t -a 'email-service::email_data' /opt/usr/data/email/.email_data
mkdir -m775 -p /opt/usr/data/email/.email_data/tmp
+chown 200 /opt/usr/data/email/.email_data/tmp
chgrp 5000 /opt/usr/data/email/.email_data/tmp
-chsmack -a 'email-service' /opt/usr/data/email/.email_data/tmp
+chsmack -t -a 'email-service::email_data' /opt/usr/data/email/.email_data/tmp
mkdir -p /opt/share/cert-svc/certs/trusteduser/email
+chown 200 /opt/share/cert-svc/certs/trusteduser/email
chgrp 5000 /opt/share/cert-svc/certs/trusteduser/email
+chsmack -a 'email-service' /opt/share/cert-svc/certs/trusteduser/email
if [ -f /opt/usr/dbspace/.email-service.db ]
then
chsmack -a 'email-service::db' /opt/usr/dbspace/.email-service.db*
fi
+if [ -f %{_libdir}/systemd/system/email-service.service ]
+then
+ chsmack -a '_' %{_libdir}/systemd/system/email-service.service
+fi
+
+if [ -f %{_libdir}/systemd/system/graphical.target.wants/email-service.service ]
+then
+ chsmack -a '_' %{_libdir}/systemd/system/graphical.target.wants/email-service.service
+fi
+
systemctl daemon-reload
if [ $1 == 1 ]; then
systemctl restart email.service
@@ -217,7 +203,8 @@ fi
systemctl daemon-reload
-%files
+%files
+%attr(-,system,system)
%manifest email-service.manifest
%{_bindir}/email-test-app
%{_bindir}/email-service
@@ -227,10 +214,10 @@ systemctl daemon-reload
%{_libdir}/systemd/user/tizen-middleware.target.wants/email.service
%{_libdir}/systemd/system/email-service.service
%{_libdir}/systemd/system/graphical.target.wants/email-service.service
-/usr/share/dbus-1/services/email-service.service
+/usr/share/dbus-1/system-services/email-service.service
/usr/share/license/email-service
-/etc/smack/accesses.d/email-service.rule
+#/etc/smack/accesses.d/email-service.rule
%files devel
%{_includedir}/email-service/*.h
diff --git a/res/email-service.sql b/res/email-service.sql
index 1d7f8d1..bac3073 100755
--- a/res/email-service.sql
+++ b/res/email-service.sql
@@ -65,7 +65,8 @@ CREATE TABLE mail_account_tbl
vibrate_status INTEGER,
display_content_status INTEGER,
default_ringtone_status INTEGER,
- alert_ringtone_path VARCHAR(256)
+ alert_ringtone_path VARCHAR(256),
+ user_name VARCHAR(256)
);
CREATE TABLE mail_box_tbl
(
@@ -168,6 +169,7 @@ CREATE TABLE mail_tbl
default_charset VARCHAR(257),
eas_data_length INTEGER,
eas_data BLOB,
+ user_name VARCHAR(256),
FOREIGN KEY(account_id) REFERENCES mail_account_tbl(account_id)
);
CREATE TABLE mail_attachment_tbl
@@ -194,7 +196,8 @@ CREATE TABLE mail_partial_body_activity_tbl
activity_id INTEGER PRIMARY KEY,
activity_type INTEGER,
mailbox_id INTEGER,
- mailbox_name VARCHAR(4000)
+ mailbox_name VARCHAR(4000),
+ multi_user_name VARCHAR(64)
);
CREATE TABLE mail_meeting_tbl
(
@@ -263,7 +266,8 @@ CREATE TABLE mail_auto_download_activity_tbl
account_id INTEGER,
mail_id INTEGER,
server_mail_id INTEGER,
- mailbox_id INTEGER
+ mailbox_id INTEGER,
+ multi_user_name VARCHAR(64)
);
CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_id);
CREATE UNIQUE INDEX mail_box_idx1 ON mail_box_tbl (mailbox_id);
diff --git a/utilities/CMakeLists.txt b/utilities/CMakeLists.txt
index 9009483..8559a67 100755
--- a/utilities/CMakeLists.txt
+++ b/utilities/CMakeLists.txt
@@ -13,7 +13,7 @@ MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
SET(VISIBILITY "-DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections -fPIE")
##########################################################
# Define Test App
@@ -29,7 +29,7 @@ SET(TEST-APP-SRCS
${CMAKE_SOURCE_DIR}/utilities/test-application/testapp-rule.c
${CMAKE_SOURCE_DIR}/utilities/test-application/testapp-thread.c
${CMAKE_SOURCE_DIR}/utilities/test-application/testapp-others.c
-# ${CMAKE_SOURCE_DIR}/utilities/test-application/testapp-gmime.c
+ ${CMAKE_SOURCE_DIR}/utilities/test-application/testapp-gmime.c
)
INCLUDE_DIRECTORIES(
@@ -42,7 +42,7 @@ INCLUDE_DIRECTORIES(
)
INCLUDE(FindPkgConfig)
-pkg_check_modules(test_app_pkgs REQUIRED glib-2.0 gthread-2.0 vconf uw-imap-toolkit contacts-service2)
+pkg_check_modules(test_app_pkgs REQUIRED glib-2.0 gthread-2.0 vconf uw-imap-toolkit contacts-service2 gmime-2.6)
FOREACH(flag ${test_app_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/utilities/test-application/main.c b/utilities/test-application/main.c
index de02f6b..ed4a95d 100755
--- a/utilities/test-application/main.c
+++ b/utilities/test-application/main.c
@@ -41,9 +41,7 @@
#include "testapp-rule.h"
#include "testapp-thread.h"
#include "testapp-others.h"
-#ifdef __FEATURE_USE_GMIME__
#include "testapp-gmime.h"
-#endif /* __FEATURE_USE_GMIME__ */
/* function prototype */
static void testapp_system_signal_handler (int signal_number);
@@ -164,11 +162,11 @@ static gboolean testapp_interpret_command (int menu_number)
case 7:
testapp_others_main();
break;
-#ifdef __FEATURE_USE_GMIME__
+
case 8:
testapp_gmime_main();
break;
-#endif /* __FEATURE_USE_GMIME__ */
+
case 0:
go_to_loop = FALSE;
break;
diff --git a/utilities/test-application/testapp-account.c b/utilities/test-application/testapp-account.c
index 1cc5d1f..5eae241 100755
--- a/utilities/test-application/testapp-account.c
+++ b/utilities/test-application/testapp-account.c
@@ -172,7 +172,7 @@ gboolean testapp_create_account_object(email_account_t **result_account)
account->options.add_my_address_to_bcc = 0;
account->check_interval = 0;
account->keep_mails_on_pop_server_after_download = 1;
- account->default_mail_slot_size = 200;
+ account->default_mail_slot_size = 20;
account->roaming_option = EMAIL_ROAMING_OPTION_RESTRICTED_BACKGROUND_TASK;
account->peak_interval = 30;
account->peak_days = EMAIL_PEAK_DAYS_MONDAY | EMAIL_PEAK_DAYS_TUEDAY | EMAIL_PEAK_DAYS_THUDAY | EMAIL_PEAK_DAYS_FRIDAY;
diff --git a/utilities/test-application/testapp-gmime.c b/utilities/test-application/testapp-gmime.c
index 8493160..dfed596 100644
--- a/utilities/test-application/testapp-gmime.c
+++ b/utilities/test-application/testapp-gmime.c
@@ -176,6 +176,7 @@ void testapp_gmime_main()
{
gboolean go_to_loop = TRUE;
int menu_number = 0;
+ int result_from_scanf = 0;
while (go_to_loop) {
testapp_show_menu (EMAIL_GMIME_MENU);
diff --git a/utilities/test-application/testapp-mail.c b/utilities/test-application/testapp-mail.c
index 8060f93..af7f296 100755
--- a/utilities/test-application/testapp-mail.c
+++ b/utilities/test-application/testapp-mail.c
@@ -1778,12 +1778,12 @@ static gboolean testapp_test_db_test()
char *cc = NULL;
char *bcc = NULL;
- to = (char *) malloc(500000);
- cc = (char *) malloc(500000);
+ to = (char *) malloc(500000);
+ cc = (char *) malloc(500000);
bcc = (char *) malloc(500000);
- memset(to, 0x00, sizeof(500000));
- memset(cc, 0x00, sizeof(500000));
+ memset(to, 0x00, sizeof(500000));
+ memset(cc, 0x00, sizeof(500000));
memset(bcc, 0x00, sizeof(500000));
testapp_print("Input Mail id:\n");
@@ -1801,8 +1801,8 @@ static gboolean testapp_test_db_test()
testapp_print("Input BCC field:\n");
if (0 >= scanf("%s", bcc))
testapp_print("Invalid input. ");
-
- if ( emstorage_test(mail_id, account_id, to, cc, bcc, &err) == true ) {
+
+ if ( emstorage_test(NULL, mail_id, account_id, to, cc, bcc, &err) == true ) {
testapp_print(">> Saving Succeeded\n");
}
else {
@@ -2018,6 +2018,138 @@ static gboolean testapp_test_get_address_info_list()
return TRUE;
}
+static gboolean testapp_test_search_mail_on_server()
+{
+ testapp_print(" >>> testapp_test_search_mail_on_server : Entered \n");
+
+ int err_code = EMAIL_ERROR_NONE;
+ int account_id = 0;
+ int mailbox_id = 0;
+ int search_key_value_integer = 0;
+ int search_filter_count = 0;
+ email_search_filter_type search_filter_type = 0;
+ email_search_filter_t search_filter[10];
+ int handle = 0;
+ time_t current_time = 0;
+ char search_key_value_string[256];
+
+ testapp_print("input account id : ");
+ if (0 >= scanf("%d",&account_id))
+ testapp_print("Invalid input. ");
+
+ testapp_print("input mailbox id : ");
+ if (0 >= scanf("%d", &mailbox_id))
+ testapp_print("Invalid input. ");
+
+ memset(&search_filter, 0x00, sizeof(email_search_filter_t) * 10);
+
+ while (1) {
+ testapp_print(
+ " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO = 1, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_UID = 2, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_ALL = 3, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_BCC = 7, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_BODY = 8, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_CC = 9, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FROM = 10, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_KEYWORD = 11, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_TEXT = 12, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_SUBJECT = 13, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_TO = 15, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER = 16, ( integet type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER = 17, ( integet type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE = 20, ( time type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON = 21, ( time type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE = 22, ( time type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED = 26, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW = 27, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED = 28, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD = 29, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT = 30, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED = 32, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT = 34, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN = 36, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID = 43, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY = 50, ( integer type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME = 60, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_CHARSET = 61, ( string type ) \n"
+ " EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED = 62, ( string type ) \n"
+ " END = 0 \n");
+
+ testapp_print("input search filter type : ");
+ if (0 >= scanf("%d", (int*)&search_filter_type))
+ testapp_print("Invalid input. ");
+
+ search_filter[search_filter_count].search_filter_type = search_filter_type;
+
+ switch(search_filter_type) {
+ case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
+ case EMAIL_SEARCH_FILTER_TYPE_UID :
+ case EMAIL_SEARCH_FILTER_TYPE_ALL :
+ case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER :
+ case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN :
+ case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY :
+ testapp_print("input search filter key value : ");
+ if (0 >= scanf("%d", &search_key_value_integer))
+ testapp_print("Invalid input. ");
+ search_filter[search_filter_count].search_filter_key_value.integer_type_key_value = search_key_value_integer;
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_BCC :
+ case EMAIL_SEARCH_FILTER_TYPE_BODY :
+ case EMAIL_SEARCH_FILTER_TYPE_CC :
+ case EMAIL_SEARCH_FILTER_TYPE_FROM :
+ case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
+ case EMAIL_SEARCH_FILTER_TYPE_TEXT :
+ case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
+ case EMAIL_SEARCH_FILTER_TYPE_TO :
+ case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
+ case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+ case EMAIL_SEARCH_FILTER_TYPE_CHARSET :
+ case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED :
+ testapp_print("input search filter key value : ");
+ int readn = read(0, search_key_value_string, 256);
+ if (readn < 0)
+ testapp_print("Invalid input. ");
+
+ search_filter[search_filter_count].search_filter_key_value.string_type_key_value = strndup(search_key_value_string, readn - 1);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON :
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE :
+ time(&current_time);
+ /* TODO : write codes for converting string to time */
+ /* search_filter.search_filter_key_value.time_type_key_value = search_key_value_string; */
+ search_filter[search_filter_count].search_filter_key_value.time_type_key_value = current_time;
+ break;
+ default :
+ testapp_print("END filter type [%d]", search_filter_type);
+ break;
+ }
+
+ if (!search_filter_type)
+ break;
+
+ search_filter_count++;
+ }
+
+ if( (err_code = email_search_mail_on_server(account_id, mailbox_id, search_filter, search_filter_count, &handle)) != EMAIL_ERROR_NONE) {
+ testapp_print("email_search_mail_on_server failed [%d]", err_code);
+ }
+
+ testapp_print(" >>> testapp_test_search_mail_on_server : END \n");
+ return TRUE;
+}
+
static gboolean testapp_test_add_mail_to_search_result_box()
{
int i = 0;
@@ -2212,7 +2344,13 @@ static gboolean testapp_test_email_parse_mime_file()
if (!email_verify_signature_ex(mail_data, mail_attachment_data, attachment_count, &verify))
testapp_print("email_verify_signature_ex failed\n");
} else {
- if ((err = email_get_decrypt_message_ex(mail_data, mail_attachment_data, attachment_count, &output_mail_data, &output_mail_attachment_data, &output_attachment_count)) != EMAIL_ERROR_NONE)
+ if ((err = email_get_decrypt_message_ex(mail_data,
+ mail_attachment_data,
+ attachment_count,
+ &output_mail_data,
+ &output_mail_attachment_data,
+ &output_attachment_count,
+ &verify)) != EMAIL_ERROR_NONE)
testapp_print("email_get_decrypt_message_ex failed\n");
}
@@ -2630,6 +2768,9 @@ static gboolean testapp_test_interpret_command (int menu_number)
case 57:
testapp_test_update_mail();
break;
+ case 58:
+ testapp_test_search_mail_on_server();
+ break;
case 59:
testapp_test_add_mail_to_search_result_box();
break;
diff --git a/utilities/test-application/testapp-others.c b/utilities/test-application/testapp-others.c
index d108870..51c2af1 100755
--- a/utilities/test-application/testapp-others.c
+++ b/utilities/test-application/testapp-others.c
@@ -99,7 +99,7 @@ static gboolean testapp_test_get_preview_text_from_file()
if (0 >= scanf("%s", html_file_path))
testapp_print("Invalid input. ");
- emcore_get_preview_text_from_file(NULL, html_file_path, 1024, &preview_buffer);
+ emcore_get_preview_text_from_file(NULL, NULL, html_file_path, 1024, &preview_buffer);
testapp_print("\n result :\n %s ", preview_buffer);